This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
en:create:randomization [06.06.2017 12:52] – [Drawing of a Random Number] admin | en:create:randomization [06.06.2017 13:14] – update admin | ||
---|---|---|---|
Line 16: | Line 16: | ||
* An option to the random generator is [[: | * An option to the random generator is [[: | ||
* Very rarely, the different variants of the questionnaire are so diverse that using filters is impractical. If this is the case, the participant can be allocated at random to different questionnaires ([[random_questionnaire|Random Selection for Questionnaires]]). Drawing with replacement is always used when a questionnaire is selected at random. Therefore, the resulting group sizes may vary considerably. | * Very rarely, the different variants of the questionnaire are so diverse that using filters is impractical. If this is the case, the participant can be allocated at random to different questionnaires ([[random_questionnaire|Random Selection for Questionnaires]]). Drawing with replacement is always used when a questionnaire is selected at random. Therefore, the resulting group sizes may vary considerably. | ||
+ | |||
+ | **Tip:** Use '' | ||
Line 42: | Line 44: | ||
This example shows graphic " | This example shows graphic " | ||
- | Instead of using '' | + | Instead of using '' |
+ | |||
+ | The following PHP code presents the same image like the avove PHP code. Yet, this code does not use the full HTML code for each image, but a placeholder '' | ||
+ | <code php> | ||
+ | $code = value(' | ||
+ | |||
+ | // Grafikdatei in Abhängigkeit von der Zufallszahl in einen Platzhalter schreiben | ||
+ | if ($code == 1) { | ||
+ | replace(' | ||
+ | } elseif ($code == 2) { | ||
+ | replace(' | ||
+ | } elseif ($code == 3) { | ||
+ | replace(' | ||
+ | } elseif ($code == 4) { | ||
+ | replace(' | ||
+ | } | ||
+ | // The HTML code may be embedded via html() | ||
+ | // or (not shown here) as text element | ||
+ | html('< | ||
+ | </ | ||
+ | |||
+ | **Tip:** Placeholders are especially helpful if the stimulus requires more HTML code then shown in the example above (e.g., to embed videos). | ||
+ | |||
+ | **Tip:** The name of the PHP variable (the examples use '' | ||
+ | |||
+ | If your stimuli require extensive HTML code (e.g., videos), when there are substantial differences in the experiment groups' | ||
+ | |||
+ | <code php> | ||
+ | $code = value(' | ||
+ | |||
+ | // Embed text or HTML code | ||
+ | if ($code == 1) { | ||
+ | text(' | ||
+ | } elseif ($code == 2) { | ||
+ | text(' | ||
+ | } elseif ($code == 3) { | ||
+ | text(' | ||
+ | } elseif ($code == 4) { | ||
+ | text(' | ||
+ | } | ||
+ | </ | ||
Line 50: | Line 92: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
// enter complete HTML code every time | // enter complete HTML code every time | ||
if ($number == 1) { | if ($number == 1) { | ||
Line 58: | Line 102: | ||
</ | </ | ||
- | < | + | < |
+ | $number = value(' | ||
// only determine the image' | // only determine the image' | ||
if ($number == 1) { | if ($number == 1) { | ||
Line 74: | Line 120: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
text(' | text(' | ||
Line 106: | Line 154: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
text(' | text(' | ||
Line 127: | Line 177: | ||
<code php> | <code php> | ||
+ | $number = value(' | ||
+ | |||
+ | // Display one question or another | ||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 137: | Line 190: | ||
<code php> | <code php> | ||
- | // show the one or the other question | ||
$number = value(' | $number = value(' | ||
+ | |||
+ | // Display one question or another | ||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 148: | Line 202: | ||
<code php> | <code php> | ||
$number = value(' | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
question(' | question(' | ||
Line 163: | Line 218: | ||
<code php> | <code php> | ||
$number = value(' | $number = value(' | ||
+ | |||
if ($number == 1) { | if ($number == 1) { | ||
setPageOrder(' | setPageOrder(' | ||
Line 173: | Line 229: | ||
You can find further explanations and examples in the section '' | You can find further explanations and examples in the section '' | ||
+ | |||
+ | |||
+ | ==== Stimuli and Questions on different pages ==== | ||
+ | |||
+ | If there is a distinct question for each stimulus variant, and both shall be presented on different pages, use a filter on both pages. As soon as a random number has been drawn once (e.g., as variable '' | ||
+ | |||
+ | <code php> | ||
+ | // PHP code in the page with the stimulus | ||
+ | $number = value(' | ||
+ | |||
+ | if ($number == 1) { | ||
+ | text(' | ||
+ | } elseif ($number == 2) { | ||
+ | text(' | ||
+ | } elseif ($number == 3) { | ||
+ | text(' | ||
+ | } elseif ($number == 4) { | ||
+ | text(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | // PHP code on a later page that displays the question | ||
+ | $number = value(' | ||
+ | |||
+ | if ($number == 1) { | ||
+ | question(' | ||
+ | } elseif ($number == 2) { | ||
+ | question(' | ||
+ | } elseif ($number == 3) { | ||
+ | question(' | ||
+ | } elseif ($number == 4) { | ||
+ | question(' | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | **Note: | ||
+ | |||
+ | **Tip:** This variable also allows the distribution of a stimulus (e.g., pages 1 to 3 of a newspaper article) on different pages. | ||
Line 332: | Line 427: | ||
===== Draw Multiples out of Urns ===== | ===== Draw Multiples out of Urns ===== | ||
+ | |||
+ | **Important: | ||
If you want to draw from different urns you also need several questions with the type " | If you want to draw from different urns you also need several questions with the type " |