WeBWorK Main Forum

test_points vs. limits in Formula objects

test_points vs. limits in Formula objects

by William Boshuck -
Number of replies: 2
I've encountered the following behaviour.

Consider the problem below.

With test_points in effect (i.e, that line uncommented, and the
line specifying limits commented) if a student enters a list of
expressions they get the response shown below the problem,
which suggests to them that there is an error in the system or
in the problem. (An answer that consists of a single expression
is graded as I would expect - correct if the expression is correct
and incorrect otherwise.) Also, the answer table is blank, apart
from the Result box (incorrect).

With limits in effect (i.e., that line uncommented, and the line
specifying test_points commented) answers that are single
expressions or lists of expressions are graded as I would expect
(correct if the answer is a single expression that is correct and
incorrect otherwise).

We are running PG 2.4.7 with some patches (which exactly
I don't know; I do know that AnswerChecker.pm is in sync
with -HEAD, because I wondered about that and asked the
sysadmin to update it).

I have done this with and without square brackets around the entries
of test_points (initially with, in accord with UsingMathObjects.pod).
The error message is the same in each case.

Thanks in advance for any information about this
behaviour.

-wb

Follows the problem.

DOCUMENT();
loadMacros(
'PGstandard.pl',
'MathObjects.pl'
);
$a = random(2,9);
$aa = $a**2;
$f = Formula("cos(arcsin($a/x))");
Context()->functions->disable('Trig');
$fsimp = Formula("sqrt(x^2 - $aa)/abs(x)");
$fsimp->{test_points} = [[-$a-2], [-$a-1], [-$a], [$a], [$a+1], [$a+2]];
#$fsimp->{limits} = [-2*$a, -$a];
TEXT(beginproblem());
Context()->texStrings;
BEGIN_TEXT
Simplify the following expression:
\( $f = \) \{ ans_rule(25) \}
END_TEXT
Context()->normalStrings;
ANS($fsimp->cmp);
ENDDOCUMENT();

Follows the output if, e.g., a student enters

sqrt(x^2-$aa)/x, -sqrt(x^2-$aa)/x

(with the generated value of $aa) as an answer
when test_points is specified.
  • Error in Translator.pm::process_answers: Answer AnSwEr1: |sqrt(x^2-49)/x, -sqrt(x^2-49)/x|
  • Can't generate enough valid points for comparison at line 562 of [PG]/lib/AnswerHash.pm
    Died within AnswerEvaluator::evaluate called at line 1 of (eval 1844)
  • Error in Translator.pm::process_answers: Answer AnSwEr1:
  • Answer evaluators must return a hash or an AnswerHash type, not type || at /dat/webwork/pg/lib/WeBWorK/PG/Translator.pm line 1174
  • Use of uninitialized value $answerScore in numeric ge (>=) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 249.
  • Use of uninitialized value $studentAnswer in pattern match (m//) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.
  • Use of uninitialized value $answerScore in numeric ge (>=) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 250.
  • Use of uninitialized value $answerScore in numeric ge (>=) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.
  • Use of uninitialized value $answerScore in numeric gt (>) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 251.
  • Use of uninitialized value $answerScore in numeric gt (>) at /dat/webwork/webwork2/lib/WeBWorK/ContentGenerator/Problem.pm line 254.
In reply to William Boshuck

Re: test_points vs. limits in Formula objects

by Davide Cervone -
OK, this was being caused by the type-checking routine that determines if the output of the two formulas is compatible. That is done by evaluating the formula to get typical output values (and the types of those values are compared). That computation was not respecting the test_points, and that's were the error came from. I have fixed it in the HEAD version of pg/lib/AnswerChecker.pm and pg/lib/Value/Formula.pm. You will need to update those to take advantage of the fix.

Once the fix in place, when a student giver a list of answers, he or she will receive the usual error for when a list is entered but a single answer is expected. If you wish to provide a different error message, you can use answerHints.pl to remap it (or a custom post-filter).

Hope that helps.

Davide