up Inquisit Language Reference

onTrialBegin attribute

The onTrialBegin attribute specifies commands to be run at the beginning of a trial.

Member of

<block> <expt> <likert> <openended> <sliderTrial> <survey> <surveyPage> <trial>

Syntax

/ onTrialBegin = { script }

Parameters

Name Type Description
script script

Remarks

This attribute executes commands at the beginning of a trial, e.g conditionally updating the various properties in the script. This is useful for dynamically configuring the trial and its stimuli based on the state of the script or the subject's performance.

Examples

The following trial updates feedback text based on whether the subject's last response was correct:

<trial myTrial>
/ stimulusTimes=[0=feedback, ratepicture]
/ onTrialBegin={
  if (values.lastcorrect == true) text.feedback.setItem("Your last response was correct",0);
}
</trial>

The following trial shortens a response timeout by 5 millisecond increments with each iteration of the trial (Note: 'this' represents 'trial.myTrial' in this context).

<trial myTrial>
/ stimulusTimes=[0=testmessage]
/ onTrialBegin={
  this.timeout = 1000 - (block.myBlock.currentTrialNumber * 5)";
}
</trial>

The following trial sets the volume of a sound stimulus to a randomly selected value.

<trial myTrial>
/ stimulusTimes=[0=hearingtest]
/ onTrialBegin={
  sound.hearingtest.volume = rand(-10000, 0)";
}
</trial>

The following trial updates a simple trial counter before it runs.

<trial myTrial>
/ stimulusTimes=[0,3,5,7,9 = littletrial; 2,4,6,8,10 = bigtrial)]
/ onTrialBegin={
  values.testtrialCounter++;
}
</trial>

Copyright Millisecond Software, LLC. All rights reserved.