How to use parametrisation in Questions
Besides creating unique, randomised Assignments, you can also create unique Questions for every Learner in a Digital Test. This is called parametrisation; the use of parameters to change a specific element within a Question.
Many Questions contain numbers and/or parameters. It is possible to code multiple Variables with a changing value for each Learner using Python in the Code Editor in Ans. This Variable can thereupon be used in the Question Field, the feedback section, and to the calculate the correct answer.
This page shows an overview of Question Types that can be parametrised, followed by an explanation how to use the Code Editor in Ans and two examples on how to code parametrisation.
-
Parametrisation is only available for Assignments of the Digital Test type. Each Question Type can have parameters in the Question Field. Depending on the Question Type it is also possible to have parameters in the answer field. For an overview, please see the table below.
Konijn, A. (2023, January 20). Inserting Parameters in Question Types. Ans Support. Retrieved May 3, 2023, from https://support.ans.app/hc/en-us/articles/360010591117-Parameterise-questions.
Question Type Question Field and Feedback Field Answer Field Open Yes Not applicable Numerical Yes Yes, by inserting Variable Mathematical Yes Not applicable Multiple-choice Yes Yes, for detractors Code-editor Yes Not applicable Fill-in Yes Yes, by inserting Variable, but cannot parametrise the different answer options File-upload Yes Not applicable Match Yes Yes Order Yes Yes Hotspot Yes Not applicable Hotspot-match Yes Not applicable -
In the Code Editor you can use Python to create Variables. These Variables can thereafter be used in Questions in combination with the mathematical operations listed below. You can use brackets to specify the order of mathematical operations.
Add up + Subtract - Divide / Multiply * Do by the power of ** To create a Variable, that has a unique value for each Learner:
- Go to or create an Assignment.
- Click New exercise and fill in the name.
- Click the ellipsis (...-icon) and choose Code Editor from the drop-down.
Konijn, A. (2022, December 12). Use the code editor in an Exercise; step 5. Ans Support. Retrieved May 10, 2023, from https://support.ans.app/hc/en-us/articles/360033627793-Use-the-code-editor-in-an-exercise.
- Write your code in the black input field. See the example above (please note that the example shows the creation of three Variables; ‘a’, 'b' and ‘c’.)
- Create a random value for each Learner using the function 'random(x,y,step=z)'.
The value of the function 'random(x,y,step=z)' will be somewhere between x and y with steps of z. If you for example use the function ‘(1,7,2)’, the value can be 1, 3, 5 or 7. You can use a 'print' statement to see if your Variables are defined correctly.
- Click Run to check for errors.
- Click Save.
The random module in Python cannot be used in Ans, because the random numbers Learners see during the test have to match the random numbers during grading. Always use the function 'random(x,y,step=z)'.
You can make use of Python libraries for more difficult functions. You can import a new library by using the code: import #library_name.
-
The Variables ‘a’, 'b’ and ‘c’ (with a unique value for each Learner) from the steps above can be used in a Numerical Question. The steps below show the basic example of linear formula a*b=c. Besides this example, it is possible to use Variables in other Question Types as well, while it is also possible to use a different (set of) Variable(s) in a Numerical Question.
To create a Numerical Question with a Variables:
- Go to or create an Assignment.
- Click New Exercise and fill in its name.
- Click New Question and choose Numerical Question.
- Click the icon with the three vertical dots and check Use Variable.
- Click the ellipsis (...-icon) and choose Code Editor from the dropdown.
- Write your code in the black input field. You could for example use the random function from the previous set of steps.
- Click Run to test the code.
- Click Save.
- Formulate the Question in the Question Content field. You can insert Variables with the Variable button). If you used the random function and the formula ‘c = a * b’ from the previous steps, your Question Content should contain Variable (a) * variable (b).
- Select the Variable you want to use as correct answer from the Variable dropdown menu. If you used the random function and the Variables ‘a’, 'b’ and ‘c’ from the previous steps, choose c.
- You can optionally set a margin for the correct answer. You can choose % or Absolute.
- Click Save.
-
In this example the incorrect answer options for a multiple Choice Question are parametrised. You create a list of incorrect answer options, and each Learner is shown a set number of random answers from the list.
This example uses textual answer options, but you could also use numbers as correct and incorrect answer options.
In Python the correct answer to a multiple-choice Question is called the Keyed Response and the wrong alternatives are called Detractors.
To create a Multiple Choice Question with parametrisation:
- Go to or create an Assignment.
- Click New Exercise and fill in its name.
- Click the ellipsis (...-icon) and choose Code Editor from the dropdown.
- Write your code in the black input field. Use the 'Keyed_Response' variable for the correct answer(s). And fill in the incorrect answer options in 'All_Detractors'. See the example below:
- Click Run to test the code.
- Click Save.
To add answer options to the Question:
- Go to or create an Assignment.
- Click New Exercise and fill in its name.
- Click New Question and choose Multiple Choice from the list.
- Formulate the Question in the Question Content field and select One in the Correct Alternatives dropdown menu.
- Click + Add Alternative.
- Click the pencil-icon in the Formulate the alternative field.
- Click Variable and choose Keyed_Response from the dropdown.
- Click Save.
- Add three more Alternatives with + Add Alternative and add Detractor1, Detractor2 and Detractor3 to the respective Formulate the alternative fields with the Variable button.
- Make sure the Keyed_Response Alternative receives the highest number of Maximum Points.
- Click Save.
Need support?
Get in touch with us! We are happy to help.