My experiment has certain demographic questions which determine whether the participants qualify for the study or not.
One of my questions has two answers- yes or no. If the participant answers yes, then the experiment continues. If they answer no, then the experiment needs to end with a thank you message.
Secondly, if they mention that their age is below 18, the experiment must also end.
Will coding be required? If so, how will I go about doing this?
One easy solution is to put a loop around the whole experiment (minus the thank you message at the end), and to put a variable in the number of repetion field " nReps" (e.g. $skipExp)
You can then use a code component changing the variable depending on what the participant wrote in the demographic questions (letâs say that the info box with the yes/no answer is called âquestion 1â)
The code is in Javascript because I assume this is needed for an online experiment, but the logic is still valid for an experiment running offline (you just need to change the syntax to Python)
The same logic can be applied for age (if age < 18 â skipExp = 0)
Yes my experiment will be run online. The image below demonstrates what my experiment currently looks like. I have four multiple-choice questions and one question (asking for age). As you can see, I already have multiple loops.
Hence, I am confused as to where the new loop will go. I tried putting it around âdemoMultipleâ and the do_multi_loop but it is saying there is an error in the syntax. I have replaced âquestion 1â which the name of my own question.
Would you happen to know why this might be happening?
What I do is have an exclusion routine which halts the experiment to exclude participants.
e.g.
if expInfo['age'] == 1:
text_exclusion.text = 'Thank you for your interest in this study.\n\nHowever, I am only studying adults.\n\nPlease press the escape key or close your browser tab to quit.'
elif expInfo['english'] != '4': # The default text_exclusion.text is about excluding native English speakers.
continueRoutine = False
Thank you for your solution. I based my code on the code you mentioned and it worked.
Below is what I did: #by default, skip the exclusion message and do the experiment
doExp = 1
doExclusion = 0
#if an exclusion criteria is met though, show the exclusion message and donât do the experiment
if(demo_resp[âblindâ] == â1â):
doExp = 0
doExclusion = 1
exclusion_msg = âThank you for your interest in this study.\n\n However, the study currently focuses onâŚ\n\nPlease press the escape key to exit the experimentâ
elif(int(demo_resp[âageâ]) < 18):
doExp = 0
doExclusion = 1
exclusion_msg = âThank you for your interest in this study.\n\nHowever, the study currently focuses on those who are 18 and above.\n\nPlease press the escape key to exit the experimentâ