Assigning participants randomly to a condition

@Nessimon, in a code component you could add the following:

# Begin Experiment
import random
condition = random.choice(('A','B'))

Then, your filename in your loop would be called $'Order' + condition + '.xlsx', which would give OrderA.xlsx, or OrderB.xlsx. This will work for Python, but for running the study online you will need JavaScript code - remember to switch the code component to Code Type “Both” to see both JS and Python code panels. Here is some JavaScript…

// Begin Experiment
function random_character() {
    var chars = "AB";
    return chars.substr( Math.floor(Math.random() * 2), 1);
}

condition = random_character();  // the condition variable will be used in your loop, as with the Python code
4 Likes