How to skip the final routine on the last run of the loop

Hello everyone.

I have built the following experiment on builder (Screenshot below). The first loop (Group_A) should be repeated e.g 3 times and every time it is repeated the next routine named “end_block” should appear but not on the last repetition of the loop. So, for example, loop “Group_A” should run, followed by routine “end_block”, followed by the second repetition of loop “Group_A”, followed by routine “end_block”, followed by third repetition of loop “Group_A”. I would like Builder to skip routine “end_block” after the third repetition of loop “Group_A” and the participant be forwarded to the thank you routine. (The participants do only one of the loops, either loop “Group_A” or loop “Group_B”. So after completing loop “Group_A”, they have to be forwarded to the thank you routine and not loop “Group_B”). How do I do that? Thank you very much in advance.

Hello

try the following:

  1. add a code-component to the end_block routine.
  2. make it the top component of this routine
  3. insert the following code in the Begin routine tab of this code-component
if trials.thisRepN == 2:
    continueRoutine = False

Not tested :wink:

Best wishes Jens

Hello

Thank you again for your reply and trying to help. I tried this code once and thought it workedbut I was mistaken and on other runs of the experiment I realized that it didn’t work. So I am back to looking for a solution for this problem.

I would be really grateful if someone could help me solve it.

Hey,
Jens’s solution looks like a good solution to your problem.
Can you please share how you implemented it? Show us the code as well as the flow of your experiment.

Thanks,
Chen

Hi

Thank you for your reply. The following screenshots show the flow of the experiment and the code. In the outer loop, I choose the number of repeats as 3.


You wrote continueRoutine==Flase instead of continueRoutine=False.
The == operator is used to compare between 2 values while the = operator is used to assign a new value to a variable.

Let me know if it works now!
Chen

First, I wrote it with only one = but then I changed it to two ==. It doesn’t work either way.

Hello

Have you also corrected False to False? Copy and paste the code I have provided into your code component.

Best wishes Jens

Hello

Yes, I exactly copy-pasted the code into my experiment but it did not work. I had to build a new experiment with a longer flow with three blocks and two en_block routines in between them. It looks more awkward but it works in the way I expected. Thanks anyhow for trying to help.