Problem with random allocation of participants

OS: Mac Ventura
PsychoPy version: 2025.1.1
Standard Standalone Installation? (y/n) yes
URL of experiment: Pavlovia
Pavlovia

Do you want it to also run locally? no
What are you trying to achieve?:

It is a simple reading task. It worked fine before we decided to randomly allocate participants to either Block 1 or Block 2

What did you try to make it work?:

I added a piece of code at the beginning (first routine, before experiment tab in Builder)

Link to the most relevant existing thread you have found:

What specifically went wrong when you tried that?:
Experiment not running online, but running well offline

Did you add code to the number of repetitions of loop Block1?

1 if selectedBlock == 1 else 0

Unfortunately you can’t put Python code like that into PsychoPy components. It needs to go into an Auto translate code component so it can be translated to JS.

Hello, Yes, I add it into the dialog box. Fine, I’m going to create a code component at the beginning of the loop, so it translates to JS. I am going to leave the box empty and see if it works this way. Thank you

You could just put selectedBlock == 1 or a variable name which takes values 1 or 0 assigned in a code component.

Yes, I believe the values should be either 1 or 2, so I have added selectedBlock == 1 and selectedBlock == 2 into nReps for each loop… I’m afraid it is still not working (it gets stuck into “init”) thank you, I have the feeling that we are very close to have it working!

Are you trying to import random?