October 17, 201213 yr I am currently creating a database which is used to create quiz questions. I would want to select 10 random questions from the database each time. Though these quiz sessions are unlikely to be very frequent, I would want this to function in a way that every time I open the database different questions need to be selected (I understand that 1 or 2 repetitions are inevitable) The problem that I am facing is that I unable to create random selections quiz questions Currently I am using a script as mentioned below Randomfield (number) in the database And have used the script Go to Layout Replace field contents(No dialog; table name::Randomfield; Random) Omit multiple records (no dialog; 10) show omitted records I would be grateful if someone can help me with this Thanks Sanjay
October 17, 201213 yr Can you describe what result you are getting that isn't the result you want? It may help diagnose the issue. Do you use the Show All Records script step before selecting random records? You should. To be multi-user safe, improve performance, and have one fewer field in your schema, I recommend a slightly different approach: Go to Layout [...] Show All Records Set Variable [$questionCount; Value:10] Loop Exit Loop If [Let ( $i = $i + 1 ; $i > $questionCount ) or Get ( FoundCount ) = 0] Go to Record/Request/Page [/* By number */ Ceiling ( Random * Get ( FoundCount ) )] Omit Record End Loop Show Omitted Only
October 17, 201213 yr try Ceiling ( (Random)*100) the 100 would be the total amount of questions you have. then simply pull that question. then loop 9 more times. I think this is what you are asking ?
October 17, 201213 yr Author Thanks very much for the suggestions. I will try them out. I have been using show all questions before the randomselection But I think I must try out other things because what i get is still in a similar order (as my question numbers) rather than random and even if i get random questions, I get the same random questions with every log in. Thank you
October 18, 201213 yr The reason your original script wasn't working is because you weren't sorting after the replace field contents step. But the previously suggested methods are much more efficient, so I would recommend using those.
Create an account or sign in to comment