Advanced Randomization using Custom Scripting

Setup script to randomize all questions

The Script for Randomization is as below:

#set($ary = ["Q3", "Q4", "Q5", "Q6","Q7","Q8"])
#set($ary = $survey.randomizeList($ary))

#foreach( $val in $ary)
 $survey.branchTo("$val")
#end
 
In the above script in the first statement questions Q3, Q4, Q5, Q6, Q7 and Q8 are added to a list and randomized in the second statement. Once randomized the survey branches to each question randomly. Steps for setting this up:

Setup the basic survey with all the Questions.

Now to randomize questions 3 through 8 add the Custom Scoring/Logic question just before Q3

Enter the above script in the Custom Scoring / Logic question.

For Randomization to work there has to be a common block termination question with which the Survey should continue. In the above instance the Block Termination Question is Q9

Branch each of the Question in the above list i.e. Q3, Q4, Q5, Q6, Q7 and Q8 to Q9 which is the Block Termination Question and test the Survey!

Setup Randomization to randomly select 3 questions from a pool of 6 questions (N out of M)

The Script is as below:

#set($ary = ["Q3", "Q4", "Q5", "Q6","Q7","Q8"])
#set($ary = $survey.randomizeList($ary, 3))

#foreach( $val in $ary)
 $survey.branchTo("$val")
#end
 
In the above script questions Q3, Q4, Q5, Q6, Q7 and Q8 are added to a list and randomized. After randomization only 3 questions are returned to the list randomly and subsequently the survey branches to only those 3 questions. Steps for setting this up:

Setup the basic survey with all the Questions.

Now to randomize questions 3 through 8 add the Custom Scoring/Logic question just before Q3

Enter the above script in the Custom Scoring / Logic question.

For Randomization to work there has to be a common block termination question with which the Survey should continue. In the above instance the Block Termination Question is Q9

Branch each of the Question in the above list i.e. Q3, Q4, Q5, Q6, Q7 and Q8 to Q9 which is the Block Termination Question and test the Survey!

You can use the same logic for Randomizing entire Blocks of Questions. To do so add only the first question in each block for Randomization and branch the last question of each block to the common block termination question.
Start your Free Trial