Translations of this page:
 

Randomization with PHP-Code

For more complex randomizations, such as the combination of questions and stimuli, or even for more complex HTML coding of the stimuli, it makes sense to integrate the randomization into the questionnaire using a PHP code. How it works will be explained with some examples on this page.

Note: If you want to randomize only one stimulus (image or other media files), the simple procedure described in Single Factorial Design should suffice.

Note: If you want to display only part of the random stimuli, please refer to the Randomization: within-subject (Measurement Repetition) chapter.

Step 1: Randomization - Dividing into Experimental Groups

In any case, the first step for the following examples is to use a random generator to classify the participants into different experimental groups. Therefore a new question type Random Generator has to be created (see Create Questions).

Example:
Note shows the number “1
Number “1” is the assigned number of “group 1” and group 1 is to receive a certain stimulus

By creating this question type, you define the subdivision into different groups. Each participant is assigned to one of these groups, described below as the participant figuratively draws a “slip of paper” with the number of the group. In the field Codes (contents) write a short description of your experimental groups, e.g.:

Control group
Positive case studies
Negative case studies

Nach dem Speichern ergänzt SoSci Survey für jede Gruppe einen numerischen Code, z.B.

1 = Control group
2 = Positive case studies
3 = Negative case studies

What will be displayed to which group later is determined only in the next step – that is, when the corresponding PHP code is included.

Step 2: Presentation of the Stimulus

As described above, so far it is only defined to which group the participant belongs (defined by the random number).

To define which group is now presented which stimulus, you need a PHP code for a filter. This is placed when Composing the Questionnaire under the random generator on the page on which the stimulus is to be displayed. This will look something like this:

Der Zufallsgernerator wird über dem PHP-Code platziert

Note: After placing the random generator and the PHP code, the stimuli don't have to be explicitly included on the questionnaire page!

There are different ways to integrate a stimulus or treatment via PHP-Code into the questionnaire and also for the different stimuli the code looks slightly different in each case. The following links will redirect you to the individual explanations of the different stimuli:

  1. Stimulus: Text
    Here you will learn how to randomize different texts using a PHP code after creating the random generator.
  2. Stimulus: image, video, audio
    Media files, such as images, videos, and audios are generally randomized via PHP code in a similar way as texts. In this chapter you will find the instructions for each media file.
    Note: Since media files can also be randomized without PHP code, please have a look at the explanation under ”Single Factorial Design“ first to check if this format is already sufficient for your objective. Also, this page tells you how to save media files.
  3. Stimulus: question
    In some cases it is necessary to randomize whole questions. How to implement this, you can read here.
  4. Stimulus: page
    The setPageOrder() function can be used to randomize entire pages.
  5. Joint Randomization of Different Stimuli
    A PHP code can also be used to randomize different stimuli together.
en/create/randomization-php.txt · Last modified: 20.04.2021 20:31 by sophia.schauer
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Driven by DokuWiki