How do I ask only a few select questions randomly based on a list of questions

Dear All,

I am developing a form that originally had 30 questions, but including all these questions turned out to be extremely long.
So, I want to develop a form in two parts that (i) asks around 5 common questions (such as age, gender, etc), and then (ii) asks 5 randomly picked questions (based on 30 questions available) to make the form short… This would mean each respondent would have 5 common questions, and 5 completely randomly assigned questions.
Is there any way to do that through the xls form?

Thank you in advance!

Hi @biraj_ad,

These posts might have your answer, if not feel free to ask about your spesific request, community will gladly help you :slight_smile:

All the best,

2 Likes

Hello @biraj_ad,
Be aware that there will be 5! (factor) = 1×2×3×4×5 = 120 possible combinations, out of a total of 30! (factor) = 2.6525286 × (10)**32 (power) combinations to consider for full randomisation (incl. order). So, you need another approach.

2 Likes

Hi @wroos
That’s true. It would be extremely tedious to do that. So, this is what I’m trying to do:

  1. Generate 5 random numbers rand1, rand2, rand3, rand4 and rand5 using once(int(30*random())+1)
  2. using relevant column for each 30 questions. This means if ${rand} =1, then the form will ask the first question and so on.

The problem I now have is that the random numbers repeat, meaning that some responses will have the same question repeating two or even three times. So now, I’m trying to figure out if its possible to create random numbers without repetitions (that is, rand1, rand2, rand3, rand4 and rand5 should be unique and in between 1 and 30 inclusive).

Here is a draft xls form that might help with the understanding.

Thanks!!
Kobo_v3.xls (51.5 KB)

Hello @biraj_ad,
with this approach you will also have the problem for analysis that you will have 5*30 variables in your data set, as you can only set a variable at one place.

You might extend each relevant clause with a check if the corresponding question(s) was not selected in the previous set(s).

You may perhaps try using the randomize function to select 5 numbers (first subset, selected-at) out of a set of 30 (“1 2 3 … 30”). And define as relevant only one number of 30 to each question exclusively. See https://getodk.github.io/xforms-spec/#fn:randomize.
You could implement this with your random value and using it for selected-at on “1 2 3 … 30”. See https://getodk.github.io/xforms-spec/#fn:selected-at

I would like to suggest for testing that you reduce your development/research of a solution first to a small list a questions.

Side-note: Your select_one choices seem always the same. Why not reuse one choice_list? Why not code the name of the choices in numeric style (-3 …+3)?

1 Like

Thank you @wroos for your tips in making the form a bit more efficient.
For the repeated random number problem, what I opted for is to check whether the random number is repeated or not and then re-randomize the number. So, for example, it would check whether rand5 is repeated across rand1, rand2, rand3 and rand4, and if yes, then a new random number is generated, if not, it retains its current value using this line of code:

if(${rand5} = ${rand4} or ${rand5} = ${rand3} or ${rand5} = ${rand2} or ${rand5} = ${rand1}, once(int(30*random())+1), ${rand5})

Since the re-generated random value could repeat again, I did this iteration 5 times (calculated that this would lead to the probability of number repetitions of only 0.000037 so it should be fine). I admit that this is a weird workaround, but at least it works!

Best,
Biraj

1 Like

Hello @biraj_ad,
could you share a form extract with your solution, please?

1 Like

Hi @wroos

Here is the form extract.
UniqueRandom_extract.xls (28 KB)

Also, I just noticed your side note on choice_list but could not find an exact documentation or example covering this. Could you share a link that explains about this?

Best,
Biraj

Hello @biraj_ad,
it is easy: The same choice_list can be used multiple times in a select in the survey sheet, (if the choices are all the same or can be filtered by a choice_filter). For ex.
select_one fruits Which fruit did you like the most for breakfast?
select_one fruits Which fruit did you like the most for lunch?
select_multiple fruits Which fruits do you not like?
(might be filtered by choice_filter as not selected in the 2 previous questions)

choice_list | name | label
fruits | 1 | apple
fruits | 2 | banana
fruits | 3 | strawberry

2 Likes