Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4420 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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

Posted

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 ?

Posted

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

Posted

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.

  • Like 1

This topic is 4420 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.