## WeBWorK Problems

### Interval context + operator correct answer string

by Alex Jordan -
Number of replies: 1
In the MWE below, in the Interval context we Compute two intervals. Then use the + operator to union them. Then, printing the result in PGML is fine: we see the correct result from unioning the two original intervals: (-1, 2].

When the same MathObject is used as the answer to an answer blank, WeBWorK gives credit for (-1, 2]. (Good.)

But when you look for the correct answer in the results table, it shows "(0, 2]", which is the first interval used in the union. So I think that something is not working with the + operator on two intervals, for creating the correct_ans_latex_string that the results table uses.

If I change from using the + operator to using Union($range1,$range2), then this issue goes away.

Here is the MWE:

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
);

##############################################

Context("Interval");

$range1 = Compute("(0,2]");$range2 = Compute("(-1,1)");

$range =$range1 + $range2; ############################################## BEGIN_PGML [[$range]] is [______________]{$range}. END_PGML ############################################## ENDDOCUMENT(); In reply to Alex Jordan ### Re: Interval context + operator correct answer string by Davide Cervone - I think that something is not working with the + operator on two intervals, for creating the correct_ans_latex_string that the results table uses. You are right, the correct_ans_latex_string is to correct. The sum should not actually have correct_ans_latex_string set, but it is inheriting the one from the (0,2] accidentally. One solution work-around for now would be to use $range = ($range1 +$range2)->inherit;


(I know that sounds wrong, but it is the right thing.)

I wil make a fix and submit a pull request.l