I have quite a few so it may be easier to try and see them in the file I attached, but I will copy them here too in the hopes that helps.
Verbal recall:
Begin routine:
respDisplay = “”;
maxDigits = 100;
//key logger defaults
last_len = 0
key_list =
Each frame:
//if a new key has been pressed since last time
if(keyResp.keys != undefined && keyResp.keys.length > last_len) {
//increment the key logger length
last_len = keyResp.keys.length
//grab the last key added to the keys list
key_list.push(keyResp.keys.pop())
//check for space
if(key_list.indexOf("space") !=-1) {
key_list.splice(key_list.indexOf("space"), 1)
key_list.append(key_list.indexOf(" "),1)
//check for backspace
if(key_list.indexOf("backspace") != -1) {
key_list.splice(key_list.indexOf("backspace"), 1)
//if we have at least 1 character, remove it
if (key_list.length > 0) {
key_list.pop();
}
}
else
//if enter is pressed then...
if(key_list.indexOf("return") != -1) {
//remove the enter key
key_list.pop();
//and end the trial if we have at least 2 digits
if (key_list.length >= 2) {
continueRoutine = false;
}
}
//now loop through and remove any extra characters that may exist
while (key_list.length > maxDigits) {
key_list.pop();
}
//create a variable to display
respDisplay = key_list.join("");
}
End routine:
psychoJS.experiment.addData(“verbResponsef”, respDisplay);
Forward spatial recall:
Begin experiment:
correctcount_3 = 0;
sequenceLength_3 = 3;
incorrectCountAtLength_3 = 0;
Begin routine:
// initial state
blkIndex_3 = 0;
nextSwitch_3 = blockDuration;
doingResponse_3 = false;
currBlock_3 = undefined;
dist_min_3 = 0;
blockCoords_3 = ;
actualSequenceLength = Math.min(sequenceLength_3, 9);
//If you got two wrong on that length, reduce length
if ((incorrectCountAtLength_3 === 2)) {
sequenceLength_3 = (sequenceLength_3 - 1);
incorrectCountAtLength_3 = 0;
}
// store ANSWER blocks as a dictionary (to switch between name/object)
blocks_3 = {};
blocks_3[‘blk1_3’]=blk1_3;
blocks_3[‘blk2_3’]=blk2_3;
blocks_3[‘blk3_3’]=blk3_3;
blocks_3[‘blk4_3’]=blk4_3;
blocks_3[‘blk5_3’]=blk5_3;
blocks_3[‘blk6_3’]=blk6_3;
blocks_3[‘blk7_3’]=blk7_3;
blocks_3[‘blk8_3’]=blk8_3;
blocks_3[‘blk9_3’]=blk9_3;
// Create grid of locations with jitter
let xGrid = [-.3, 0, .3];
let yGrid = [-.3, 0, .3];
let locations = ;
for (let x in xGrid) {
for (let y in yGrid) {
locations.push([xGrid+Math.random(2).1 -.05, yGrid[y]+Math.random(2).1 -.05]);
}
}
// Shuffle locations
for (let rolls in blocks_3) {
locations = locations.sort(function() { return 0.5 - Math.random()});
}
var counter = 0; // location index
// give blocks a new set of random locations
for (let items in blocks_3) {
if (blocks_3[items].hasOwnProperty(‘pos’)) {
blocks_3[items].pos = locations[counter];
counter = counter + 1;
}
if (blocks_3[items].hasOwnProperty(‘fillColor’)) {
blocks_3[items].fillColor = new util.Color(‘white’);
blocks_3[items].lineColor = new util.Color(‘white’);
}
}
sequence_3 = [“blk1_3”, “blk2_3”, “blk3_3”, “blk4_3”, “blk5_3”, “blk6_3”, “blk7_3”, “blk8_3”, “blk9_3”];
respSequence_3 = ;
Each frame:
if (!(doingResponse_3) && (t > nextSwitch_3)) {
if (typeof currBlock_3 != ‘undefined’) {
// reset color of current block
currBlock_3.fillColor = new util.Color(‘white’);
currBlock_3.lineColor = new util.Color(‘white’);
}
// then change current block and make that red
if (blkIndex_3 >= actualSequenceLength) {
doingResponse_3 = true; // no more blocks to show
} else {
let currBlockName_3 = sequence_3[blkIndex_3];
currBlock_3 = blocks_3[currBlockName_3];
respSequence_3.push(currBlock_3.name);
currBlock_3.fillColor = new util.Color(‘red’);
currBlock_3.lineColor = new util.Color(‘red’);
// track time of this change
nextSwitch_3 = parseFloat(nextSwitch_3) + parseFloat(blockDuration);
}
blkIndex_3 = blkIndex_3 + 1;
}
// all clicked?
if (mouse_3.clicked_name.length >= actualSequenceLength) {
continueRoutine = false;
}
// update color of clicked
for (let blockName in mouse_3.clicked_name) {
for (let eachBlock in blocks_3) {
if (mouse_3.clicked_name[blockName] == blocks_3[eachBlock].name) {
blocks_3[eachBlock].fillColor = new util.Color(‘silver’);
blocks_3[eachBlock].lineColor = new util.Color(‘silver’);
}
}
}
End routine:
psychoJS.experiment.addData(“respSequencef”, respSequence_3);
psychoJS.experiment.addData(“sequenceLengthf”, actualSequenceLength);
psychoJS.experiment.addData(“CorrectAnswerf”, sequence_3.slice(0, actualSequenceLength));
psychoJS.experiment.addData(“incorrectCountAtLengthf”, incorrectCountAtLength_3);
psychoJS.experiment.addData(“blockCoordsf”, blockCoords_3);
psychoJS.experiment.addData(“dist_minf”, dist_min_3);
psychoJS.experiment.addData(“Clickedf”, mouse_3.clicked_name);
//Is answer correct?
if ((JSON.stringify(mouse_3.clicked_name) === JSON.stringify(sequence_3.slice(0, actualSequenceLength)))) {
sequenceLength_3 += 1;
incorrectCountAtLength_3 = 0;
} else {
incorrectCountAtLength_3 += 1;
}
Backward spatial recall:
Begin experiment:
correctcount_4 = 0;
sequenceLength_4 = 3;
incorrectCountAtLength_4 = 0;
Begin routine:
// initial state
blkIndex_4 = 0;
nextSwitch_4 = blockDuration;
doingResponse_4 = false;
currBlock_4 = undefined;
dist_min_4 = 0;
blockCoords_4 = ;
actualSequenceLength = Math.min(sequenceLength_4, 9);
//If you got two wrong on that length, reduce length
if ((incorrectCountAtLength_4 === 2)) {
sequenceLength_4 = (sequenceLength_4 - 1);
incorrectCountAtLength_4 = 0;
}
// store ANSWER blocks as a dictionary (to switch between name/object)
blocks_4 = {};
blocks_4[‘blk1_4’]=blk1_4;
blocks_4[‘blk2_4’]=blk2_4;
blocks_4[‘blk3_4’]=blk3_4;
blocks_4[‘blk4_4’]=blk4_4;
blocks_4[‘blk5_4’]=blk5_4;
blocks_4[‘blk6_4’]=blk6_4;
blocks_4[‘blk7_4’]=blk7_4;
blocks_4[‘blk8_4’]=blk8_4;
blocks_4[‘blk9_4’]=blk9_4;
// Create grid of locations with jitter
let xGrid = [-.3, 0, .3];
let yGrid = [-.3, 0, .3];
let locations = ;
for (let x in xGrid) {
for (let y in yGrid) {
locations.push([xGrid+Math.random(2).1 -.05, yGrid[y]+Math.random(2).1 -.05]);
}
}
// Shuffle locations
for (let rolls in blocks_4) {
locations = locations.sort(function() { return 0.5 - Math.random()});
}
var counter = 0; // location index
// give blocks a new set of random locations
for (let items in blocks_4) {
if (blocks_4[items].hasOwnProperty(‘pos’)) {
blocks_4[items].pos = locations[counter];
counter = counter + 1;
}
if (blocks_4[items].hasOwnProperty(‘fillColor’)) {
blocks_4[items].fillColor = new util.Color(‘white’);
blocks_4[items].lineColor = new util.Color(‘white’);
}
}
sequence_4 = [“blk1_4”, “blk2_4”, “blk3_4”, “blk4_4”, “blk5_4”, “blk6_4”, “blk7_4”, “blk8_4”, “blk9_4”];
respSequence_4 = ;
Each frame:
if (!(doingResponse_4) && (t > nextSwitch_4)) {
if (typeof currBlock_4 != ‘undefined’) {
// reset color of current block
currBlock_4.fillColor = new util.Color(‘white’);
currBlock_4.lineColor = new util.Color(‘white’);
}
// then change current block and make that red
if (blkIndex_4 >= actualSequenceLength) {
doingResponse_4 = true; // no more blocks to show
} else {
let currBlockName_4 = sequence_4[blkIndex_4];
currBlock_4 = blocks_4[currBlockName_4];
respSequence_4.push(currBlock_4.name);
currBlock_4.fillColor = new util.Color(‘red’);
currBlock_4.lineColor = new util.Color(‘red’);
// track time of this change
nextSwitch_4 = parseFloat(nextSwitch_4) + parseFloat(blockDuration);
}
blkIndex_4 = blkIndex_4 + 1;
}
// all clicked?
if (mouse_4.clicked_name.length >= actualSequenceLength) {
continueRoutine = false;
}
// update color of clicked
for (let blockName in mouse_4.clicked_name) {
for (let eachBlock in blocks_4) {
if (mouse_4.clicked_name[blockName] == blocks_4[eachBlock].name) {
blocks_4[eachBlock].fillColor = new util.Color(‘silver’);
blocks_4[eachBlock].lineColor = new util.Color(‘silver’);
}
}
}
End routine:
psychoJS.experiment.addData(“respSequenceb”, respSequence_4);
psychoJS.experiment.addData(“sequenceLengthb”, actualSequenceLength);
psychoJS.experiment.addData(“CorrectAnswerb”, .concat(sequence_4.slice(0, actualSequenceLength)).reverse());
psychoJS.experiment.addData(“incorrectCountAtLengthb”, incorrectCountAtLength_4);
psychoJS.experiment.addData(“blockCoordsb”, blockCoords_4);
psychoJS.experiment.addData(“dist_minb”, dist_min_4);
psychoJS.experiment.addData(“Clickedb”, mouse_4.clicked_name);
//Is answer correct?
if ((JSON.stringify(mouse_4.clicked_name) === .concat(JSON.stringify(sequence_4.slice(0, actualSequenceLength))).reverse())){
sequenceLength_4 += 1;
incorrectCountAtLength_4 = 0;
} else {
incorrectCountAtLength_4 += 1;
}
Math test:
Begin routine:
respDisplay_2 = “”;
maxDigits_2 = 100;
//key logger defaults
last_len_2 = 0
key_list_2 =
Each frame:
//if a new key has been pressed since last time
if(keyResp_2.keys != undefined && keyResp_2.keys.length > last_len_2) {
//increment the key logger length
last_len_2 = keyResp_2.keys.length
//grab the last key added to the keys list
key_list_2.push(keyResp_2.keys.pop())
//check for space
if(key_list_2.indexOf("space") !=-1) {
key_list_2.splice(key_list.indexOf("space"), 1)
key_list_2.append(key_list.indexOf(" "),1)
//check for decimal point
if(key_list_2.indexOf("period") !=-1) {
key_list_2.splice(key_list.indexOf("period"), 1)
key_list_2.append(key_list.indexOf("."),1)
//check for backspace
if(key_list_2.indexOf("backspace") != -1) {
key_list_2.splice(key_list_2.indexOf("backspace"), 1)
//if we have at least 1 character, remove it
if (key_list_2.length > 0) {
key_list_2.pop();
}
}
else
//if enter is pressed then...
if(key_list_2.indexOf("return") != -1) {
//remove the enter key
key_list_2.pop();
//and end the trial if we have at least 1 digits
if (key_list_2.length >= 1) {
continueRoutine = false;
}
}
//now loop through and remove any extra characters that may exist
while (key_list_2.length > maxDigits_2) {
key_list_2.pop();
}
//create a variable to display
respDisplay_2 = key_list_2.join("");
}
End routine:
psychoJS.experiment.addData(“mathResponse”, respDisplay_2);
That is probably the least elegant way to share so if there’s a better way then let me know!
Katie