[ww-bugs] Bug 3422: The problem doesn't recognize the correct answer
bugzilla-daemon at webwork.maa.org
bugzilla-daemon at webwork.maa.org
Sun Sep 13 07:07:39 EDT 2015
http://bugs.webwork.maa.org/show_bug.cgi?id=3422
Davide P. Cervone <dpvc at union.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dpvc at union.edu
--- Comment #3 from Davide P. Cervone <dpvc at union.edu> 2015-09-13 07:07:38 ---
Before I explain what is going on, you should note that the problem has been
updated in the OPL, so you may want to get the updated version. Also, you
might want to say what version of WeBWorK/PG you are running, as such issues
may be version dependent. For example, I wasn't able to get the problem to
fail with version 2.10.
In any case, where's what's happening. The problem uses num_cmp(), and
num_cmp() takes a string value that it converts to a number (and the original
string is displayed as the correct answer when requested by the user). If you
pass num_cmp() a number already, it is first converted to a string, then
re-parsed, and converted back into a number.
It is this lat bit that is the source of the issue for you. Your number gets
converted to scientific notation as "3.05175e-5" and then that is parsed and
converted to a number. Note, however, that the letter "e" doesn't men
exponentiation in WeBWorK, it is the base of the natural logarithm e =
2.71828..., so this become "3.05175*e - 5" (you can see that in the correct
answer column from the spacing around the minus sign). That means the
"correct" answer is being corrupted during the number->string->number
conversion.
WeBWorK uses a capital "E" as the exponentiation indicator, so a simple
work-around for now would be to use
ANS(num_cmp(uc($ans), strings=>["DNE"]));
(insert uc(...) around the $ans to force the e to an E). Then update the
library and your copy of WeBWorK/PG at your earliest convenience.
--
Configure bugmail: http://bugs.webwork.maa.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
More information about the webwork-bugs
mailing list