WeBWorK Main Forum

Issue with the Limited Polynomial Context

Issue with the Limited Polynomial Context

by Rick Lynch -
Number of replies: 1

Hi Everyone! I believe I have run into an issue with the limited polynomial context in that it accepts answers of the form "constant - (term with variables) + constant" even though there are two constant terms. Can anyone confirm that they also have this issue, and if there is any hope to fixing it? I've included a screenshot of what is going on and the corresponding example code below. Thanks in advance!

DOCUMENT();

loadMacros(
    "PGstandard.pl",
    "MathObjects.pl",
    "PGML.pl",
    "contextLimitedPolynomial.pl",
);

Context("LimitedPolynomial-Strict");
$ans = Compute("-x + 2")->reduce;

BEGIN_PGML

The correct answer is [`-x + 2`].

Enter [`-2 - x + 4 = `] [__]{$ans}. This answer is accepted, but it shouldn't be.

Enter [`-2 + 4 - x = `] [__]{$ans}. However this doesn't work, which is what should happen.

Enter [`-x - 2 + 4 = `] [__]{$ans}. Neither does this, but has a different error message.

END_PGML

ENDDOCUMENT();

Attachment lim_poly_example_ss.PNG
In reply to Rick Lynch

Re: Issue with the Limited Polynomial Context

by Davide Cervone -

You are correct, this is an error. It turns out to be due to the context mishandling negation of constants and variables, so -x + x is also incorrectly allowed.

I have made a pull request to resolve the problem. You could get the updated contextLimitedPolynomial.pl file from there and use that to resolve the issue until the change is part of an official release.