WeBWorK Answer Comparison Macros
This set illustrates WeBWorK procedures for deciding whether a student's answer
is correct or incorrect. A number of standard procedures are provided for handling
numeric, string, and function answers. Also customized procedures can be written by
the professor. Viewing the source of the examples allows you to see how these procedures are
called.
Problem 1 illustrates the various methods of handling numeric answers.
Usually WeBWorK problems allow students to enter expressions involving elementary
functions ( e.g. sin(pi/4) ) which evaluate to a number. Thus for most problems,
students can use WeBWorK as a scientific calculator. More restrictive problems
might demand that the answer be a number, a fraction, or an arithmetic expression
not involving elementary functions.
Problem 2 illustrates the various methods of handling string answers.
String answers might be used in short answer or matching questions. As with numeric
answers, there are several procedures for handling different types of answers.
Problem 3 illustrates the various methods of handling answers involving
functions. If a function can be written in different ways, WeBWorK will accept any
valid way of writing the function. For example sin(t+pi/2) = cos(t) so if cos(t) is
the answer to a question, sin(t+pi/2) would be accepted as a correct answer. Methods
are provided for handling antiderivatives. For example sin(x) and sin(x) + 5 are both
antiderivatives of cos(x) and both (and all others) would be accepted as correct by
WeBWorK.
Problem 4 illustrates the various methods of handling answers involving
units. WeBWorK understands most of the MKS units which might appear in problems (see
units).
For example a student can answer a problem involving time in seconds, minutes, hours, etc.
and a problem involving length in meters, microns, feet, miles, etc.
Problem 5 illustrates an ad hoc answering procedure written for a single problem.
This procedure simply checks whether a student has entered a valid palindrome. The main point
is that it is easy for professors to write their own "answer checking" procedures. If you can write
an algorithm for deciding whether or not a submitted answer is correct, you can use that
algorithm in WeBWorK.
A final reminder: These examples are meant to illustrate the technical capabilities
of WeBWorK, not necessarily as examples of good pedagogy.