WeBWorK Problems

Bug in Set cmp? / Ellipsis in answer

Bug in Set cmp? / Ellipsis in answer

by Alex Jordan -
Number of replies: 1
I am having a problem that I have tried to boil down to the minimal working example below. For a calculus course, I would like students to enter the first several values of a sequence. I would like them to use braces, as in {1, 2, 3}, to enter their answer. I can force this by defining the answer to be a Set MathObject, with braces as the corresponding parens.

I am unable to change the list_type to be "a sequence" rather than "an interval, set, or union". This means that if students enters something like "x" or "1, 2, 3", rather than "{1, 2, 3}", they are given confusing error messages:
Your answer isn't an interval, set or union
I would want this to say
Your answer isn't a sequence

I believe I am passing the appropriate parameters to the cmp call, so I have begun to wonder if there is a typo somewhere in the parser for the Set object. My MWE is short, so I'll just paste it here rather than attach it

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
);
##############################################
Context("Numeric");
Context()->parens->set('{'=>{type=>Set});
$answer = Set(1,2,3);
##############################################
Context()->texStrings;
BEGIN_TEXT
Enter the sequence \($LBRACE 1, 2, 3$RBRACE\).$PAR
\{ans_rule(10)\}
END_TEXT
##############################################
ANS($answer->cmp(list_type=>"a sequence",ordered=>1));
ENDDOCUMENT();

Second question, related to this problem: is there a relatively straightforward way to implement an ellipsis as part of the answer to a question like this? I tried removing . as an operator and making ... a String in the context, but then I was unable to form a list of mixed type, e.g. {1, 2, 3, ...} has Reals and a String. I tried making ... into a Real constant, but ... is an illegal name for a constant.

In reply to Alex Jordan

Re: Bug in Set cmp? / Ellipsis in answer

by Alex Jordan -
Answered my own question: I should pass
cmp_class => "a sequence"
to the answer checker. (I think I will continue to pass list_type =>"a sequence" to the answer checker as well.)


I'm still interested in ideas for an ellipsis.