Subject: Random generator + PHP text() shows no stimulus, jumps to final page
Hello,
I am building a three-arm between-subject experiment for my master's thesis at the University of Kassel and cannot get the randomised text display to work. I have followed the manual pages "Randomization with PHP-Code" and "Randomization: Texts" but the stimulus never appears.
Test project name: randomisation
(This is a minimal test project I built to isolate the problem.)
WHAT I HAVE SET UP
Section TR contains:
- TR01 "control" — created with Add Text, content: THIS IS CONTROL
- TR02 "Treatment1" — created with Add Text, content: THIS IS TREATMENT 1
- TR03 "Treatment 2" — created with Add Text, content: THIS IS TREATMENT 2
- TR04 "arm" — question type Random Generator
TR04 Codes (contents) currently reads:
1 = 1
2 = 2
3 = 3
The "Drawn yet" column shows draws are happening (e.g. 3: 1), so the generator itself appears to work.
Questionnaire page 01 contains, in this order:
1. TR04 (the random generator)
2. A PHP code element placed below it, in the page content area (not in the "PHP for Processing Responses" box)
The PHP code is:
if (value('TR04') == 1) {
text('TR01');
} elseif (value('TR04') == 2) {
text('TR02');
} else {
text('TR03');
}
TR01, TR02 and TR03 are NOT placed on any questionnaire page, as the manual instructs.
WHAT HAPPENS
When I start the questionnaire (starting a new interview, not refreshing with F5), no text is displayed. The questionnaire goes straight to the final page: "Thank you for completing this questionnaire!"
No error message is shown.
WHAT I HAVE ALREADY TRIED
- question('TR01') instead of text('TR01') — same result, no display
- An urn instead of a random generator. urnDraw('treat') returned: "There are not enough parameters for the function urnDraw(). Please specify 2 parameter(s)." Adding a second parameter for a storage variable did not resolve it, as I could not create a suitable internal variable.
- echo for debugging — blocked: "The PHP keyword echo is not allowed within PHP code."
- Confirmed the PHP element is in the page content area, not the processing-responses area
- Confirmed I start a new interview rather than refreshing
MY QUESTIONS
- Is text() the correct function for elements created with Add Text, and is my syntax correct?
- Should the Codes (contents) of the random generator contain plain numbers (1, 2, 3), or does it need something else for use with value()?
- Is there a setting on the Random Generator question (for example under Display Contents, Management, or Variables) that must be configured before value() will return the drawn code?
- Is there a way to display the drawn value on screen for debugging, given that echo is not permitted?
I would be very grateful for any help. I need this working before I can begin data collection.
Thank you very much