The precondition command defines conditions under which the files in an include element should be included.
<include>
expression | Specifies the expression to evaluate to determine whether the file(s) should be included. |
The precondition attribute can be used to conditionally load different include files based on factors such as the subject or group code or the region or language of the respondent's computer. If the expression(s) given in the precondition evaluate to true, the files are included. If the expression(s) evaluate to false, the files are not included.
The precondition attributre provides a convenient way to create multi-language tests that are administered in the language of the respondent. To create a multi-language test, the different translations of text stimuli should be defined in separate scripts, one for each language. For example, a task that supports English and Japanese would have a main script controlling the test logic, and two include scripts containing the English and Japanese versions of the instructions and text stimuli presented by the task. The main script would then conditionally include either the Japanese or English include script based on the language code of the respondent's computer (returned by the computer.languagecode property).
The following example includes japanese.iqx include file if the language of the computer is japanese, and an english include file otherwise.
<include>
/ precondition=[computer.languagecode == "jp"]
/ file="japanese.iqx"
</include>
<include>
/ precondition=[computer.languagecode != "jp"]
/ file="english.iqx"
</include>