Keep the same randomization order of answers/topics for several questions

Overview

A common requested scripting technique is to display a set of answers on screen in some randomized order. It could be there’re several questions with the same set of answers, where you would want to display that set of answers in a randomized order, yet in the same randomized order in each question.

This HowTo will show how this can handled.

 

1. Step 1: Create a Dummy Open Ended Question:

2. Step 2: Determine the randomized order

3. Step 3: Add the randomization code to all questions

 

Step 1: Create a Dummy Open Ended Question

Add an open ended question to the script, and set it to be hidden from surveyor.

The purposes of this question would be to save a string of the answers set indexes in the chosen randomized order:

 

Step 2: Determine the randomized order

Add the following code to the first question’s (out of the questions to display…) start script:

 

if (!Answered(QRef(1)))
{

     // create array of all answers indexes in a randomized order
     var arr=CreateRandomArray(GetAnswerCount(CurrQues));
     // set the string of the indexes randomized order in the dummy question
     SetAnswer(QRef(1),IntArrayToString(arr));
}

 

Step 3: Add the randomization code to all questions

In all displayed questions’ start script, add this code:

RandomizeAnswers(CurrQues,StringToIntArray(Answer(QRef(1)).ToString()));

 

That’s it!

 

Visit us at:  http://www.dooblo.net

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

1 comment
  • Hi, i tried this script as instructed, but not work,

    the items list not has the same order for each questions but the ordering is different.

    Maybe in the first question (dummy) i need something else? For example variables ecc ecc?

     

     

Please sign in to leave a comment.