OS (e.g. Win10): Mac Big Sur PsychoPy version (e.g. 1.84.x): 20.2.10
What are you trying to achieve?:
I am trying to code correct answer (1/0) using the textbox answer of a certain task.
What did you try to make it work?:
I compare the answer given in the textbox to the actual stimulusalso see:
I use the following code:
if text == textbox_4.text:
score = score + 1
else:
score = score + 0
What specifically went wrong when you tried that?:
However, the score remains 1 even if the texts match. Does anyone have an idea what can go wrong here? The textbox_4 is defined under ‘ubentest’ and the text under ‘feedback’ in the same loop.
Thanks! Yes that’s what I have, except that I only want to ‘document’ the score and do not give feedback directly during the task. However, when the score should be scored 1 (the textbox is the same as another variable called thisIm2 the score does not add up!
Hi Becca, thank you for answering!
No, so if I leave the textbox totally empty, I get the following message: AttributeError: ‘NoneType’ object has no attribute ‘replace’
But if I then put ‘antwort:’ in the textbox (or empty spaces) it works. However, the score still does not add up (so I create a new variable that combines antwort: with the answer; see below
ubentest = where the participant has to type the word in the textbox and this word is stored
routine 2 = the correct word is combined with antwort so I can compare it to the answer
feedback_2: the answer is compared to the antwort and correct word (also see the picture from excel above and the code in the second picture)
OK so for now I think this should do the trick - if you add a space to the text field of your textbox’s (this will avoid the attribute error you describe).
Many thanks for your time. Unfortunately, I think this is not the main problem (I tried it of course), I earlier worked around this by putting ‘answer:’ in the textbox and then comparing the ‘answer:’ + what was typed in textbox_4 to thisIm2. However, the problem seems that even when the answers are correct (and also exactly the same shown in the output), the score still doesn’t add up. So this is how it looks with the space involved, same answer (when it ignores the space indeed), but score remains 0…
I really don’t understand, so it seems that the string variables in some way cannot really be compared?
Aha OK I’ve looked into this more and think I have it. Currently there is a bug whereby text.text is replaced with “default text” at the end of the routine (the developers @TParsons are aware of this and it is fixed for the next release). For your case though this is causing problems, because the correct answer is not “default text” of course…
For now, you need to check if the correct answer has been typed in the textbox on each frame. I have added the code component “checkCorrect” to your file to demonstrate this - the value “score” saved to the output file now increases. PAT.psyexp (158.2 KB)
Yes this solves the problem, thank you! It now gives the correct score.
The only problem that I have remaining now is that when I shuffle the stimuli en then let them come back in the second routine, the answers belonging to the stimuli are not shuffled with them, so I can’t check the correct score
But maybe I just have to check this by hand and not automatize the scoring (also in case participants make a typing error)
I am currently encountering a similar problem! I have an experiment that worked in an early version locally (it works online), but now I get “default text” or nothing. In my case I have a free recall task where folks type in multiple responses. These responses are checked against a created dictionary. I have tried to move this out of the end routine portion but I still get the same issue. Do you know when this will be fixed, or maybe you have a work around?