Jump to content

Script to display a random record


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

Recommended Posts

I am creating a quiz from a db in which each record has the following fields:

1- street names (question)

2- location (answer)

3- hint

4- map (container)

I have created layouts displaying:

1-street name only (question)

2-street name & hint

3-street name & map

4-street name, location & map (answer)

I need to display each next question (street name) in a random order and I cannot seem to create a script that will do this.

Is a script the way to do this or do I need a different approach ?

Any help would be appreciated, I have firefighters who need to learn their streets and this will help them do it in non-alphebetical order !!

Thanks, joefire

Edited by Guest
Link to comment
Share on other sites

First you need to get a random number. FileMaker has the Random function that generates a random number from 0 to 1; you can employ it to get a random integer from 1 to desired range:

Int( Random *  ) + 1




To go to a random record make a global field Record # and write a script:




Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]




To display all the records in random order you need a loop:




Loop

Exit Loop If [ Status( CurrentFoundCount ) = 0 ]

#

Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]

#

# Do your stuff here, i.e. display the first layout, then go to hint, etc.

#

Omit Record

End Loop

Link to comment
Share on other sites

Thank you, this worked very nicely !

I didn't need the loop as I will have only one record (question) show at a tme and a button for this script that will take me to next random record.

Question:

Will this script eventually take me through all 680 records without repeating too often.

Here is what I'm using:

Set Field[ Record #, Int( Random * Status( CurrentFoundCount ) ) + 1 ]

Go To Record/Request/Page [ By Field Value, Record # ]

Go to Layout ["Streetonly"]

Thanks again

Link to comment
Share on other sites

It will follow the law of large numbers, meaning that the distribution of repeats will approach some constant as the number of experiments (people taking the quiz) grows.

In order to make a more precise prediction, we would need to know how many questions are there in a quiz. For example, if there are 10 questions in total, and a quiz requires a person to answer 2 questions, the probability of getting the same question twice is 10%. If the quiz requires 3 questions, then the probability increases to 19%.

Link to comment
Share on other sites

Thanks so much for all your help. I added the capability to go to the next street alphabeticaly just in case some wish to be more methodical.

There are 680 streets which are divided about evenly into four districts. They may be studied all together or by district. I dont know if those are large numbers but I will have to test to check the repeats.

Thanks to all !

Edited by Guest
Spelling
Link to comment
Share on other sites

I am afraid you may have misunderstood my remark.

First, the "large numbers" bit referes to the number of quizzes taken, not the number of questions in a quiz. You cannot predict whether a question will repeat during a single quiz; you can only predict the AVERAGE result of a large number of quizzes.

Next, in order to make such prediction, we need to know not only the number of possible questions, but also how many question will be actually asked; obviously, if only one question is asked, the chances of a repeat are zero; if more than 680 questions are asked, repetition is certain; in-between, the probability rises on a curve from 0 to 100%.

Link to comment
Share on other sites

This topic is 6545 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.