[ww-bugs] Bug 4092: Correct answer is a formula, but any number is also accepted
bugzilla-daemon at webwork.maa.org
bugzilla-daemon at webwork.maa.org
Thu Mar 8 14:12:11 EST 2018
http://bugs.webwork.maa.org/show_bug.cgi?id=4092
Davide P. Cervone <dpvc at union.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dpvc at union.edu
--- Comment #1 from Davide P. Cervone <dpvc at union.edu> 2018-03-08 14:12:11 ---
I suspect the error is in the line
return ($student->D("x") == a*($student*$student + $ksq));
because the "a" in this is not the same as the "a" in the context; here, it is
just a perl string "a". When the student answer is a number, then you get that
string a times a MathObject Real, and the Real tries to convert the "a" to a
number. It gets 0 in that case (that should probably be viewed as a bug in
MathObjects). So the right-hand side is 0. The left is the derivative of the
constant, so is also 0. So that means the value is "correct".
When the student answer is a formula, the right hand side turns the string "a"
into a Formula not a Real, and since "a" is a variable in the Context, it is a
formula "a" times the other stuff, and that produces a formula result, and
everything checks as expected. But is it still bad practice to use a literal
"a" as a string, and it would be better as
return ($student->D("x") == Formula("a*($student*$student + $ksq)"));
for example.
--
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