Implement different tasks based on session which is written before the running

OS: Win11
PsychoPy version : PsychoPy 2023.2.3

My purpose:

  1. Design 4 loops, each containing 30 trials, each trial runs the same program but presents different stimuli.
  2. The 120 trials, which could have been combined into a single loop, are divided into 4 loops due to participant breaks interspersed between them.

My issue:

  1. Participants may exit midway through the experiment, causing subsequent trials to restart from the beginning.
  2. I want to use the session provided at the beginning to determine which loop of the trial the participant has left to complete.

What I have done:
1709455800439
1709456408057

as you can see, I intend to assign a Block_number for each loop, which will be toggled 0/1 based on the session identifier. Consequently, at the beginning of each loop, I can check whether to proceed based on the Block_number value.

But this cannot work, the program is running as if I hadn’t set any code yet. By the way, I’ve successfully run each loop. I just want to use a control to confirm whether the loop should be executed or not.

So is there any solution or is there a simpler and more efficient way for me to achieve this task?

I’m new to PsychoPy and this forum, so I appreciate any help I can get. Thanks in advance!

Which tab have you used? It should be Begin Experiment

Do I have to put all the code inside ‘Begin Experiment’?

I asked some people, and the response I got was that I can achieve my idea by using code [<loop_name>.finished = True (Python offline, replace <loop_name> to the current loop name) and trials.finished = true (JS online)]

It’s more complex than I anticipated. I feel like this feature doesn’t require overly complicated statements.

It would be better to use nReps to stop the loop starting. trials.finished = True is for ending a loop early