OS Win10
PsychoPy version 2
I have built an experiment to test participants ability to recall a word from a word pair. The experiment shows participants one word from the word pair and the participants have to type the corresponding word. I have built the experiment so that participants see their answers on screen as they type and they are able to correct mistakes as they type and press enter when they are happy with their answer.
This means that resp.keys store every key press so an answer for the word light may look something like this: [‘l’, ‘i’, ‘f’ ‘backspace’ ‘g’, ‘h’, ‘t’, ‘return’]. In addition I have also designed the experiment to store the final text string using the following code:
thisExp.addData(‘inputText’, inputText)
inputText=“”
Therefore the data output file looks something like this:
What I would like to do is to give feedback to participants about whether their answers are correct or incorrect. I have set the correct answer to be corrAns (in red) but this is compared to resp.keys (in blue) which contain an infinite amount of different strings based on participants key presses and so resp.corr is always 0 even if participants write the correct word.
Therefore I thought the easiest solution would be to create feedback by comparing inputText (in blue) to corrAns (in red). I attempted this by creating an addition routine at the end of the loop so that feedback shows after each trial. I created a text box in this routine with the text: $msg. I then created the following code within this routine:
However when I try to run the experiment I am presented with the following error:
if inputText=$corrAns: msg=‘correct!’
‘’‘’‘’‘’‘’‘’ ^
SyntaxError: invalid syntax
I am hoping someone here can help. What I need to achieve is basically a feedback message after each trial telling them if they were correct or incorrect. I cannot set the correct answer to a string version of the word e.g. '[‘s’,‘e’,‘a’,‘t’, ‘return’] as we want to test older participants and so expect mistakes. Please let me know if you need any more information to help!