PennController for IBEX › Forums › Support › Adding break trials › Reply To: Adding break trials

This was very helpful but I am encountering a minor problem with the the Break trial as it was described in this thread and the linked one. My experiment has 63 trials and the number of breaks I want to include doesn’t cleanly fit into that number (I also don’t need to give the participant a break after they have completed all 63 trials, they can just reach the end of the experiment at that point.
I first tried to give breaks every 16 trials in the hopes that it would give a break at 16, 32, and 48, and since my .csv file only has 63 trials it would skip doing a fourth break since no 64th trial exists but I still get the break occurring. I even tried 17 just to see if it had something to do with 63 being so close to 64 and it still occurred.
For reference, the code I am using is
function SepWithN(sep, main, n) {
this.args = [sep,main];
this.run = function(arrays) {
assert(arrays.length == 2, "Wrong number of arguments (or bad argument) to SepWithN");
assert(parseInt(n) > 0, "N must be a positive number");
let sep = arrays[0];
let main = arrays[1];
if (main.length <= 1)
return main
else {
let newArray = [];
while (main.length){
for (let i = 0; i < n && main.length>0; i++)
newArray.push(main.shift());
for (let j = 0; j < sep.length; ++j)
newArray.push(sep[j]);
}
return newArray;
}
}
}
function sepWithN(sep, main, n) { return new SepWithN(sep, main, n); }
And my sequence looks like this:
Sequence(sepWithN("break",randomize("exptrial"),17),"endexp")
Thanks for the help,
Max
-
This reply was modified 4 years, 2 months ago by
Jeremy. Reason: replaced main.pop() with main.shift()