The onBlockEnd attribute specifies commands to be run at the end of a block.
Name | Type | Description |
---|---|---|
script | script |
This parameter executes one or more specified expressions after a block of trials is complete. The expressions can read and conditionally update the various properties in the script. This is useful for dynamically configuring the experiment based on, for example, the subject's performance on that block.
The following block lengthens the timeout based on the subject's mean response time on the last block (Note: 'this' represents 'block.myBlock' in this context):
<block myBlock>
/ trials=[1-5=practicetrial; 6-10=testtrial)]
/ onBlockEnd={
if (this.meanLatency > 1000) trial.testtrial.timeout = 950;
}
</block>
The following block sets the content of a text stimulus based on the percent of correct responses on previous blocks (Note: 'this' represents 'block.practice' in this context).
<block practice>
/ trials=[1-10=noreplace(lefttrial, righttrial)]
/ onBlockEnd={
if (this.percentCorrect > 80) text.status.setItem("nice job!",0);
}
</block>
The following block sets the volume of a sound stimulus to a randomly selected value.
<block myBlock>
/ trials=[1-12=noreplace(testtrial, testtrial, distractortrial)]
/ onBlockEnd={
sound.testsound.volume = rand(-10000, 0)";
}
</block>
The following block tracks the subject's best block score using a custom value (Note: 'this' represents 'block.myBlock' in this context).
<block myBlock>
/ trials=[1,3,5,7,9 = littletrial; 2,4,6,8,10 = bigtrial)]
/ onBlockEnd={
values.bestperformance = Math.max(values.bestperformance,this.percentCorrect);
}
</block>