# Response Accuracy Required Before Progression

**URL:** <https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346>\
**Category:** Builder\
**Created:** [January 16, 2019, 1:22pm UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346 "2019-01-16T13:22:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CEKinch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/cekinch/32/5850_2.png) [@CEKinch](https://discourse.psychopy.org/u/CEKinch)\
**Post date:** [January 16, 2019, 1:22pm UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/1 "2019-01-16T13:22:15Z")

</div>

Hey,

New to PsychoPy so hoping I can get a hand with this.

I’m setting up an experiment where participants need to reach a certain level of performance (let’s say, 4/5 correct responses) before they are allowed to proceed to the next routine. If this threshold is not met then it needs to loop them back to the start of that routine.

Any suggestions appreciated!

Cheers  
CK

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 18, 2019, 7:17am UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/2 "2019-01-18T07:17:30Z")

</div>

First, define your correct answer attribute in your response component and set a high number for nReps in your loop.

Then, insert a code component. In the first tab (Begin Experiment), insert:

```auto
nCorrect = 0

```

In the fourth tab (end routine), insert the following and substitute myTrialLoop with the name you gave your loop and key\_resp with the name you gave your response component.

```auto
if key_resp.corr: # if the response was correct, increment your iterator
    nCorrect += 1

if (myTrialLoop.thisN+1)%5 and nCorrect >= 4/5: # if the subject just finished a set of 5 trials and got 4/5 or more correct, finish the loop
    myTrialLoop.finished = True
else:
    nCorrect = 0

```

To make more sense of the lines of code and to adapt them to your needs, compile your script and try to understand where the code is inserted and what variables it uses.

Does that help?

---

<div class="post-metadata">

**Author:** ![CEKinch](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/cekinch/32/5850_2.png) [@CEKinch](https://discourse.psychopy.org/u/CEKinch)\
**Post date:** [January 18, 2019, 8:49am UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/3 "2019-01-18T08:49:34Z")

</div>

Hi Lukas,

Yes! This helps immensely! Exactly what I was looking for!

Thank you!

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [January 18, 2019, 10:35am UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/4 "2019-01-18T10:35:47Z")

</div>

Great 😃  
You could then tick the ‘solved’ option underneath my post. 👍

---

<div class="post-metadata">

**Author:** ![lthieffr](https://avatars.discourse-cdn.com/v4/letter/l/a9a28c/32.png) [@lthieffr](https://discourse.psychopy.org/u/lthieffr)\
**Post date:** [October 1, 2020, 11:26am UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/5 "2020-10-01T11:26:57Z")

</div>

Hi Lukas!

Sorry to bring up and old post but I’m struggling with psychopy. I hope you will be able to help me!

In my experiment, participants have to reach a minimum of 75% correct responses in a recall task. To be more specific, participants are first presented with several word pairs in a memory task. In the recall task they are presented with the first word of the word pairs and then need to type in the second word pair. Since I’m using the textBox component that allows participants to type in their responses, where could I define my correct response attribute?

Sorry if it’s a stupid question, thank you in advance,

Lola

---

<div class="post-metadata">

**Author:** ![Sara\_Eskandari](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/sara_eskandari/32/15765_2.png) [@Sara\_Eskandari](https://discourse.psychopy.org/u/Sara_Eskandari)\
**Post date:** [April 21, 2021, 5:02pm UTC](https://discourse.psychopy.org/t/response-accuracy-required-before-progression/6346/6 "2021-04-21T17:02:20Z")

</div>

Hi,

How can we store keys and responses when we press several keys as a response to a stimulus for example in digit span task in builder and coding in Psychopy?
