## WeBWorK Problems

### Allow Non Reduced Unions

by Brittni Lorton -
Number of replies: 1

I would like to allow nonreduced and non simplified unions in some answers. I have looked around and I am struggling to find a way to do this. I can see that by default, Interval context requires simplified unions, but I am trying to find a way to avoid that. I have attempted to add the line

Context()->flags->set(reduceUnions => 0);

but to no avail. I have also attempted to play around with the reduceUnionsForComparision but I also cannot get that to work. Any ideas? Here is a simple example where I would love students to be able to enter either {1,6}U{2,5} OR {1}U{2,5}U{6}

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

#  Initialization

DOCUMENT();

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

);

TEXT(beginproblem());

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

#  Setup

Context("Interval");

$a = Interval("{1}U(2,5)U{6}"); BEGIN_PGML the interval [[$a]] is [_]{$a} END_PGML COMMENT('Uses PGML.'); ENDDOCUMENT(); In reply to Brittni Lorton ### Re: Allow Non Reduced Unions by Brittni Lorton - Never mind, I figured it out! If anyone else wants this the solution I found that is working is using the studentsMustReduceUnions flag. Here is a working example: ########################### # Initialization DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl", ); TEXT(beginproblem()); ########################## # Setup Context("Interval");$a = Interval("{1}U(2,5)U{6}");

BEGIN_PGML

the interval [[$a]] is [_]{($a)->cmp(studentsMustReduceUnions => 0)}

END_PGML

COMMENT('Uses PGML.');

ENDDOCUMENT();