Choose input file depending on participant id

Hi, I can’t find a way to use different input file depending on participant’s id. What I need is to somehow implement this: “if participant’s id%2 !=0, choose file 1, else use file 2”.

I tried solutions proposed here: Selecting condition files depending on participant number. It gives me error “Conditions file not found.”

I will run it online, so it’s important that everything can be converted to javascript.

Any thoughts?

Hello Hejlo

here some thoughts

conditionFile = " "
if int(expInfo['participant'])%2 == 0:
    conditionFile = "group1.xlsx"
else:
    conditionFile = "group2.xlsx"

should autotranslate to JS. Call the conditionFile in the relevant loop with $conditionFile.

Best wishes Jens

Thanks Jens! It worked perfectly when I run the experiment locally, but when I try to pilot it from Pavlovia, I get the following error:
image

It looks like it’s unable to find the files when they are in two separate rotations. When I pilot it from Pavlovia using a single input file, it runs fine. I can’t see the reason why it would have a problem fetching separate files when run online if it doesn’t when run locally.

Hello Hejlo,

the file rot2.xlsx is uploaded?

Best wishes Jens

Hi Jens,

Sorry, uploaded where? On gitlab.pavlovia.org I have both rot1.xlsx and rot2.xlsx, as well as the single input file (that runs smoothly online).

Hello Hejlo,

do you mind sharing your script and your input files, either via link to your public project or upload *.psyexp, *. xlsx here. Currently, your link just goes to gitlab and not to your project.

Best wishes Jens

Of course, here the link to the project Olga Solaja / MIT_online · GitLab.
The single input file is mit_stim_online.xlsx
Thank you!

Have you added the possible Excel files as resources under Settings – Online?

Ok hejlo,

delete the code-element from your trial-routine. Insert a code-element in the instructions-routine. Insert the following code at the Begin-Experiment tab of that code-element


if int(expInfo['participant'])%2 == 0:
    conditionFile = "2"
else:
    conditionFile = "1"

In your trial loop trials enter $"rot"+conditionFile+".xlsx".

The solution posted only works locally but not on-line. No resources, e.g. rot1.xlsx, were downloaded.

Best wishes Jens

It works! Thanks a lot, Jens!

I didn’t do that, but it worked out with @JensBoelte suggestion below. Thank you!