Restarting a Loop
I have an OpenSesame loop which cycles through a sequence consisting of a sketchpad, keyboard, and logger. I would like the loop to restart from the first cycle after a user makes an incorrect response. Could you tell me how I reset the loop? Thank you!
Comments
Hi Christopher,
It is a little tricky to give you an out-of-the-box solution for that problem without actually trying to implement this. In general, I advice you to have two nested loop-sequence constructs. The outer
loopis set to a high repeat number with a certainbreak_ifstatement, so that it will just keep on running, unless the user breaks out of it. Inside thisloopyou put the actual trial_loop which is what you keep on iterating until participants finish or make a mistake. Also in thisloopyou should define abreak_ifstatement, e.g.if correct_response == False: break, or something along these lines. Importantly, you also need to define a variable in the very end of thisloopthat indicates whether thisloopwas finished without a mistake or not. This variable you can then use for the outer loop, to decide whether you will break it and continue with the rest of your experiment, or repeat the inner loop again.It surely is a little hard to grasp, but do you think you have an idea of what I tried to bring across?
Eduard
Hi Cristopher,
I think the attached example should help you get started. I added an
inline_scriptitem at the end of thetrial_sequenceand placed the following code in the Run_phase tab:
Not sure how you want to log and analyze the output, though. Are you going to analyze only the trials that were all correct in a row?
Cheers,
Lotje
Did you like my answer? Feel free to

Hi,
I tried using the
items.execute(u'sequence_name').
It runs the sequence again but, it runs the next row in the loop.
I want to run the same row again.
Details: subjects read a text, than needs to answer questions. If he wants he can press 5 and go back to the text and back again to the same question.
any suggestions?
Thanks,
Nachshon Korem
Hi,
So you don't want to repeat a
sequencebut only a previous item in thatsequence. Is that correct? Can you try to replaceu'sequence_namewith the item's that you want to run?Eduard
Hi,
1st thanks for your replay. Yes I tried that, it still continue to the next iteration.
I found an awful way to do it, add another loop and break it if subject responds.
Any better ideas?
Hi Korem,
I refuse to think of better ideas if you have a solution that works just fine and doesn't have any other drawbacks than being "ugly" (beauty is in the eyes of the beholder...)
Eduard