psychopy.org | Reference | Downloads | Github

Repeat stimulus until participant gets it correct

Hello again!

First of all: Thanks to all of you for helping me with my other issues. This forum has been such a great help for me!!
I am working on a new Experiment now. This time it is a Mental Rotation experiment.

It is already working quite well but I have one big problem that I couldn’t solve yet. In the trainings trial I want to repeat a stimulus as long as the participant gets it wrong and only want to show the next stimulus when the participant gets it correct but I don’t know how to do it.

I have created a routine feedback ant inserted a code component. This is how it looks like right now:

Here is also the rest of my experiment if that helps:

What code do I need in my feedback code component? Or doing something completely wrong and do I insert the Code component somewhere else?

I would appreciate any help!! Thanks a lot in advance!
Best wishes,
Sarah

The reason for the syntax error is because the second part of your if statement isn’t indented. However, continueRoutine = True is superfluous so I’d recommend that you delete it entirely.

Thank you @wakecarter! I realized that shorty afterwards as well and fixed the syntax error. Now my code component looks like this but it is still not working…

Bildschirmfoto 2020-06-06 um 14.48.30

After an incorrect answer it just displays the next stimulus and doesn’t repeat the stimulus I got not correct…

Is there something like stimulus.repeat maybe ??

How are you trying to repeat?

I would do this by loading the trials into an array prior to the trials loop so I can choose whether to advance or repeat each time

Have a look at https://pavlovia.org/Wake/brookes-template-2020 now.

For some reason (possibly due to conflict with the slider component I’ve added) it doesn’t work offline, but online it uses a single text component to display the fixation, item and feedback – and then repeats if the answer is incorrect.

Thank you so much @wakecarter for taking the time helping me and for sending me your experiment!!
That is exactly what I need! Unfortunately I can’t read the code properly because of the format.
Did you do it with the Builder interface?
Could you maybe send me a screenshot of what you did in the Code component for achieving that a stimulus gets repeat if it is incorrect??

Thanks a lot!

I did (I only) use the Builder interface so you can download the psyexp file. I’ll screenshot later

I can only download it as a .txt or .html file and don’t get it converted to a psyexp file afterwards :confused:

Don’t you get access to the files on Gitlab when you click on view code?

How about this link?

1 Like

When I click on this link I see this:

But once I download it it becomes a .txt file, so I cannot open it in PsychoPy…

Thanks for your efforts!

When I click on the icon with the cloud and the down arrow the file downloads with a psyexp extension. If it’s downloading with a txt extension for you, you should be able to rename it to open it in PsychoPy

1 Like

Here it is as an attachment
template.psyexp (52.2 KB)
items.xlsx (8.1 KB)

1 Like

The easiest thing to do in this situation is just to insert a second loop around your trial routine (i.e. nested within the outer trial loop). This inner loop should not be connected to a conditions file, and just be given a large nReps values, like 100.

In the “End routine” tab,

put code like this:

if key_resp.corr:
    your_inner_loop_name.finished = True

i.e. the trial routine will just keep repeating until the response is correct. At that point, the inner loop will end, and the next iteration of the outer loop (i.e. the next trial) will occur.

I agree that is simpler. I was assuming online compatibility would be needed, which may not be the case.

Thank you so much @wakecarter and @Michael! I finally got it and works perfectly!!
Thanks a lot!!!