====== Random Selection for Questionnaires ======
In a survey project you can create several questionnaires (**Assemble Questionnaire**) -> **Create new Questionnaire** or **Manage Questionnaires**). If the participant opens the [[:en:survey:url|link to to questionnaire]], they can be randomly assigned to one of the questionnaires.
**Warning:** If you implement randomization across different questionnaires, systematic dropouts can lead to an (sometimes significantly) uneven distribution in the completed questionnaires. Use only a questionnaire with [[:en:create:randomization]] of the stimulus to reliably fill the experimental groups evenly (see also the following note).
**Warning:** If the experimental groups work in different questionnaires, it is necessary to pay special attention to ensure that the questionnaires are identical except for the treatment. For example, if a change is made in only one of the questionnaires after the pretest, this can lead to confounding and the inability to use the data. The "normal" [[:en:create:randomization]] is less error-prone here.
**Note:** For experiments it is usually much easier (!) to create only one questionnaire and vary the stimulus with a small PHP code ([[:en:create:randomization]]).
===== How-to =====
First you create an additional questionnaire under **Assemble Questionnaire** -> **Create new Questionnaire**, that takes care of the random assignment. The questionnaire identifier can be chosen freely, for the following description we use the ID "random".
Define this questionnaire as the default questionnaire under **Assemble Questionnaire** -> **Manage Questionnaires**.
{{:de:create:scr.random-questionnaire.questionnaires.png|Questionnaires for random selection}}
To ensure an equal distribution of the participants on the questionnaires, you need a question of the type [[:en:create:questions:random]]. You can create this question in any category -- for the further description it is assumed that this question has the ID "RF01".
{{:de:create:scr.random-questionnaire.random-create.png|Create random generator}}
Enter the IDs of the questionnaires (see above) you want to choose between as //codes// in the random generator and save the question ({{:button.save.png|Save question}}).
Leave the default setting "equally distributes" selected for the //type of drawing//. The option "Equally distributed in finished questionnaires" will //not// work because the random distribution questionnaire will never be finished.
{{:de:create:scr.random-questionnaire.random-contents.png|Random generator for the selection of the questionnaire}}
Open the questionnaire that you have created for random distribution under **Assemble Questionnaire** for editing.
- Drag the random generator (RF01) to the first (and only) page of the questionnaire, and
- place the following [[:en:create:php|PHP code]] below it.
$qnr = value('RF01', 'label');
goToQuestionnaire($qnr);
The function ''[[:en:create:functions:value]]'' retrieves the ID of the randomly drawn questionnaire from the random generator. The function [[:de:create:functions:goToQuestionnaire]] jumps directly to the questionnaire with the corresponding ID.
{{:de:create:scr.random-questionnaire.questionnaire.png|Questionnaire to randomly select a questionnaire}}
You have chosen the questionnaire "random" under **Assemble Questionnaire** -> **Administer Questionnaires** as the default questionnaire for the survey project. The participants can call [[:en:survey:url]] without further parameters (''q=...''). They will then first be taken to the "random" questionnaire and from there randomly distributed to one of the other two questionnaires.
===== Weighted Selection =====
If some questionnaires should be selected more often than others (higher weighting in the random selection), please simply enter their identifiers several times in the random generator.
The following random generator for example would select te questionaire "control" twice as often as "order1", "order2" or "order3".
1 control
2 control
3 order1
4 order2
5 order3
===== Interaction with extern Panels =====
If you recrute the respondants from an extern panel you have to transmit respondetcodes in most cases in the redirect: [[:en:survey:panels]]
As soon as ''[[:en:create:functions:gotoquestionnaire]]'' is used, a new case is created in the dataset. In this (new) interview, it is no longer possible to access the data that were collected in the original questionnaire (here, for example, "random"). This also applies to a participation code that may have been passed via URL from the panel provider.
For the process to work, you have to explicitly pass the participation code to the subordinate interview. Therefore the function ''[[:en:create:functions:multileveldown]]'' is used. If the participation code was passed by reference (REF), it would look like this.
$qnr = value('RF01', 'label');
multiLevelDown($qnr, reference());
In the subordinate questionnaire you can then access the passed code using ''[[:en:create:functions:multileveldata]]''. In the redirect, the reference would then no longer be used directly ...
redirect('https://www.panelanbieter.de/complete?xyz=ABCDEF&uid=%reference%');
// or equivalent
redirect('https://www.panelanbieter.de/complete?xyz=ABCDEF&uid='.reference());
... but the data passed by ''multiLevelDown()'', i.e.
redirect('https://www.panelanbieter.de/complete?xyz=ABCDEF&uid='.multiLevelData());