OS (e.g. Win10): PsychoPy version (e.g. 2025.1.0 Py 3.10): Standard Standalone Installation? (y/n) Y Do you want it to also run online? (y/n) Y What are you trying to achieve?:
I am updating my change blindness experiment so that it uses the textbox component to save written answers instead of using code. Textbox answers are saved. However, sometimes participants either do not recognise the change or do not provide an answer. Currently, nothing is saved in these cases. I would like to save the strings âkein Erkennenâ when no change is detected and âkeine Antwortâ when no answer is given.
I added the following code to the âBeginâ tab of the routine where participants provide their answers.
if skip: #no change was detected
thisExp.addData("kein Erkennen", textboxBericht.text)
continueRoutine = False
I have the following code in the end tab of the same routine for cases when no answer was given.
if len(textboxBericht.text) == 0:
thisExp.addData("Keine Antwort", textboxBericht.text)
Unfortunately, the column textboxBericht.text in my data is empty in both cases.
Thanks a lot for the input. I tried this but the line
if textboxBericht.text:
thisExp.addData('Antwort', textboxBericht.text)
does not work. The data columnAntwort had always the value keine Antwort when an answer is provided. This is probably due the fact that I call this code-component in the same routine as the component textboxBericht. In this case the if-else construction evaluates to
else:
thisExp.addData('Antwort', 'Keine Antwort')
The data column textboxBericht.textcontains the provided answer.
The elifcondition works as intended.
It seem to be impossible to set the value of textboxBericht.text
Currently, everything is in a Begin routinetab. I think about splitting the if-else construction in two parts, one in a Begin routinetab
if skip:
thisExp.addData('Antwort', 'Kein Erkennen')
continueRoutine = False
the other in an End routinetab
if textboxBericht.text:
thisExp.addData('Antwort', textboxBericht.text)
else:
thisExp.addData('Antwort', 'Keine Antwort')
You should be able to do textboxBericht.text = âNo answerâ but for it to be saved Iâm wondering whether it needs to be set in the final frame instead of End Routine.