OS(e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2020.2.10
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: dummyrun2.psyexp (21.7 KB)
I am attempting to use the new beta textbox feature for a questionnaire, where the response to the second question determines what the third question to ask will be. My issue has two pieces:
(1) I am trying to figure out the best way to use the new textbox feature so that it is an empty box to start (currently you can not leave the “Text” field blank even when checking the textbox to “Editable”); (2) I would like to set up my code component to check the second question’s response and use the answer to determine what the third question will be. For the sake of ease (at least I think it is for ease), I am currently making each question a separate routine so that the code component for my third routine can read what occurred in the second routine.
What did you try to make it work?:
For part (1), I have simply entered “( )” in the “Text” field of the textbox component. This creates a nuisance in that the participant will need to delete this before entering their response. I am in the dark on a way around this.
For part (2), I have tried several variations of the following code component, which I thought would grab the answer to the second question (possibly as a string?) and match it to the conditions of the code component to display the proper question for the third question. Here is the general code outline I have been attempting:
the code component is currently placed in the top position of routine 3
Begin Experiment Tab:
#name of question variable for Question 3
Question_3text = " "
Begin Routine Tab:
#determining which question or statement to show after Question 2
if Response_2.text =="LSD":
Question_3text = "enter dose in number of micrograms"
elif Response_2.text =="psilocybin":
Question_3text = "enter dose in number of grams"
else:
Question_3text = "sorry that is not a valid substance"
the reason I am currently attempting to use “Response_2.text” is because this is the name given to the output for Response_2 when I check the data output file.
What specifically went wrong when you tried that?:
The third question continues to display “sorry that is not a valid substance” even if I enter “LSD” or “psilocybin” in the second question’s textbox. In one sense, I at least know that the if statements are being read because of the third question. However this still leaves me wondering what I actually need to label “Response_2.text” in the code so that it pulls the participant’s question 2 response and uses that to determine what to display for the third question.