07 Using Variables
Pre-processed variables
Define variables that are determined before the task is displayed in order to use random parameters in your tasks. Variables are supported in ONYX for all types of tasks and offer various possibilities, especially for calculation interactions. With the help of variables, it is possible to create task templates which automatically allow an unlimited number of different test and exam attempts.
Post-processed variables
Define variables that are determined after the submission of the task in order to create adaptive task and test scenarios. Post-processed variables (in short: post-variables) allow you to access the learners' answers and points achieved. You can use this information to enhance following content such as feedback or task descriptions of follow-up attempts. In addition, it is possible to intervene in the assessment and make subsequent changes to it.
Definition of a variable
Click on Add new variable in the tab Variables to define a new variable. The new variable is immediately added and displayed in the overview table. Below the table, an edit window opens for the new variable. The order of the variables and conditions within the variables table can be easily changed using drag-and-drop.
Assign a unique variable name for your variable. The variable name serves as an identifier and allows you to use the variable in the task text. Please make sure that the variable name does not contain any umlauts, special characters, and spaces. The input is case sensitive. If a variable is defined with the name "a", it can be accessed via the placeholder {a}.
Select the variable type. The following variable types are available:
- Numerical variables:
- Integer
- Floating-point number
- Text variables
- Image variables
Depending on the selected variable type, you have various options for the determination of the value:
- Value
- Value range
- Random selection
- Calculation (MAXIMA)
Variables can also be created without immediately setting a value. If the value is set at a later point in time, it can for example be set in dependence of other variables (cf. conditions).
Use of variables
Defined variables can be inserted into task and answer text by specifying the variable name. Direct integration into LaTeX-formulas is also possible. The defined variable name must be enclosed in braces. ONYX automatically detects if there is a variable declaration with the appropriate name. If an identifier is used which is not defined, it will be ignored and output as text.
In the example, the variables {VAR1}, {VAR2}, and {VAR3} were declared:
Definition of a condition
In the tab Variables, you can also use conditions. A condition allows you to set the value of a variable, depending on other variable values.
Click on Add new condition to define a new condition. The new condition is immediately added and displayed in the overview table. Below the table, an edit window opens for the new condition. The order of the variables and conditions within the variables table can be easily changed using drag-and-drop.
Variables can be compared with other variables of the same type or with fixed values. The comparison operators depend on the type of the variable. You can, for example, check whether values are equal to (=) or not equal to (!=) another value.
Please note: A variable that is used within a condition must be initialised before the condition. The variable which is used in the condition or statement must be added as a single variable before the condition can be added. If the value of a variable is set within one or more conditions, it will be unnecessary to set a value for the variable itself. Select the empty entry from the value selection list.
Link conditions: If you have created several conditions for an IF section, you can configure how these entries will be linked. Determine whether all conditions (AND) or at least one condition (OR) must be met for the condition to be executed.
Alternative conditions (ELSE IF): You can add any number of alternative conditions (ELSE IF branches). Different variables can be set in the conditions. In the simple mode, only one variable can be set per condition. For more complex rules, you can switch to the expert mode. A more detailed description can be found in the help pages for the expert mode.
Expert mode (IMS QTI)
The variable representation in the test and task content is based on the principle of template declaration and the template processing of the IMS QTI 2.1 specification. The template processing of IMS QTI 2.1 offers far more possibilities for setting variables, in particular by the nesting of logical expressions and conditions. The description entered in the expert mode is directly transferred into the XML of the task as a single template processing expression.
Please note that after changing the description in the expert mode, there is no way to return to the simple mode.
For further information on the XML definition of the template processing, please refer to the section IMS QTI 2.1 specification. The ONYX Testsuite already supports a wide set of IMS QTI expressions and possibilities. A detailed check to ensure correct functioning of the task template is nevertheless recommended when using the expert mode.
View variable assignment
When testing your test content, you can view the variable assignment in the preview at any time. These details are also available to the supervisor or assessor in the results views. In addition to the variable assignment, information on the MAXIMA tasks as well as possible system errors are displayed.
For more detailed information, please refer to the following help sections: