Page tree
No Translation available yet

You have English selected as language but this page has not been translated yet. Translate the page or view the content in the default space language below.

Display default
Skip to end of metadata
Go to start of metadata

The use of variables allows the creation of dynamic task text. Task content can be generated randomly or adapted to the user, previously given answers, or assessments. For implementation, two different types of variables are provided in the tab of the same name:

  • Pre-processed variables
    Pre-variables are assigned before the task is displayed and therefore make it possible to adapt the task text as well as the predefined and correct answers dynamically. In this way, task templates can be defined with the help of placeholders. These are replaced by specific random values per test run on the basis of defined intervals, value drop-down lists, or calculation rules. As a result, test tasks will be different but similar for each participant and test run.
  • Post-processed variables
    Post-variables are only assigned after the task has been answered, submitted, and automatically assessed, thus allowing access to response-specific values such as the learner's response or the points for correct answers. In this way, adaptive feedback content, follow-up tests, and task series can be enabled. The use of conditions and MAXIMA statements allows responses from learners to be analysed and typical errors identified. Based on these insights, teachers will then be able to provide appropriate feedback or customised exercises.

Tab Variablen

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.

Variablen verwenden

Example "transport" - Use of random parameters

As an example, a typical application task is created. The goal is to calculate the distance travelled by a vehicle based on speed and time. The speed is dependent on the vehicle type.


Beispielaufgaben mit Variablen im Editor

In the example, the text variable {transport} will be randomly initialised with one of the following values: "bike", "bus", or "train". The numeric variable {speed} is randomly selected from a value range. Thus, the value range for the speed {speed} should be set in dependence of the selected vehicle {transport}, since a "bike" is generally slower than a "train".

Beispiel einer Bedingung im Editor Beispiel einer weiteren Bedingung im Editor

For dependent value setting, we use the variable condition. In the condition, we can define the value range for the variable {speed} depending on the selected value of the variable {transport}. For the bike ({transport}="bike"), for example, a value range of 10 to 30 (km/h) was set.

Variablen in der Aufgabenstellung nutzen

The given values of the task are integrated into the task text by specifying the variable name ({transport}, {speed}, and {hours}). In the example, the variable is included in a task of the type calculation interaction.

The variable with the correct solution {distance} is bound to the gap.

Beispielaufgabe im Testrun

One of the defined values will be randomly chosen for each participant and each test attempt. In the example, the value "bike" was randomly inserted, which is why a speed in the value range of 10 to 30 (km/h) was selected.

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.

Nutzerlösung einer Beispielaufgabe Nutzung einer Post-Variable im Feedback Nutzung einer Post-Variable Lösungshinweis

Example "transport" - Adaptive task feedback

Adaptive feedback allows for individual feedback based on the learners' answers. The participant can, for example, be provided with concrete hints or error messages. Post-variables (post-processed variables) allow access to the learners' responses, e.g. to each gap. Attempts at solutions or even previous answers can also be included in the feedback.

In the following, the example "transport" will be extended by simple adaptive feedback. Feedback should give the user an indication of whether their answer was less than or greater than the correct solution or hint at how the correct solution can be calculated.

Example "transport" - Adaptive task feedback
 Show example ...
Postvariablen und Bedingungen im Editor

In the first step, the text variable {div} in a condition is set to the value "less than" or "greater than" in the tab Variables , depending on whether the answer given by the learner was less than or greater than the correct answer.

In addition, the learner's answer will be stored in a numeric variable {answer} so that it can be easily accessed from within the feedback.

Nutzung von Post-Variablen im Feedback

In the second step, concrete task feedback is stored. The participant should see the feedback only if they have submitted an incorrect answer. Therefore, the general feedback Answer was wrong needs to be selected from the tab Feedback . For more information about task feedback, refer to the help page Set feedback .

Individual feedback and values stored in the variables can be included in other feedback by entering the variable name ({div}, {answer}).

Additional feedback blocks can also be added as individual feedback. In the example, a hint was added to the feedback, which is permanently displayed regardless of the learner's answer. Feedback can also contain detailed sample solutions and calculations. For tasks with random parameters, pre-processed variables can be added to the feedback.

Feedback mit Post-Variablen im Testrun

Since the task contains random parameters, different values will be displayed for each test attempt and participant. According to the defined content, the participant will now additionally be shown individual feedback based on their answer.

You can decide whether you want to retain the random parameters of a task or have them redefined for future attempts. For more information, see the section Reset variables on the help page Set test options.

Example "transport" - Points deduction per attempt

If the participant has several attempts at a solution, individual and successive hints can be provided to help them answer the question. In such scenarios, it may be especially desirable to have points deducted from the participant's total score for each additional attempt. A participant who answers the task correctly at the first attempt receives the full score. The more hints or attempts they need, the fewer points they will obtain.

For the example "transport" , a points deduction for each attempt should be realised using variables. Therefore, the maximum possible score for the task has been increased to 10 points. For each additional attempt, the score should be reduced by one point. In other words, if a task is attempted multiple times within one test run, points will be deducted for each additional attempt. The number of test attempts is not considered. It is strongly recommended to make the points deduction visible to the participant. This can be achieved by embedding appropriate text elements into the task and feedback.

Ansicht der Variablen zum Punktabzug in der  Beispielaufgabe

