Professional > Interview scripting > Writing interview scripts > Sorting categorical response lists > Displaying responses in random order
 
Displaying responses in random order
Note Randomization behaves differently depending on whether you specify it in the metadata or the routing section.
In the metadata section
To display responses in a different random order each time the question is asked, type:
Qname "Text" categorical [NumResps] {
  Responses
} ran;
ran is an abbreviation for the randomize keyword which you can use if you prefer.
For example:
OtherIssues "And are there any other issues that are of concern
to you?" categorical [0..]
{
FindingThings "Finding things/navigating around",
Speed "Speed/bandwidth",
Regulation "Government regulation",
EqualAccess "Equal access for all",
Pornography,
InternetCrime "Internet crime (e.g. hate crimes, stalking)",
Paying "Paying for online services or information",
Censorship,
Privacy
} ran;
When you specify randomization in the metadata section, the randomization pattern is based on the number of responses in the response list, so if there are several questions with randomized response lists and they all have the same number of responses, the randomization sequence for all of those lists will be the same. The interviewing program does not recalculate the randomization pattern for each question. If your script contains two response lists of four responses and two response lists of five responses, the two response lists with four responses will both use one randomization pattern while the two response lists containing five responses will both use another randomization pattern.
In the routing section
To randomize responses using a statement in the routing section, type:
Qname.Categories.Order = OrderConstants.oRandomize
When you specify randomization in this way, the randomization patterns are recalculated for each question using what is known as a seed value which is based on the system’s GetTickCount function. If your script contains two response lists of four responses and two response lists of five responses, each list will use a different randomization pattern. The exception is for questions in a loop, where the same seed value and randomization pattern is used for each iteration.
If you want to use the same seed value for all randomized questions in an interview and, thus, have the same randomization pattern for all questions with the same size response lists, you must save it and then set it before each question is asked. To save the randomization seed, place the following statements in the routing section:
Dim variablevariable = GetRandomSeed()
Then, before the .Ask statement for each question that will use that seed, type:
SetRandomSeed(variable)
For example, if the ISPNames and ISPUsed questions both use the same shared list, the following routing statements will display both response lists in the same random order:
Dim seed
seed = GetRandomSeed()
ISPNames.Categories.Order = OrderConstants.oRandomize
ISPNames.Ask()
SetRandomSeed(seed)
ISPUsed.Categories.Order = OrderConstants.oRandomize
ISPUsed.Ask()
General information
Randomization does not apply to responses that have a fixed position in the response list. For more information, see Responses with fixed positions in the response list.
If the respondent snaps back to a question with a randomized list, the interviewing program presents the list in the order in which it was originally displayed, regardless of how many times the respondent views the question.
If you specify ordering for a question in both the metadata and the routing section, the routing specification overrides the metadata specification. For further information about defining order in the routing section, see Controlling response order from the routing section.
See also
Sorting categorical response lists