The three sections of a single expression question are shown here:
<ANSWER ... > <RESPONSES> ... </RESPONSES> <HINTS> ... </HINTS>
The structure of each of these sections is shown here. See below
for explanation of expression syntax and
testing equality.
ANSWER
The form of the <ANSWER...> element is as follows:
<ANSWER ANS=l TOL=t HELP=url>
The <ANSWER...> element automatically generates the proper HTML for the form used by the reader to supply her answer. Only the ANS= attribute is required; the others are optional.
The ANS=l attribute specifies that l is the correct answer for the question.
The tolerance, t, is the relative amount that the supplied answer can be different from the correct one and still be judged correct. By default, TOL=0.0001. See below for an explanation of equality testing.
The HELP="url" attribute is optional. If given, it specifies the URL of a help document, and a link to that is automatically included after the answer form..
<RESPONSES> <WHEN ANS=x> . . . . . . <WHEN CORRECT> . . . . . . <WHEN INCORRECT> . . . . . . </RESPONSES>The <WHEN...> elements specify the conditions under which the following text is to be displayed as a response to a supplied answer.
<WHEN ANS=x> specifies that the following text is to be displayed whenever the reader supplies value x as an answer.
<WHEN CORRECT> specifies that the following text is to be displayed whenever the user selects the correct answer, and no other WHEN clause has been printed.
<WHEN INCORRECT> specifies that the following text is to be displayed whenever the user selects an incorrect answer, and no other WHEN clause has been printed.
All WHEN elements are optional; if none are given then the RESPONSES section need not be given either. In either case, a suitable default response is provided, giving feedback as to whether the selected answer was correct or not.
The following arithmetic functions are available:
A number followed immediately by a variable is taken to mean multiplication. In other words, the expression:
5i + 3jis legal and is equivalent to:
5*i + 3*j
Basically, we just substitute random numbers between 0 and 1 for the variables in the expressions, numerically evaluate them, and compare results, using the tolerance specified in the <ANSWER...> element. Of course, we first ensure that the expressions have exactly the same set of variables.
This method has lots of problems, but it works for simple things.