 ##### Page tree
Go to start of banner

# Beispiel - Digging a hole

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 Content

Related topics
Further information

## Example "Digging a hole" 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. 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. All other variables will also be created:Variable: {PEOPLE}, type: text, random selection: men; woman; childrenVariable: {A}, type: integer, value range: min=2, max=4, step=1Variable: {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} 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. 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