**Overview**

This how to will introduce you to a method of creating different answer randomization according to a given order and script.

In this article you will find 2 examples.

**Example 1:**

Saying for example you have a question with answers 1,2,3,4,5.

For Males it should be asked in the answer order of 2,1,3,5,4 and for females in the order of 5,4,3,1,2.

This will allow you to set these different orders in a few simple steps.

**Step 1: **Hidden Single-Choice question for Order logic

**Step 2: **Set the order logic.

**Step 3: **Use the randomization.

**Step 1: Hidden Single-Choice question for Order logic**

First, you should create a hidden single-choice question somewhere in the beginning of your survey, representing the relevant orders as answers, for example:

Answer 1: 1,2,3,4,5

Answer 2: 5,1,2,3,4

Answer 3: 4,5,1,2,3

Answer 4: 3,4,5,1,2

Answer 5: 2,3,4,5,1

* For this example this questions index will be 1.

**Step 2: Set the order logic.**

Now, you should use SetAnswer() in your desired script, according to your personal survey logic, in order to set the answer of our hidden single-choice question, for example:

SetAnswer(1,3);

I have chosen answer 3, therefore, the given order will be:

4,5,1,2,3

**Step 3: Use the randomization.**

Now, in the question where I want to change the order of it’s answers, I would place the following code in it’s start script:

*RandomizeAnswers(CurrQues, StringToIntArray(SelectedAnswerText(1)));*

* RandomizeAnswers(); get’s two parameters.

1^{st} parameter is the question index, 2^{nd} parameter is an array of integers with the given answer indexes.

So it would get the selected rotation as a string, for example: “4,5,1,2,3″

turn it into an integer array: {4,5,1,2,3}

And then, randomize this questions answers according to this array.

**Example 2:**

In the attached survey example we will display a list if drinks in a randomized order, with the following limitation:

- "Diet Coke" and "Cocal-cola zero" will always be shown one after the other.

- "DK" and "None" will always be displayed last

The randomization script is done in the Expression question (Q2).

**That’s it!**

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

## Comments

Please sign in to leave a comment.