PennController for IBEX › Forums › Support › Different sequence for group?
Tagged: groupcolumn, groups, order, sequence
- This topic has 1 reply, 2 voices, and was last updated 2 years, 8 months ago by Jeremy.
-
AuthorPosts
-
March 22, 2022 at 1:37 pm #7950OwenJamesParticipant
Hello! I am trying to make my experiment have 2 groups ( A and B) and each group needs to do 7 experimental blocks, only Block A needs to have a different order of the blocks (a set order) than group B. Here is a link: https://farm.pcibex.net/r/bDpPaf/ and I commented the code with which I tried this, but this is the code:
Template( GetTable( "items.csv" ) .setGroupColumn( "blockorder" ), variable => newVar("blockorder").set(variable.blockorder).global().log()) if (getVar("blockorder") == "A") Sequence( "Consent", "block1Instructions", rshuffle("block1"), "block2Instructions", rshuffle("block2"), "block3Instructions", rshuffle("block3"), "block4Instructions", rshuffle("block4"), "block5Instructions", rshuffle("block5"), "block6Instructions", rshuffle("block6"), "block7Instructions", rshuffle("block7"), SendResults() , "Thankyou" ) //use different sequence per group else Sequence( "Consent", "block1Instructions", rshuffle("block1"), "block2Instructions", rshuffle("block2"), "block3Instructions", rshuffle("block3"), "block6Instructions", rshuffle("block6"), "block7Instructions", rshuffle("block7"), "block4Instructions", rshuffle("block4"), "block5Instructions", rshuffle("block5"), SendResults() , "Thankyou" )
I get an error with the blockorder variable (use of labelname unknown).
March 22, 2022 at 1:53 pm #7952JeremyKeymasterHi,
Use
__counter_value_from_server__
to conditionally execute differentSequence
commands:if (__counter_value_from_server__ % 2) Sequence( "Consent", "block1Instructions", rshuffle("block1"), "block2Instructions", rshuffle("block2"), "block3Instructions", rshuffle("block3"), "block6Instructions", rshuffle("block6"), "block7Instructions", rshuffle("block7"), "block4Instructions", rshuffle("block4"), "block5Instructions", rshuffle("block5"), SendResults() , "Thankyou" ) else Sequence( "Consent", "block1Instructions", rshuffle("block1"), "block2Instructions", rshuffle("block2"), "block3Instructions", rshuffle("block3"), "block4Instructions", rshuffle("block4"), "block5Instructions", rshuffle("block5"), "block6Instructions", rshuffle("block6"), "block7Instructions", rshuffle("block7"), SendResults() , "Thankyou" )
Template
executes its function after the core of the script, so the Var element “blockorder” will not have received its value by the time yourif
is executed. Also,getVar("blockorder")
returns a pointer to the javascript object that represents the Var element, which PennController knows how to interpret, but if you just reference it inside anif
like that, you won’t get what you think (ie. you won’t get"A"
or"B"
). How-to guide: Using JavaScriptJeremy
-
AuthorPosts
- You must be logged in to reply to this topic.