Page tree
Skip to end of metadata
Go to start of metadata

The following sample task shows the use of variables to generate random values in a calculation interaction. The participant should calculate the answer depending on given values, which are redefined for each attempt.

This example is based on the example content "Digging a hole" published by IMS for the use of IMS QTI item templates. 

Example task

Example "Digging a hole"

Editor view of the task

Create a calculation interaction and replace by variables all the values in the task text that should later be initialised with random values. Variables can be added by specifying the variable name in braces. The following variables are used in the example:

  • The text variable {PEOPLE} should be randomly assigned the value "men", "woman" or "children".
  • The numerical variables {A}/{B} indicate the number of people.
  • The numerical variable {MIN} stands for the given time.

The answer is to be calculated from the given values and will also be represented as a variable later:

  • The numerical variable {ANSWER} refers to the time to be calculated.

Editor view of a variable

All required variables can be managed in the tab Variables. In the following, the variable creation process will be explained using the text variable example {PEOPLE}:

  • In the section Pre-processed variables, create a new variable via the button Add new variable.
  • Enter the variable name PEOPLE. Please pay attention to the correct spelling of the variable name. Upper- and lower-case letters must be the same as for the placeholder.
  • Since this is a text variable, select the entry Text as variable type.
  • The value is set from a random selection of given terms.
  • Enter the terms "men", "woman" and "children". Separate multiple values by a line break or semicolon.

Overview of the task variables

All other variables will also be created:

  • Variable: {PEOPLE}, type: text, random selection: men; woman; children
  • Variable: {A}, type: integer, value range: min=2, max=4, step=1
  • Variable: {MIN}, type: floating-point, calculation (MAXIMA): 120/{A}    

The variable {B} should be set depending on the variable {A} to simplify the calculation. Therefore, the variable {B} is initially empty and then set to the appropriate value using a condition.

  • Variable: {B}, type: integer, condition: IF A = 2 THEN B = value range: min=4, max=12, step=2 ELSE IF A = 3 THEN B = random selection: 6; 12 ELSE IF A = 4 THEN B = random selection: 8; 12  
  • Variable: {ANSWER}, type: integer, calculation (MAXIMA): 120/{B}

Editor view of the task with variables

To insert the variable into the task text, you need to type the variable name {PEOPLE}. In the example, the variable is included in a task of the type calculation interaction.

Example task with automatically generated variable values

One of the defined values will be randomly chosen for each participant and each test attempt. In the example, the value "women" was inserted.

  • No labels