======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 [[en:create:randomization-einfaktoriell|]] should suffice. **Note:** If you want to display only part of the random stimuli, please refer to the [[en:create:randomization-within|]] 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 [[en:create:questions:random|Random Generator]] has to be created (see [[en:create:basics#part_1creating_questions|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 [[en:create:php-filters|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: {{:de:create:scr.zufallsgenerator_php.png?400|Der Zufallsgernerator wird über dem PHP-Code platziert}} **Note:** After placing the random generator __and__ the PHP code, the stimuli __must not__ be additionally explicitly embedded on the questionnaire page! **Tip:** If you want to present a stimulus multiple times on different pages, you can simply embed the PHP code multiple times on different pages. You only have to include the random generator once in the questionnaire. There are different ways to integrate a stimulus or treatment via [[en:create:php|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: - [[en:create:randomization-text|Stimulus: Text]]\\ Here you will learn how to randomize different texts using a PHP code after creating the random generator. - [[en:create:randomization-media|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 "[[en:create:randomization-einfaktoriell|]]" first to check if this format is already sufficient for your objective. Also, this page tells you how to save media files. - [[en:create:randomization-question|Stimulus: question]]\\ In some cases it is necessary to randomize whole questions. How to implement this, you can read here. - [[en:create:randomization-page|Stimulus: page]]\\ The setPageOrder() function can be used to randomize entire pages. - [[:en:create:randomization-mixedstimuli| Joint Randomization of Different Stimuli]]\\ A PHP code can also be used to randomize different stimuli together.