# Typed responses not being marked correct

**URL:** <https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684>\
**Category:** Builder\
**Created:** [June 22, 2021, 7:24am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684 "2021-06-22T07:24:57Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 22, 2021, 7:24am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/1 "2021-06-22T07:24:58Z")

</div>

**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!

[![](https://img.youtube.com/vi/-Fto45M7bS0/maxresdefault.jpg "How to check if a typed response is 'correct' in PsychoPy") ](https://www.youtube.com/watch?v=-Fto45M7bS0)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 22, 2021, 12:55pm UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/2 "2021-06-22T12:55:57Z")

</div>

Hello,

do you mind showing us your code?

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 22, 2021, 6:03pm UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/3 "2021-06-22T18:03:36Z")

</div>

```auto
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.

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 23, 2021, 7:46am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/4 "2021-06-23T07:46:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 24, 2021, 4:53am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/5 "2021-06-24T04:53:38Z")

</div>

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.50.58 AM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/8/5892d1aaee9357596b93843e8eefe3d3a0a703ab.png)  
 ![Screen Shot 2021-06-24 at 12.51.12 AM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/5/d56705737cc2d034449f79f43fd6791a628ada54.png)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 24, 2021, 7:11am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/6 "2021-06-24T07:11:09Z")

</div>

Hello blue\_rose

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

Best wishes jens

---

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 25, 2021, 3:32am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/7 "2021-06-25T03:32:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 25, 2021, 7:49am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/8 "2021-06-25T07:49:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 25, 2021, 11:25pm UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/9 "2021-06-25T23:25:13Z")

</div>

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](https://discourse.psychopy.org/uploads/short-url/mb1WqZsE15qb1w6ykosdEjLaWVz.psyexp) (12.6 KB)  
[messingaround.xlsx](https://discourse.psychopy.org/uploads/short-url/yxDb31PVCCBP6h1YKydzq1xczW4.xlsx) (8.5 KB)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 28, 2021, 10:02am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/10 "2021-06-28T10:02:28Z")

</div>

Hello blue\_rose

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

```auto
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

---

<div class="post-metadata">

**Author:** ![blue\_rose](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/blue_rose/32/16808_2.png) [@blue\_rose](https://discourse.psychopy.org/u/blue_rose)\
**Post date:** [June 29, 2021, 4:26pm UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/11 "2021-06-29T16:26:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [June 30, 2021, 8:27am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/12 "2021-06-30T08:27:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [June 30, 2021, 2:21pm UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/13 "2021-06-30T14:21:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 1, 2021, 6:58am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/14 "2021-07-01T06:58:02Z")

</div>

Hi,

I tried this with no success.

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [July 1, 2021, 8:00am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/15 "2021-07-01T08:00:54Z")

</div>

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

[playingaround.psyexp](https://discourse.psychopy.org/uploads/short-url/e9CD6a4OB3fSUy6cH4ztw2NCedf.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.

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [July 1, 2021, 8:48am UTC](https://discourse.psychopy.org/t/typed-responses-not-being-marked-correct/23684/16 "2021-07-01T08:48:16Z")

</div>

Hello,

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

Best wishes Jens
