Randomizing conditions files several times within one experiment

Hi everyone,

I have an experiment where I randomize 2 condition files (instruction A and instruction B) using code component in the begin routine:

function random_character() {
var chars = “AB”;
return chars.substr( Math.floor(Math.random() * 2), 1);
}

condition = random_character();

In my trials I put something like:
$‘Instruction’ + condition + ‘.xlsx’

I also need to randomize a file with stimuli (Stimuli C and Stimuli D):
function random_character() {
var chars = “CD”;
return chars.substr( Math.floor(Math.random() * 2), 1);
}

conditionV = random_character();

In my trials I put something like:
$‘Stimuli’ + conditionV + ‘.xlsx’

I need to get four possible variations out of it:
Instruction A, Stimuli C
Instruction A, Stimuli D
Instruction B, Stimuli C
Instruction B, Stimuli D

However, Psychopy for some reason generates something like Stimuli A, is unable to find that file (because it does not exist) and manifests an error.

Any idea how to have two code elements which randomize two separate conditions?

You are giving two different functions the same name, which is bound to cause confusion.

Personally I would just use shuffle and then select element [0]