Issue with selected_rows when using a custom variable in online experiment

Hi everyone,

I’m currently building an online experiment and ran into an issue I hope someone can help with.

My condition file contains 72 rows, and I want to randomly select 6 rows in each loop. To do this, I created a list called stimnum_cong containing the numbers 0 to 71. At the beginning of each loop, I shuffle this list, take the first 6 numbers, and store them in a new list called stimnum_sample. These selected numbers are then removed from stimnum_cong.

After that, I use the variable $stimnum_sample in the selected_rows field of the loop control. However, when I try to run the experiment online, I keep getting errors during this process.

I suspected the issue might be due to the data type of $stimnum_sample, so I tried converting it to a string using the following code:

# Convert stimnum_sample to a string
stimnum_str = ','.join(map(str, stimnum_sample))

Then I used $stimnum_str in the selected_rows field instead—but unfortunately, that didn’t work either.

I’d really appreciate any suggestions or insights you might have. Thank you so much in advance for your help!

Let me know if you’d like to take a look at my code. Many thanks again!

I’m fairly confident that the issue here is that you are setting the selected rows as a string of comma-separated indices instead of a list.

Try putting $stimnum_sample in your loop. If you’ve already tried this and get the same error then perhaps there’s an issue with your create of stimnum_sample. Try printing it to the console.