Hello, I am trying to use the Set class and I noticed that the answer checker will not mark the answer wrong if {} is missing. Is there a way to require {} in student's answer? Thank you.
DOCUMENT();
Hello, I am trying to use the Set class and I noticed that the answer checker will not mark the answer wrong if {} is missing. Is there a way to require {} in student's answer? Thank you.
DOCUMENT();
The problem turns out to be in the Union answer checker (which uses the list checker internally, and ends up having accidentally bypassed the type checking that is usually performed).
One solution is to make sure that your checker is using a Set rather than a Union (since the union is a set). That can be done in several ways. Oner is to use Set()
rather than Union()
:
$AUB = Set("$A U $B");
Another would be to use the reduce()
method to simplify the union into a set:
$AUB = Union($A,$B)->reduce;
Another would be to use the overloaded +
operator, which acts as union on operands that are sets:
$AUB = $A + $B;
Any of this will result in $AUB
being a set rather than a union.
A couple of coding suggestions:
You don't need $aString
and $bString
, as PGML will produce the proper output for sets. So you can use
Let [`A = [$A]`], [`B = [$B]`]. Then [`A \cup B = `] [______________________]
I would recommend separate math delimiters for the three expressions above, rather than including the commas and periods within the math. The commas and periods are part of the sentence, not the math, and so it is inappropriate to include them in the math itself.
You don't need to use a separate ANS()
call, but can just put the $AUB
in the PGML. None of the values you set are needed, here.
Let [`A = [$A]`], [`B = [$B]`]. Then [`A \cup B = `] [______________________]{$AUB}
That should resolve your problem.