Mathematical expression¶
Mathematical expression parts require the student to enter an algebraic expression, using JME syntax.
These parts are marked by picking a sample of points uniformly from a given range for the free variables in the expression, and evaluating both the student’s answer and the correct answer on those points. If the two expressions agree on enough inputs, then they are considered to be equivalent and the student’s answer is marked as correct.
For questions where the student is asked to rearrange an expression, clearly just evaluating both answers won’t detect the difference  you want to look at the form of the student’s answer, as well as the values it produces. The string restrictions offer a somewhat blunt method of restricting the form of the student’s answer. You can do more sophisticated testing with a custom marking algorithm and patternmatching on the student’s answer.
You can find the mathematical expression part’s builtin marking algorithm at GitHub.
Marking
 Correct answer
 The expected answer to the part. Question variables (or, more broadly, JME expressions which should be evaluated to a single value when the question is generated), can be included by enclosing them in curly braces.
 Show preview of student’s answer?
 If ticked, a rendering of the student’s answer in mathematical notation is displayed beeside the input box. You should leave this on unless you expect the answer to be veery simple and need the space  the feedback about how their answer is interpreted is very useful to students.
 Answer simplification rules
Simplification rules to apply to the correct answer, if it is displayed to the student (for example, after clicking the Reveal answers button). This shouldn’t affect marking.
If this field is empty, the following rules are applied:
basic
,unitFactor
,unitPower
,unitDenominator
,zeroFactor
,zeroTerm
,zeroPower
,collectNumbers
,zeroBase
,constantsFirst
,sqrtProduct
,sqrtDivision
,sqrtSquare
,otherNumbers
.
String restrictions
Before length restrictions are applied, surplus brackets and whitespace are removed, and spaces are inserted between some operations, to minimise the possibility of the length restrictions being triggered for the wrong reasons.
 Warn if student uses an unexpected variable name?
 If this is ticked, all variable names used in the student’s are checked against the list you provide.
The first variable name which is not in the list will trigger a warning.
You can use this option to prevent students incorrectly entering answers such as
xy
, which is interpreted as a single variable, when they meanx*y
, the product of two variables.  Expected variable names
 Variable names in this list will not prompt the “unexpected variable name” warning when the student uses them.
 Minimum length restriction
 If the student’s answer contains fewer than this many characters, the penalty is applied. A value of zero means no restriction is applied. See the comment above on how the length is calculated.
 Maximum length restriction
 If the student’s answer contains more than this many characters, the penalty is applied.
A value of zero means no restriction is applied.
The student’s answer is tidied up slightly so that things like extra or missing space characters don’t affect the calculated length.
All spaces are removed, and then spaces are inserted between binary operations.
For example, the answer
1+x
(three characters) is marked as1 + x
(five characters).  Required strings
 If the student’s answer doesn’t contain all of these strings, the penalty is applied.
 Forbidden strings
 If the student’s answer contains any of these strings, the penalty is applied.
Accuracy
These settings define the range of points over which the student’s answer will be compared with the correct answer, and the method used to compare them.
 Checking type
The rule to use to compare the student’s answer with the correct answer. In the lines below, \(x\) represents the value of the student’s answer at a particular point and \(y\) represents the value of the correct answer, while \(\delta\) is the value of the checking accuracy property.
 Absolute difference. Fail if \(\left xy \right > \delta\).
 Relative difference. Fail if \(\left \frac{x}{y}  1 \right > \delta\).
 Decimal points. \(x\) and \(y\) are rounded to \(\delta\) decimal places, and the test fails if the rounded values are unequal.
 Significant figures. \(x\) and \(y\) are rounded to \(\delta\) significant figures, and the test fails if the rounded values are unequal.
 Checking accuracy
 The parameter for the checking type.
 Points to check
 The number of comparisons to make between the student’s answer and the correct answer.
 Maximum no. of failures
 If the comparison fails this many times or more, the student’s answer is marked as wrong.
 Checking range start
 The minimum value sample points can take.
 Checking range end
 The maximum value sample points can take.
This part type provides the following properties to the settings
object:

correctAnswer
The Correct answer to the question.

checkingType
¶ The Checking type setting, representing the name of the checking function to use. One of
"absdiff"
,"reldiff"
,"dp"
or"sigfig"
. Seeresultsequal()
.

checkingAccuracy
¶ See Checking accuracy.

failureRate
¶

vsetRangeStart
¶ See Checking range start.

vsetRangeEnd
¶ See Checking range end.

vsetRangePoints
¶ See Points to check.

maxLength
¶ The maximum length, in characters, of the student’s answer, as set in Maximum length restriction.

maxLengthPC
¶ The proportion of credit awarded if the student’s answer is too long.

maxLengthMessage
¶ Message to add to marking feedback if the student’s answer is too long.

minLength
¶ The minimum length, in characters, of the student’s answer, as set in Minimum length restriction.

minLengthPC
¶ The proportion of credit to award if the student’s answer is too short.

minLengthMessage
¶ Message to add to the marking feedback if the student’s answer is too short.

mustHave
¶ A list of strings which must be present in the student’s answer, as set in Required strings.

mustHavePC
¶ The proportion of credit to award if any musthave string is missing.

mustHaveMessage
¶ Message to add to the marking feedback if the student’s answer is missing a musthave string.

mustHaveShowStrings
¶ Tell the students which strings must be included in the marking feedback, if they’re missing a musthave?

notAllowed
¶ A list of strings which must not be present in the student’s answer, as set in Forbidden strings.

notAllowedPC
¶ The proportion of credit to award if any notallowed string is present.

notAllowedMessage
¶ Message to add to the marking feedback if the student’s answer contains a notallowed string.

notAllowedShowStrings
¶ Tell the students which strings must not be included in the marking feedback, if they’ve used a notallowed string?