Nandor's 24-Jan-2009 example uses init_graph which probably needs PGgraphmacros.pl to be loaded. I do like having the student answer plotted. I would add the following:
$PAR
Note: the ${BBOLD}Preview Answer${EBOLD} button
will show a figure with original curve (in blue) together
with your function (plotted in green).
My experiments with Davide's first revision, 26-Jan-2009, often had an incorrect plot of the student answer. E.g., with problem having 2^x as correct answer, I answered 3^x - 2 and viewed a green curve corresponding to 2 + 2^(-x) = 2 + (1/2)^x. Some earlier malfunctions had led me to guess $h retained the value from first student attempt, but this particular experiment had result inconsistent with that conjecture.
Davide's second version is even more instructive, thanks.
WeBWorK Problems
must_have_filter
This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day