Description of the problem:
I have an experiment with two conditions, fillers, and one question. I have an excel sheet which looks like this:
conditiona | conditionb | question |
---|---|---|
x1 | y1 | question1 |
x2 | y2 | question2 |
x3 | y3 | question3 |
x4 | y4 | question4 |
x5 | y5 | question5 |
x6 | y6 | question6 |
x7 | y7 | question7 |
x8 | y8 | question8 |
x9 | y9 | question9 |
x10 | y10 | question10 |
x11 | y11 | question11 |
x12 | y12 | question12 |
filler | filler | question13 |
filler | filler | question14 |
filler | filler | question15 |
filler | filler | question16 |
filler | filler | question17 |
filler | filler | question18 |
filler | filler | question19 |
filler | filler | question20 |
filler | filler | question21 |
filler | filler | question22 |
filler | filler | question23 |
filler | filler | question24 |
filler | filler | question25 |
filler | filler | question26 |
filler | filler | question27 |
filler | filler | question28 |
I want participants to be randomly presented with either a stimulus of “conditionone” or “conditiontwo”. This is easy. But I want that they see exactly six (text) stimuli from “conditionone” and six from “conditiontwo” (and then the corresponding question) randomly interspersed with fillers.
I created the following JavaScript code which I added into a code component (“Begin experiment”):
//Participants need to see six stimuli from condition one and six from condition two
newlist =
["conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo"];
shuffle(newlist);
//Then they will see sixteen fillers
fillerlist =
["conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo",
"conditionone", "conditiontwo"];
shuffle(fillerlist);
//Put the list of stimuli and the filler list together
cuelist = (newlist + "," + fillerlist);
//In the right format:
cuelist = cuelist.split(",").map(String);
To “Begin routine”, I added:
//Take the first element of cuelist:
stims = cuelist.shift();
//Write this to the data file:
psychoJS.experiment.addData("stim", stims);
//Evaluate the string as a variable
stims=window[stims];
Then I added a loop with my excel sheet as an input and set the loop type to random. I added two text components, one taking $question and one taking $stims as an input (both: set every repeat).
The problem is: I do not get six stimuli from condition one and six from condition two, but sometimes like five from condition one and seven from condition two and stuff like that. I would really appreciate input!