OS (e.g. Win10): Win10 PsychoPy version (e.g. 1.84.x): 2021.1.0 Standard Standalone? (y/n) y What are you trying to achieve?: Assign correct keyboard response to variable in code component, have it recognised as “Correct answer” by subsequent keyboard component
What did you try to make it work?: Tried a simple new "experiment’’ with just 5 loops of trial, a code assigning one key as answer, and keyboard component after it, in order, with default allowable keyboard responses, one of which assigned as correct. Tried using ‘dollar sign’ and not using it ahead of variable name in “Correct answer” textbox of keyboard component dialog (apparently not needed anymore but tried it anyway). Tried “y” and “space” as correct assigned answer. But no response is recognised as correct. Data file shows “trial_resp.corr” = 0 all the time. Tried opening an old experiment opened in this version of PsychoPy; it still works, with same correct answer logic (but the dialog box opens up differently, it doesn’t show the “$” sign ahead of the Correct answer box, but same version of PsychoPy). So just creating a new experiment seems to fail in this basic way.
Could you upload the psyexp file? It could be a bug - possibly because Correct Answer for Keyboard is now validated as a list - but I’d need to have a look at the Python code from your experiment to make sure
ok, can’t load my whole experiment but here is the dummy bit just to check that the usual, simple assignment of correct response value to a variable for keyboard component to check if response correct works; it wouldn’t using this new version of PsychoPy, although it can handle it in the same way from old experiment. it seems to recognise the difference, even throws up a slightly different dialog for keyboard component if experiment written in older version. So this is just stripped back focus on the issue; you get a feedback bit too. You can see I’ve tried your list representation of the value, or you can go back to the single scalar value as before, which, again, still works from old experiment in this new version. it’s writing in new version that this doesn’t work anymore, one way or the other. maybe i’m doing something differently but just with these few settings … as always before … dummy_2.psyexp (11.1 KB)
tried also using [ANSWER] rather than just ANSWER or $ANSWER in the keyboard component’s “Correct answer” box, paired with the same or alternative form in the prior code giving a value to answer. Also tried running this new script, written and run within 2021.1.0 Builder, but switching version in settings to 2020.2.3, and it still doesn’t recognise the value; key_resp.corr still always returns as 0.
nice try. No. Same thing. Always .corr = 0, always given 0 as its value whether key matches the key given to correct response variable or not. I was originally using “RESPONSE_EXP” as name of variable in experiment when problem arose in rewriting the experiment from scratch, in this new version. Had worked in old version, written/saved in 2020.2.3, but that has stopped accepting any edits, updating “lastrun.py”, as raised in association with others elsewhere. That’s only reason why rewriting from scratch, otherwise worked before, Just this not working in new version now
Have tried uninstalling new version (2021), in which this was written, and reverting to 2020.3.10, but the psyexp file won’t run in that, nor will another experiment written in the new version; error is “opacity cannot = NoneType”; changed opacity to 1 in the text components, same error. Also the .py file isn’t generated from “Compile” in the new version; dialog pops up “… .py file not found”; and trying to do this in earlier version encounters multiple issues via “compile.py” or similar. Won’t raise as separate issues as can’t investigate exhaustively at this stage. Just noting that here in case you want to run the .psyexp file attached above and check it out.
Ah I’ve found the problem - it’s the new param types in 2021.1. Essentially, it sees whatever you give a Keyboard for it’s correct answer as a list, not a string. This is only a problem for experiments made in 2021.1.0 - experiments made earlier will have the old param types and so will be interpreted fine. I’ll fix this in 2021.1.1, but for your specific experiment I’m afraid you’ll have to do a bit of manual substitution - you could either remake the Keyboard components again in the next version, or open the .psyexp in notepad (or equivalent program) and replace anything like this: