The ontrialend attribute specifies commands to be run at the end of a trial.
<expt> <surveypage> <trial>
expression | One or more expressions, delimited by semi-colons. See help with expression syntax for more information. |
This parameter executes one or more specified expressions after a trial 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 trial.
The following trial lengthens the timeout based on the subject's response time:
<trial mytrial>
/ stimulusframes=[1=teststim]
/ ontrialend=[if (trial.mytrial.beginresponsetime > values.timeout) values.timeout = values.timeout + 100]
</trial>
The following trial updates a score based on the participants response:
<trial mytrial>
/ stimulusframes=[1=teststim]
/ ontrialend=[if (trial.mytrial.response == "1") values.totalpoints = values.totalpoints + 10]
</trial>
The following trial sets the volume of a sound stimulus progressively louder up to a max of -10000 if the participant responds incorrectly.
<trial mytrial>
/ stimulusframes=[1=teststim]
/ ontrialend=[if (trial.mytrial.correct == false) sound.feedback.volume = max(-10000, sound.feedback.volume - 100)]
</trial>
The following trial tracks the subject's fastest score using a custom value.
<trial mytrial>
/ stimulusframes=[1=teststim]
/ ontrialend=[values.fastest = min(values.fastest, trial.mytrial.latency)]
</trial>