psychopy.org | Reference | Downloads | Github

Typed responses not being marked correct

OS: macOS Catalina
PsychoPy version: 2021.1.4

Hello,
My experiment has a component which requires participants to type in answers which the program will then mark as correct or incorrect. However, all of the responses inputted are marked as incorrect, even if they are correct. I followed along with this video step by step on a separate file to see if I could isolate the problem, but I had the same problem. I tried it on a different device as well, and it still didn’t work. Any help would be greatly appreciated!

Hello,

do you mind showing us your code?

Best wishes Jens

if ((textbox.text === corrAns)) {
    thisFeedback = "correct";
} else {
    thisFeedback = "incorrect";
}
trials.addData("correctAns", thisFeedback);

This is the code i used in the “begin routine” section of the feedback loop. I don’t have anything else.

Hello blue_rose

this code looks ok to me. So, if everything is marked as incorrect the if-construction might not get get corrAns or textbox.text correct and always evaluates to incorrect.

  1. You might want to check the names of your textbox-component and your correct-answer column in Excel.
  2. what does PsychoPy store as textbox-response? Check your result-file.

Best wishes

Hello,
I checked the names of the textbox and the correct response on the the Excel spreadsheet but they were correct. The results also show the correct response being recorded and stored, but somehow, the feedback column states “incorrect” on the data file. Here are some screenshots from the csv file.


Screen Shot 2021-06-24 at 12.51.12 AM

Hello blue_rose

could you have a space or another non-printable character stored in corrAns or in textbox.text?

Best wishes jens

I double checked if there is are any additional characters in corrAns but I couldn’t find any. I even tried changing it to a numerical value to see if it would work, but it is still marking as incorrect. I think it may be a problem with the text box component itself, if so I am unsure how to fix it.

Hello blue_rose

do you have a running toy-version of your experiment, just the response and feedback-components and the condition-file which you are willing to post here?

Best wishes Jens

I do. Please excuse the names, this was just an attempt to mess with the code to see if I could fix any problems myself.
playingaround.psyexp (12.6 KB)
messingaround.xlsx (8.5 KB)

Hello blue_rose

I added two lines to you code-component in the feedback-routine:

print(textbox.text)
print(len(textbox.text))

This shows the textbox.text is “empty” and has a length of 0 which is reason why your if-construction fails.

Best wishes Jens

Thank you for your response.The data sheet (csv) actually saves the textbox.text correctly but when you print in the feedback routine it is empty. Why do you think this is and how to fix it?

Hello,

I have no idea. I tried various ways to access the textbox.text. None was successful despite the fact that it is being saved in the results file. I continue trying but perhaps somebody else has an idea.

Best wishes Jens

Try saving textbox.text to a variable at the end of the routine with the textbox.

Hi,

I tried this with no success.

Best wishes Jens

Here is a working version. The key is in the order of the components.

playingaround.psyexp (14.3 KB)

  1. A code component that saves typed_response = textbox.text
  2. A keyboard component to monitor for the return key
  3. The textbox

textbox.text is already empty if you have the code component below the textbox.
textbox.text contains the return if you have the keyboard component below the textbox.

Hello,

cool, I didn’t think of the order of components.

Best wishes Jens