PennController for IBEX › Forums › Support › Question about assigning conditions, groups + randomization › Reply To: Question about assigning conditions, groups + randomization
July 17, 2023 at 11:07 am
#10745
Keymaster
Hi Kate,
You can use the same function to generate all your trials:
Template("dummy", () => {
const targetKeys = Object.keys(targets);
fisherYates(targetKeys); // shuffle the references to the pairs
let new_targets = []; // this will contain half the items (only POS or only NEG for each pair)
for (let i=0; i<targetKeys.length; i++) // keep the POS rows for the first half, the NEG rows for the second half
new_targets.push( ...targets[targetKeys[i]][ i<targetKeys.length/2 ? "posi" : "neg"] );
// Create three items per row that we kept
new_targets = new_targets.map(t=>
[ {contextsetter: t['contextcomparative'], contextquestion: t['comparativequestion']},
{contextsetter: t['contextequative'], contextquestion: t['equativequestion']},
{contextsetter: t['contextquestion'], contextquestion: t['questionquestion']}
].map(row => ["experiment_"+t.pair,"PennController", myCustomTrialFunction(row)] ) // this map returns an array of 3 trials
).flat(); // flatten the array to have all the trials at the root, instead of having a series of arrays of 3 trials
// Shuffle new_targets as long as we can find three items in a row that come from the same pair
while (new_targets.find( (v,i)=>i<(new_targets.length-2) && v[0].split('_')[1]==new_targets[i+1][0].split('_')[1] && v[0].split('_')[1]==new_targets[i+2][0].split('_')[1] ))
fisherYates(new_targets);
window.items = new_targets; // now add the trials to the experiment's items
return {}; // we added the items manually above: return an empty object from Template
})
This way you necessarily get the same rendering for all your trials
Jeremy