Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Restarting a Loop

Christopher_MayChristopher_May Posts: 4
edited February 27 in OpenSesame

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

  • eduardeduard Posts: 848

    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 loop is set to a high repeat number with a certain break_if statement, so that it will just keep on running, unless the user breaks out of it. Inside this loop you put the actual trial_loop which is what you keep on iterating until participants finish or make a mistake. Also in this loop you should define a break_if statement, 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 this loop that indicates whether this loop was 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

  • lvanderlindenlvanderlinden Posts: 292

    Hi Cristopher,

    I think the attached example should help you get started. I added an inline_script item at the end of the trial_sequence

    and placed the following code in the Run_phase tab:

    # If the participant gave an incorrect response:
    if var.correct == 0:
    
        # Re-execute the whole block_loop item
        items.execute(u'block_loop')
    

    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

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • Korem NKorem N Posts: 3

    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

  • eduardeduard Posts: 848

    Hi,

    So you don't want to repeat a sequence but only a previous item in that sequence. Is that correct? Can you try to replace u'sequence_name with the item's that you want to run?

    Eduard

  • Korem NKorem N Posts: 3

    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?

  • eduardeduard Posts: 848

    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

Sign In or Register to comment.