Reply To: Filtering a table with a global variable

PennController for IBEX Forums Support Filtering a table with a global variable Reply To: Filtering a table with a global variable

#11121
Arsen Anisimov
Participant

I have figured it out. PCIbex auto-magically saves the number of the block which was randomly chose in the first Template and uses it in the second, so my code looks like that:

I want my experiment to start with any topic (block) so I randomize them:

var blocks = [[randomize("block-1"), "later-block-1"], [randomize("block-2"), "later-block-2"], [randomize("block-3"), "later-block-3"], [randomize("block-4"), "later-block-4"]];

fisherYates(blocks);

Sequence("welcome", "consent", blocks[0][0], blocks[0][1], blocks[1][0], blocks[1][1], blocks[2][0], blocks[2][1], blocks[3][0], blocks[3][1], SendResults(), "end")

So “later-blocks” always follow regular “blocks”.

//block-
Template(
    GetTable( "list.csv" )
        .filter( row => row.text_type != "late" ) 
    , 
    row => newTrial("block-"+row.block,
        //
    )
    .log("id_item", row.id_item)
    .log("text_type", row.text_type)
    .log("group", row.group)
    .log("block", row.block)
);

//later-block-
Template(
    GetTable( "list.csv" )
        .filter( row => row.text_type == "late" ) 
    , 
    row => newTrial("later-block-"+row.block,
        //
    )
    .log("id_item", row.id_item)
    .log("text_type", row.text_type)
    .log("group", row.group)
    .log("block", row.block)
);