Randomize the text of a question.

Have you ever wanted to randomize the text in a question. For example , if you are running a telephone interviewing job you may want the interviewer to read read the list out in a different order each time.  In this article we will show you one way that this can be done.

First off we need the texts to randomize. So lets make the question metadata and setup up an array to put the texts in.
First the metadata

Q1 “What do you like , please read out in this order ..

and now record the result.” categorical [1..]
_1 “Text 1”,
_2 “Text 2”,
_3 “Text 3”,
_4 “Text 4”,
_5 “Text 5”,
_6 “Text 6”,
_7 “Text 7”

and then in the routing we can start to add the code for the randomizing. So first off we need an array of the texts.

Dim aTexts[8]

aTexts[1] = “
Text 1″
aTexts[2] = “
Text 2″
aTexts[3] = “
Text 3″
aTexts[4] = “
Text 4″
aTexts[5] = “
Text 5″
aTexts[6] = “
Text 6″
aTexts[7] = “
Text 7″

Then with the ransequence command we can produce a a list of numbers in a random order.

Dim aRandom,aRan,sText

aRandom = ransequence(1,7,1)

then we can loop the random number and build up a string that can be used as a label insert into the question text before it is asked.

for each aRan in aRandom
    sText = sText + aTexts[aRan]

Q1.label.inserts["ReplaceMe"] = stext

And there we have it. What we will end up with is something like this.

Final Output

Leave a Comment

%d bloggers like this: