psychopy.org | Reference | Downloads | Github

Something wrong with code component or textbox feature in 2020.2.10

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?: Mimicking simple tutorial videos

What did you try to make it work?:
What specifically went wrong when you tried that?:

Recently I have been having issues getting the new version of PsychoPy to read my if statements in a code component of a questionnaire I am building.

I decided to go all the way back to the drawing board when it comes to the new text box feature by watching both of the recent PsychoPy tutorial videos produced and published by Becca on 10/19/2020. I reproduced and checked each of my selections so they match what Becca had shown in both the tutorial videos and am finding that the same sort of issue occurring in my questionnaire experiment is also occurring even when trying to simply match the experiment from the tutorial videos. Each time trying to run it, I only get a response stating “Incorrect” instead of correct. When I check the data output file, the textbox.text column matches the corrAns column, but the program still displays “Incorrect”. It’s almost as if it isn’t reading the “if” part of the if statement, and jumping straight to the “else” part.

I have even uninstalled and reinstalled PsychoPy and cleared out anything other than the experiment file and conditions file that was in the project folder (old data, last run PY file, etc.).

I have uploaded the experiment and conditions file that this is happening to along with the most recent data output so that you can see the response matches “corrAns” but still returns as “Incorrect”. I have a feeling that if someone can provide an answer to why I am receiving an “Incorrect” responses even when typing the correct response, this will similarly help me on my other questionnaire experiment as well. A couple other things to note is that (i) the textbox appears glitchy and on some of the runs and the text may suddenly be bold in one run, and not in the next (ii) the version of Python I have downloaded is Python 3.8; not sure if this makes a difference…
_dummyrun3_2021_Jan_05_2123.csv (1.2 KB) conditions.xlsx (8.5 KB) dummyrun3.psyexp (12.4 KB)

Thanks for providing your files, but for a speedy response, could you also just show us the actual code snippets you are using, and which tab of the code component they are in?

Sure thing, thank you for the clarification on posting a code segment, I will be sure to utilize it moving forward.

The code snippet that I have entered is located within the “Begin Routine” tab of the code component. There are no additional snippets:

if textbox.text == corrAns:
    thisFeedback = 'Correct!'
else:
    thisFeedback = 'Incorrect'

trials.addData('correctAns', thisFeedback)

This seems exactly the same as your question in the other thread. This code shouldn’t be run at the beginning of the routine, as no response can have been made at that point (as using debugging print statements would show). Simply move the code to the “end routine” tab, at which time the response is actually available for you to test against.

Similarly as the other post, this does not solve the issue. I have already attempted code placement in the end routine tab. In this instance it is even easier to see that something else is going on because I have set up this example experiment following the exact steps that are shown in the PsychoPy tutorial (How to check if a typed response is 'correct' in PsychoPy - YouTube).

The only difference is that the video was published using PsychoPy 2020.2.4 and the current version I am running is v2020.2.10.

After having downloaded v 2020.2.4 on my laptop and replicating the experiment in both versions, comparing what happens in each, there is indeed still some things that are off with 2020.2.10. This small test experiment does in fact work as it is designed within the tutorial video when using 2020.2.4, but not when using 2020.2.10.

In v2020.2.10 a response of “Incorrect” continues to be placed on the screen regardless of the input, even if it is the proper “corrAns” response.