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();

loadMacros(

"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();

loadMacros(

"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();