Piping random words into a question text based on pre-made lists

The Challenge

I got an interesting scripting request recently. The request consisted of presenting subjects with a description of a hypothetical individual and randomly vary the person’s attributes. , so in other words – pipe in randomly selected characteristics.

Example: the items inside the [] are the elements to be randomly assigned. Only one from each [] would be displayed in the question text:

The person is He is from the [North/East/Central/West] region of Uganda, his home language is [Acholi/Luganda/Runyolo], and he has [light/dark] skin. He is [Catholic/Muslim/Protestant/Evangelical/not religious] and [works in an office/ works in a shop/ works on a farm/is unemployed].

The Solution

It was actually pretty easy to do using SurveyToGo. I started off with the following steps:

  1. Add the actual question and configure the text of it to be:
    He is from the {0} region of Uganda, his home language is {1}, and he has {2} skin. He is {3} and {4}
    ** We will later pipe the correct random attributes to the {xx} place holders.
  2. Add 5 questions at the beginning of the survey. Each question will represent a category:
    1. Region: (answers: North/East/Central/West)
    2. home language: (answers: Acholi/Luganda/Runyolo)
    3. skin: (answers: light/dark)
    4. religion: (answers: Catholic/Muslim/Protestant/Evangelical/not religious)
    5. employment: works in an office/ works in a shop/ works on a farm/is unemployed
  3. Configure each of the 5 questions to be “hide from surveyor” (in the advanced tab). This will make sure they are not shown during the survey as we will only use them for the randomization:
  4. Finally, in the start script of the question that has the text, I added the following script:

if (!Answered(1)) {

      SetAnswer(1,Random(3)+1);

      SetAnswer(2,Random(3)+1);

      SetAnswer(3,Random(2)+1);

      SetAnswer(4,Random(5)+1);

      SetAnswer(5,Random(4)+1);

}

SetTextFormat(CurrQues,SelectedAnswerText(1),SelectedAnswerText(2),SelectedAnswerText(3),SelectedAnswerText(4),SelectedAnswerText(5));

This script

  1. Randomly chooses answers to the dummy questions using the “Random()” function.
  2. Pipes the chosen answers of the dummy questions to the text of the current question.

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

Advertisements