This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
en:create:functions:random [10.04.2016 10:20] – [random()] admin | en:create:functions:random [29.05.2018 10:33] – fixed typo cseifert | ||
---|---|---|---|
Line 8: | Line 8: | ||
* //max//\\ The largest number allowed | * //max//\\ The largest number allowed | ||
- | **Note: | + | **Note: |
- | + | ||
- | **Note: | + | |
Line 18: | Line 16: | ||
//min// ≤ return value ≤ //max// | //min// ≤ return value ≤ //max// | ||
- | |||
- | |||
- | ==== Drawing with Replacement ==== | ||
- | |||
- | The PHP functions '' | ||
- | |||
- | **Note:** When drawing with replacement, | ||
- | |||
- | - Add a new question in the **List of Questions** using the type " | ||
- | - Add a variable (item) in this question with the description, | ||
- | - [[php|PHP code]] is used to carry out the actual random draw. | ||
- | |||
- | <code php> | ||
- | $number = random(1, | ||
- | put(' | ||
- | </ | ||
- | |||
- | |||
- | ===== Example ===== | ||
- | |||
- | In the following example, a number between 1 and 3 is drawn and the participant is shown one of the text elements " | ||
- | |||
- | <code php> | ||
- | // Draw a random number | ||
- | $stim = random(1, 3); | ||
- | // Save the result of the draw in the data record | ||
- | put(' | ||
- | // Display stimulus | ||
- | if ($version == 1) { | ||
- | text(' | ||
- | } elseif ($version == 2) { | ||
- | text(' | ||
- | } else { | ||
- | text(' | ||
- | } | ||
- | </ |