Topic outline
-
-
Variables in Formula type questions
Formula questions (and some other Moodle questions) use both random and global (fixed) variables.
Variables (also called wildcards) allow you to create a dataset of possible values for Moodle to randomly select from. This means that each time the question is presented to students on a Moodle page, the question will have different values. This provides a greater level of test security for a question.
Using variables
Simply replace a value in your question with a variable name and define the parameters of that variable. Make sure that you pick an appropriate variable name. The name needs to be enclosed in curly braces whenever you use it in Moodle (for example, {width} or {x}).
Then give Moodle the formula for the answer, with the variables embedded.
For example: if your original question is about calculating the area of a triangle, given the base and height, you can make both of those values variable:
Question: Calculate the area of a rectangle with a base of {b} cm and a height of {h} cm.
Correct Answer Formula: {base} * {height} ( * being the multiplication sign ).
When a student takes the test, Moodle will randomly select values for {base} and {height} (from within your parameters) and mark the student's answer using the Correct Answer Formula.
You can set as many different variables for a question as you like, but we recommend keeping them to a minimum. Sometimes just making one value in the question into a variable will provide sufficient test security for the question.
Random variables
Random variables are the basic variables which the question depends on. You set the variables within a certain range, and according to incremental steps.You can either set a list of possible variables (separated by commas) or stipulate a lower and upper limit and increments (separated by colons).
For example:
- A = {1, 2, 3} This means that the variable will be either 1, 2, or 3.
- A = {1:10:1) This means that the variable will be a number between 1 and 10, in increments of 1.
Global variables
Global variables can be assigned a fixed value, or they can be determined by formulas which use the random variables (that is, they manipulate the random variables) and/or other global variables. Moodle will work out their values based on the random variables assigned to that student in that question.
Express global variables using a mathematical formula.
For example, if A is a random variable, the global variables might be set at:
- H = (2A)
- F = H – A
When setting the formulas, make sure that you’ve used the correct Order of Operations, especially for parentheses (). Also make sure that you entered any random variables correctly.
The global variables can include variables to represent student answers.
For example:
- Ans1 = H + F
-