# Problem of feedback coding in IAT test

**URL:** <https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145>\
**Category:** Builder\
**Tags:** feedback\
**Created:** [February 23, 2020, 7:05pm UTC](https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145 "2020-02-23T19:05:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/noe/32/7057_2.png) [@Noe](https://discourse.psychopy.org/u/Noe)\
**Post date:** [February 23, 2020, 7:05pm UTC](https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145/1 "2020-02-23T19:05:47Z")

</div>

If this template helps then use it. If not then just delete and start from scratch.

**win10** (e.g. Win10):  
**PsychoPy 3**

**What are you trying to achieve?:**  
I am not very familiar with builder. Here i want to achieve:  
if the participant answers correctly, the experiment must continue to the next trial.  
if they answer incorrectly, feedback appears an “X” in the screen and participant can not get into next until they choose the correct answer.

**What did you try to make it work?:**  
Here I read [https://discourse.psychopy.org/t/feedback-depending-on-correctness-of-answer-inside-a-trial/5747](https://discourse.psychopy.org/t/feedback-depending-on-correctness-of-answer-inside-a-trial/5747)  
and here i attach my trial and code

 ![my trial1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/4/1/412739de37f0d5b2e91982b9779291d0a9abe184.png) ![coding1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/6/b656e0ee3bb1f3333acc90cd9249a8d576b6aa54.png)

**What specifically went wrong when you tried that?:**  
The problem is that I inset the code but it does not work. It works just like without the code. I really hope anyone can help me I am quite new with Builder and my research can not advance more 😔.  
Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [February 23, 2020, 10:02pm UTC](https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145/2 "2020-02-23T22:02:18Z")

</div>

This code is in the “Begin routine” tab, so it will run just once, before the subject has even had a chance to make a response.

There may be other issues with the code logic, but the key issue is to move the code to where it can actually have an effect (e.g. in the “Each frame” tab, so that it runs on every screen refresh during the trial).

---

<div class="post-metadata">

**Author:** ![Noe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/noe/32/7057_2.png) [@Noe](https://discourse.psychopy.org/u/Noe)\
**Post date:** [February 24, 2020, 3:12pm UTC](https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145/4 "2020-02-24T15:12:49Z")

</div>

Hi Micheal,  
Thank you so much for your response. Now I tried to find the coding error and did some changes:  
Begin Experiment:  
msg=""  
End Rountine:  
if resp1.keys:  
corr=resp1.corr  
rt=resp1.rt  
else:  
corr

thisExp.addData(‘rt’, rt)  
thisExp.addData(‘corr’, corr)

Find attached the screenshots:

 ![fotos1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/f/7f3271c8921e6ffe23348fb7c7b0230ed332d258.png) ![fotos2](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/3/d38475fc25982e63a22519240f1a8e5f9f4e6144.png)

I read this openIAT resource: [demos / OpenIAT · GitLab](https://gitlab.pavlovia.org/demos/openiat)  
Here I have some question:

a. Now the experiment can judge right or wrong answer, but what I need is that when the respondent chooses a wrong answer, he/she can not continue until he/she chooses the right answer.

b. If he/she chooses the right answer, the test goes directly to the next word.  
I tried to code it, but it did not work.  
I read this tip: [Feedback depending on correctness of answer inside a trial](https://discourse.psychopy.org/t/feedback-depending-on-correctness-of-answer-inside-a-trial/5747)  
Could you give please me advice?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Noe](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/noe/32/7057_2.png) [@Noe](https://discourse.psychopy.org/u/Noe)\
**Post date:** [February 24, 2020, 8:13pm UTC](https://discourse.psychopy.org/t/problem-of-feedback-coding-in-iat-test/11145/5 "2020-02-24T20:13:54Z")

</div>

Hi  
I have done some changes in my test.  
Begin Experiment:  
msg=""  
Each frame:  
if key\_resp\_part\_1.keys: # ie if the list isn’t empty:  
if key\_resp\_part\_1.keys[-1] != respond: # check the latest response  
msg=“X”  
elif key\_resp\_part\_1.keys[-1] == respond: # check the latest response  
msg=" "  
if len(key\_resp\_part\_1.rt)\>1:  
key\_resp\_part\_1.rt[-1]==key\_resp\_part\_1.rt[-1]+key\_resp\_part\_1.rt[-2]  
continueRoutine = False

 ![1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/e/7e2a1e49765098817217e061c33614ca9990da5d.png)  
But the problem is the code can not work. when the wrong answer is choosen, the respond “x” does not appear.  
I do not know where i should change.  
best
