Randomizing Questions

I have a list of 7 statements which need to be rated separately. How do I randomize these statements?

Are you wanting to randomize the order of questions? Or randomize the displayed order of options within a single select_one/select_multiple question?

If you want to randomize questions see: Randomizing the order of questions - Showcase - ODK Forum

If you want to randomize select options see: XLSForm Docs

1 Like

Hi @Xiphware I want to randomize the questions

Hi @Xiphware I managed to solve this by following steps

Step 1: Randomize the questions in a .csv file
Step 2: Use the random() function to generate random numbers as 1-9 e.g. round(${Rand}*9). “Note, these are two separate calculate variables”
Step 3: Pull the value label in a calculated field using the function pulldata(‘csv_file’, ‘order_value’, ‘order_id’, ${Random_Value_Above}).
Step 4: Pipe above the calculated field as per the question.

Thanks

1 Like

Be aware that generating two random numbers is easy, but generating two different random numbers is quite tricky… Specifically,

rand1 = once(int(random()*9)+1)
rand2 = once(int(random()*9)+1)

will generate two random numbers between 1..9. However, these two random numbers can - and certainly will sometimes - be the same!

Have a play with this form. If you run it a few times you will see the same random number generated.

Random.xlsx (14.4 KB)

1 Like

Note, please use a calculation like mine above to accomplish this; ie

once(int(random()*9)+1)

random() will give you a random decimal between 0.0 (inclusive) and 1.0 (exclusive!)

multiple this by 9 to give you a random decimal between 0.0 (inclusive) and 9.0 (exclusive)

int() will drop the decimal portion, therefore giving you a random integer between 0 and 8 (inclusive).

add 1 to make this a random integer between 1 and 9 (inclusive).

and finally wrap it all in a once() so you dont keep regenerating this random number more than once every time the form refreshes calculations (which happens continuously while you are filling in a form…)

Whereas a calculation like:

round(random()*9)

will actually give you a number between 0 and 9 (!), with a non-uniform distribution at either end due to rounding up to 9 only above 8.5, and down from 0 only below 0.5. But you wont actually realize this unless you do it repeatedly over many samples and notice somewhat skewed results (and the occasional error due to getting a 0!)

1 Like

@Xiphware i will give it a try