Randomization: Texts

Note: This page explains how to randomize texts with a Random Generator and some PHP code. Since this is already the 2nd step of the procedure, please read the Randomization with PHP-Code page first.

If your stimulus is a text, the function text() must be used when including it via PHP code. This function embeds the HTML code as a text module in a page.

At first you need to create a random generator (siehe Randomisierung mit PHP-Code). The next step is to create the stimulus texts as Text in the List of Questions. After that, when Compose Questionnaire, you place a PHP code on the page under the random generator. This code might look like this:

if (value('RG01') == 2) {
  text('ST01');
} elseif (value('RG01') == 3) {
  text('ST02');
}

With this PHP code, the group “Positive case studies” (random generator value RG01=2) would display the text with the ID “ST01”, the group “Negative case studies” (random generator value RG01=3) would display the text with the ID “ST02”, and the control group (random generator value RG01=1) would display nothing.