PennController for IBEX › Forums › Support › Randomizer › Reply To: Randomizer
March 3, 2022 at 3:39 pm
#7826
![](https://www.pcibex.net/wp-content/uploads/2018/10/IMG_8365-e1540835663655-150x150.jpg)
Keymaster
Hi Marc,
I think mixing in other trials inside the “GreetingsTrial” is incompatible with the modifyRunningOrder
function we discussed in our email exchange. So you would be better off using a custom shuffle sequence function instead of using modifyRunningOrder
:
function KeepOneInGroupAfter(x,sep='_') { this.args = [x]; this.run = function(arrays) { const ret = [] const sources = {}; arrays[0].forEach( r=> { let type = r[0].type.split(sep); type.shift(); type = type.join(sep); sources[type] = [...(sources[type]||[]),r]; }); for (let k in sources){ fisherYates(sources[k]) // Randomize trials in the group ret.push(sources[k][0]) // Add first trial in the group } return ret; } } function keepOneInGroupAfter(x,sep) { return new KeepOneInGroupAfter(x,sep); }
Then you can do this:
Sequence("consent", "practice", rshuffle(keepOneInGroupAfter(startsWith("GreetingsTrial")), "other"), "send", "final")
Jeremy