WeBWorK Main Forum

odd correct answer display

odd correct answer display

by Gavin LaRose -
Number of replies: 7
Hi all,

I'm seeing the following odd behavior: for this problem


$showPartialCorrectAnswers = 1;
$a = random(0,5,1);
$b = $a + 1; 
$error = "ln(x - $a) - (x - $b)";

Context()->flags->set( limits=>[$a, $a+2] );
Enter answer: \{ ans_rule(25) \}

ANS(Compute( $error )->cmp() );

I'm seeing the correct answer, when displayed, displaying as ln(x - 5) - x - 6, which drops the parentheses from the second term. The problem is marked correctly, so it's only in the display of the answer in the correct answer field.

This is in WeBWorK 2.10, PG 2.10, installed in late August. Is this a bug?


In reply to Gavin LaRose

Re: odd correct answer display

by Peter Selinger -
I had the same issue, see http://webwork.maa.org/moodle/mod/forum/discuss.php?d=3785

Didn't receive any replies though. Maybe I posted to the wrong forum.

-- Peter
In reply to Gavin LaRose

Re: odd correct answer display

by Dick Lane -
I saw a similar bad-display, with omission of necessary parentheses, earlier this week.

a)  this error in formatting of a "correct answer" IS a bug
b)  this bug is relatively recent

I reported this via Bugzilla as a WeBWorK bug-- its id is #3519.

I doubt this is a MathJax error.  If the MathJax folk need to be involved, where should this report have been sent?
In reply to Dick Lane

Re: odd correct answer display

by Michael Gage -
This isn't a MathJax error.  It involves MathObjects but it is probably caused inadvertently by some infrastructure cleanup I did earlier this summer. I'll look in to it.  Experimentation indicates that if you use Formula instead of Compute then the parentheses are displayed correctly.

In reply to Michael Gage

Re: odd correct answer display

by Davide Cervone -
I think this one is a MathObjects error, due to changes in Compute() that I made earlier this year. (It is a problem with the code that determines when parentheses are needed for repeated operators of the same precedence.) The new code is not yet in a release version, so it should be fixed for v2.11 before that goes out.
In reply to Davide Cervone

Re: odd correct answer display

by Peter Selinger -
It's not just for operators of the same precedence: also different precedences. For example, in problem Library/FortLewis/Calc3/17-2-Motion-velocity/HGM4-17-2-30-Motion-velocity-acceleration.pg, the answer is displayed as

i + 4k + (t-2) * 3.14159j + 2k

when it should be:

i + 4k + (t-2) * (3.14159j + 2k)

Also, the error occurs in version 2.10, which I am guessing is already released, since we are using it in a local installation.
In reply to Peter Selinger

Re: odd correct answer display

by Davide Cervone -
That is a different error (with the Vector object), that I think has been fixed in 2.11 already. And yes, that is a longer-standing problem that is part of the current 2.10 release (another reason that it is not the same as the issue Gavin reported).