To perform the points deduction, the following variables need to be defined:

  • The numeric variable {deduction_attempt} stores the points deduction for each attempt.

    In this example, the total score should be reduced by one point. Therefore, {deduction_attempt) is set to a static value of 1. Since the value is static, it can be created as a pre-variable (pre-processed variable).

  • The numeric variable {deduction} stores the current points deduction depending on the attempt.

    The points deduction {deduction} is calculated as the product of the number of attempts (system variable NUMATTEMPTS) and the deduction of points per attempt {deduction_attempt}. Since this value is computed per attempt, it must be calculated as a post-variable (post-processed variable).

In addition, the score of the task must be recalculated according to the points deducted by setting the system variable SCORE and verified by the author. This includes the definition of a new condition: If the points deduction is greater than 0, the score of the task is reduced by the respective value.

Note: For the sake of simplicity, all of the variables for generating general task and feedback content have been hidden in the screenshot.

Note within the task:

  Hinweis zum Punktabzug in der Aufgabenstellung der Aufgabe

Note as individual feedback:

Hinweis als individuelles Feedback

A general note will be included in the task to make the learner aware of the fact that points may be deducted, and an individual note will be displayed as a feedback message immediately after the deduction.

Please note that if there has been a points deduction, the follow-up attempt can no longer be considered as completely correct because the maximum score can no longer be achieved. This also affects the presentation of the points achieved (colour marking), the correct/incorrect marking, and the general task feedback, which depends on the condition whether or not the participant has reached the maximum score. By using individual feedback, the logic for displaying feedback content can be individually adapted to the task.

Beispielaufgabe in unterschiedlichen Versuchen

Points will now be negated according to the number of attempts needed.

  • Participants who enter the correct answer at the first attempt receive the full score.
  • Participants who enter the correct answer in a follow-up attempt receive partial points. Through appropriate feedback, these participants can be given individual hints at the solution to encourage them to continue processing the task on their own.

Example "transport" - Assessment of the maximum score

If several attempts are possible per task, it might be the case that a participant will not score as many points in a follow-up attempt as was already scored before. If desired, the highest score achieved can be remembered and eventually used for the assessment. The participant should be informed accordingly through notes and be shown the scoring of the current attempt as well as the maximum score achieved for all attempts.

In the following, the example "transport" will help to explain how the assessment of the maximum score can be enabled.

Beispiel mit Wertung über mehrere Versuche

To do this, the following variables need to be defined.

The entire implementation is done using post-variables ( post-processed variables ), since, among other things, the score of the current attempt will be accessed.

Note: For the sake of simplicity, all of other variables for generating task and feedback content have been hidden in the screenshot.

  • The numeric variable {best_score} stores the highest score achieved in multiple attempts.
    The variable {best_score} is initialised without a value and later controlled by a condition:
    • At the first attempt , {best_score} is not yet initialised (NULL) and will be set to the current score {current_score}. Condition: IF best_score = NULL THEN best_score = value: current_score
    • Each successive attempt is checked to see whether the score achieved {current_score} is greater than the present maximum score {best_score}, in which case the latter will be adjusted accordingly. Condition: IF current_score > best_score THEN best_score = value: current_score
  • The numeric variable {current_score} stores the current score for the current attempt.
    The current score can be read out using the system variable SCORE. As this value is changed manually by the author, it should be temporarily stored in a variable. This guarantees access to the current score and, for example, the output of this value in notes and feedback.
    • With each attempt, the variable {current_score} is set to the value of the system variable SCORE. Condition: IF best_score = NULL THEN best_score = value: current_score
  • The numeric variable {best_score_is_used} stores whether the task assessment was changed manually.
    In the example, the participant should be shown an additional note if the best score is used for assessment instead of the current score. Therefore, the auxiliary variable {best_score_is_used} is applied, which will be set to the value 1 if the task assessment was changed manually.
    • The variable {best_score_is_used} is set to the value 1 if the current score is less than the highest score, which has been achieved so far. Otherwise, the variable is given the value 0. Condition: IF best_score > current_score THEN best_score_is_used = value: 1 ELSE best_score_is_used = value: 0

Note within the task:

Hinweis zur Wertung in Aufgabenstellung

In order to let the learners know which assessment procedure will be applied, a general note is included with the task. This note will be accompanied by some individual feedback information if the task assessment has been changed manually and the best score option has been configured.

Note as individual feedback:

Hinweis zur Wertung als individuelles Feedback

Feedback can be controlled using the auxiliary variable {best_score_is_used}, which displays individual feedback to the participant depending on whether its value is 0 or 1. It includes a reference to the current score {current_score} as well as to the maximum score {max_score} achieved so far. In addition, the system variable MAXSCORE is used to embed the maximum possible score in the note.

Beispielaufgabe Wertung in unterschiedlichen Versuchen


If the participant receives a lower score in a test attempt than in a previous attempt, the best score will be the one counted. In the example given, the exercise is configured in such a way that different values will be displayed for each test attempt. The participant has already solved the task at the second attempt and received the full score. Therefore, the participant obtains the full score for the task despite giving an incorrect answer. The feedback displayed to the participant also indicates that they have received 0 points for the current attempt, but that their best score of 10 points will be assessed.

This example can be combined with the application scenarios described above:

  • Example "transport" – Use of random parameters
  • Example "transport" – Adaptive task feedback
  • Example "transport" – Points deduction per attempt

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.

Definition einer Variable im Editor

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:

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:

Einfügen von Variablen in den Aufgabentext

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.

Eine neue Bedingung anlegen

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.

Vergleichsoperatoren einer Bedingung

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.

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.

Variable im Expertenmodus

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:

  • No labels