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

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

Recommended Posts

  • Newbies
Posted

Hi all!

I have 5 fields. 4 fields gets one random number each that represents false answers to a question, Field=1 Field=2 Field=3 Field=4. The 5th field automatically fetches a number that represents the right answer to the question. For simplicity we assume that the right answer shows up i field5. In the application the right answer is randomly placed i Field 1-5.

So what I'm basically doing is posing a question and 5 possible answers show up on screen. 1 is correct and 4 is false.

1. Now, my problem is that from time to time there can be 2 (or more) identical incorrect answers showing up. Example: Field1= 45 Field2 = 13 Field3= 567 Field4 = 13 Field5= 435 (correct answer).

What I want to do is to check if there are any equal numbers in the fields, and if so, randomize the 4 fields with the incorrect answers again BUT

2. The next problem is that from time to time 2 (or more) correct answers show up. Example:Field1= 45 Field2 = 435 Field3= 567 Field4= 13 Field5 = 435

So I need to check which field that displays the correct answer, and then randomize the other 4 fields and do same checking again until there are 5 unique numbers in the 5 fields.

So what i need to do is the following:

* check in which field the correct answer is displayed and "lock" it.

* compare the 4 fields with incorrect answers. 1. Are there any equal numbers? 2. Are there the same number as in the field with the correct answer?

* If there are equal numbers in the incorrect answers, randomize again until there are 4 unique numbers and none of them is the same as in the field with the corect answer.

* If there are the same number in the field with the correct number as in any of the fields with the incorrect numbers, randomize the 4 fields with the incorrect answers again until there are 5 unique numbers in the answerfields.

I guess this can be solved with some kind of nested loop, but I just can't figure out HOW........I appreciate all help I can get in solving this little puzzle.... confused.gif

Thanks in advance

/nic

Posted

It might be easier to change the order of the things around a bit. I would first generate a list of 4 unique, incorrect, random numbers. This would be a loop, generating a random number into a temp field, then - if this number is indeed incorrect and not already in the list - add it to the list.

When you have your 4 numbers, insert the correct answer at a random position in the list. The 5 fields can be calculation fields, each showing one value from the list.

  • 2 months later...
Posted

i am doing exactly this, it is complicates, im sure you can do better than what ive done, but here it is anyway:

have your 5 fields

have calc fields = to your 5 fields

have a global random value

have 5 display calc fields, so if(randomfield < 0.1, fieldset1, if (randomfield < 0.2, fieldset2.... etc))

you have to engineer the duplicate fields so that for any random value, all results are displayed

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