Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I'm hoping to piece together a script which shuffles the contents of three fields, but am not really sure if this is do-able, or where to begin.

Any ideas would be very welcome.

I have a DB with multiple-choice test questions in it, and each record has three fields [A, B, and C] with three possible answers in the; one of them is correct. I have another field [correct] with the correct answer to the record's question, and yet one more [answer] that returns either A, B, or C, depending on which field [A,B, or C] matches the correct answer [correct]. From there I have a few layouts that allow me to select records from the master DB to include in various versions of the test. All that works fine.

What I *want* to do is create a script which will shuffle the contents of fields A, B, and C around randomly within a record so I can quickly create different versions of the same test. Since the [correct] field wouldn't change, the [answer] field should still provide the correct match by locating the field [A, B, or C] which contains the right answer. I just can't crack how to randomly shuffle the contents of the three fields [A, B, and C].

Did that make sense? Hope so.

Any ideas, anyone?

Thanks in advance.

Posted

This is a little roundabout, but should work.

Number fields: Low and High

Randomizer, a calculated field:

Low + Round (Random * (High - Low), 0)

Global fields: gA, gB, gC

Script:

Go to Record (First)

Loop

Set Field (Low, 1)

Set Field (High, 3)

# This produces a random number between 1 and 3

Set Field (gA, Choose(Randomizer, "", A, B, C)

Set Field (gB, Choose(Randomizer, "", C, A, :

Set Field (gC, Choose(Randomizer, "", B, C, A)

# Your order will be ACB, BAC, or CBA

Set Field (A, gA)

Set Field (B, gB)

Set Field (C, gC)

Go to Record (Next, exit after last)

End Loop

If you want to be extra-random, run the script two or three times.

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