URL of experiment: [1 Hour Pilot Link] LINK HERE
Description of the problem:
I have a divided attention study that has a between-subjects factor of group. In an early code component, I set variable x to be a random integer, 1 or 2. Then, I use 1 or 2 to assign participants to either be in the Symbols group or the Word group. However, I’m having trouble making my experiment only show one set of instructions (by skipping the irrelevant instructions for the non-assigned group). To do so, I’ve set loops around the single-routine instruction screens (loops called ‘SkipToWords1’ and ‘SkipToSymbols1’, see screenshot below). In my in-lab version of the experiment, I had IF statements saying that, for example, IF group is Symbols, then set WordSkipper to 0 and then WordSkipper was the name of the loop around the word instructions, which would then skip that loop because I would set nReps to $WordSkipper. However, when going online and using Pavlovia, I got an error: TypeError: Cannot read property ‘0’ of undefined. So, my alternative solution was to set nReps to 1 and instead use a code component to break out of the loop. The idea being, if group is set to Symbols, then I have a code that breaks out of the Words group instructions screen/loop as soon as it starts, and vice versa.
I’ve now been on forums and have read everything I can get my hands on in terms of breaking out of a loop in Pavlovia using PsychoPy builder and JS code components, including but not limited to using ‘trials.finished’, ‘LOOPNAME.finished’ and ‘currentLoop.finished’, and every variation I can think of. All of this of course has been with Auto → JS turned on, except when needing to specify ‘trials.finished’ on the JS side. This leads me to believe that my IF statement isn’t finding the x variable I set at the start of the study. I’ve been at this for 2 days straight with no progress, so I’m hoping someone can help me out please!
Here are some contextual screenshots and things I’ve tried already:
Experiment flow at the beginning:
Part of my ‘RandomizerScript’ that randomizes people into group by variable x:
An example of code I tried by using a Code Component in the WelcomeSymbols routine, ‘Begin Routine’ tab:
if x == 2:
trials.finished = True
SkipToWords.finished = True
An example of code from the same routine, but in the ‘Each Frame’ tab:
if x == 2:
continueRoutine = False
Thanks everyone in advance! This forum has already been super useful.