[solved] How to repeat a particular trial until correct before moving on to next trial?
Hi, how can I repeat a particular trial or question until a correct response is obtained (e.g., participants must keep trying question 1 until they get it correct before they can move on to question 2)? Are there any examples of how this has been implemented? Thanks very much.
Comments
Hi,
You can add a repeat_cycle plug-in (typically) to the end of the trial_sequence. This plug-in has a 'Repeat if' statement, which you can set to any arbitrary criterion. For example, if the trial_sequence contains a keyboard_response item, and you want to repeat the trial if the response was incorrect, you can set the 'Repeat if' statement to
[correct] = 0.Best wishes,
Lotje
Did you like my answer? Feel free to

Hi Lotje,
Thanks for the reply. The repeat_cycle plug-in repeats all the incorrect cycles AFTER all cycles have been completed, but what I want is to repeat a particular cycle immediately. So instead of cycle 1, 2, 3, 4, 5, repeat 1, 2, I want it proceed this way 1, 1, 2, 2, 3, 4, 5. Any idea how to accomplish that? Thanks again.
Hi,
I see what you mean. You can immediately repeat an error trial by:
1.) Appending an inline_script item to the very end of your trial sequence:
2.) And placing the following code in its Run phase tab:
You can find a simple example experiment here (download, change the extension from .txt into .opensesame and open as normally):
I hope this helps!
Best,
Lotje
Did you like my answer? Feel free to

Hi Lotje,
That worked brilliantly! Thanks very much!
I am using this code to do something similar in my experiment. It does repeat the current trial but it also seems to leave off a trial at the end. That is if I have 10 questions, this will repeat say question 1 once but then only go to question 9. I assume this is because it is using up one of the predefined cycles to repeat this trial. Is there a way to hold this cycle constant until the trial has been answered successfully?
Repeating a trial, as described above, shouldn't result in skipping another trial. So presumably something else is going wrong here. Could you describe in more detail how you have implemented this exactly?
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Thanks for the reply. I have checked the sample code and indeed it doesn't do what my program is doing. I can't immediately see what the experiment is doing wrong but I'll keep analyzing it and report back if I find anything that might be helpful to others. For now, I've started with a fresh experiment and gotten it working correctly.
Hello! I am making a discrimination reversal task on a touch screen for dogs to participate in. It is a two choice task, with two stimlui being randomly presented together on the left and right side of the screen. The dog must learn to discriminate between the two objects to receive a food reward. I used the inline script given above to allow for a trial to repeated if a the subject makes an incorrect choice. However, I want to repeat a trial only once if they chose the wrong choice (or don't make a choice). So essentially it is giving the subject a second chance to choose or not choose the positive stimulus. So, for example, if the subject chooses the negative stimulus, the same trial (let's say with the negative stimulus on the left side and the positive stimulus on the right side) will be ran once before moving on two the next trial (which will present the neg stimulus and positive stimulus on the left or right side randomly). I am very new to opensesame and python so I am not sure how to code for this. Any help is greatly appreciated!!
Hi Jackie,
I think a puppy deserves more than a single chance to right a wrong ;-) But to answer your question, I would write a simple
inline_scriptthat executes the trial_sequence again, but only if the response was incorrect and the trial was not repeated before.if not var.correct and not var.repeated: # 0 == False var.repeated = 1 items.execute('trial_sequence')This requires that the variable repeated is set to 0 in the block_loop.
I attached a simple example experiment that illustrates the idea.
Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi Sebastiaan,
It works perfectly! Thank you SO MUCH!!! The pups will appreciate it too :-)
Jackie
Does anybody perhaps know how would the same code proposed by lvanderlinden look like in the inline Java script?:)
Thank you!
Hi,
"Translating" this piece of Python code to Java script is, unfortunately, not possible. This is because
exp.items[]is not available in Java script.Is it necessary for your experiment to repeat an error trial immediately after participants made an incorrect response?
If not, you could consider repeating the error trial(s) (if any) at the end of the block loop, by:
[correct] = 0I attached an example script. This should run on OSWeb as well. I hope this helps.
Cheers,
Lotje
Did you like my answer? Feel free to
