WeBWorK Problems

Can't convert an empty value to a real number on incorrect interval response

Can't convert an empty value to a real number on incorrect interval response

by Adam Weyhaupt -
Number of replies: 2
Hi again -

When using MathObjects, if a student responds to a question asking for an interval with an incorrect response, they receive the message "Can't convert an Empty Value to a Real Number"

Am I coding something incorrect? Is it possible to coerce Webwork into giving a more meaningful message (to me, it would be preferable to simply say "incorrect").

I've copied below sample code which exhibits the problem.

Thanks,

Adam

---------



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

DOCUMENT();

loadMacros(
"PGstandard.pl", # Standard macros for PG language
"MathObjects.pl",
#"source.pl", # allows code to be displayed on certain sites.
#"PGcourse.pl", # Customization file for the course
);

# Print problem number and point value (weight) for the problem
TEXT(beginproblem());

# Show which answers are correct and which ones are incorrect
$showPartialCorrectAnswers = 1;

##############################################################
#
# Setup
#
#
Context("Numeric");

$pi = Real("pi");

##############################################################
#
# Text
#
#

Context()->texStrings;
BEGIN_TEXT

Let \(r(t)\) be the signed distance of a point from the origin at time \(t\) seconds. Suppose that \( r(t) = 1 + \sin(2t) \). Suppose that the object begin movement at time \(t = 0\) and ceases movement at time \(t = 2\pi\). On what interval is the object's distance from the origin at least \(\frac32\)? Express your answer as an interval. If necessary, use "U" for union.
$BR
\{ans_rule(40)\}
END_TEXT
Context()->normalStrings;

##############################################################
#
# Answers
#
#

Context("Interval");
$int = Compute("[pi/12, 5pi/12] U [13pi/12, 18pi/12]");
ANS($int->cmp());


ENDDOCUMENT();
In reply to Adam Weyhaupt

Re: Can't convert an empty value to a real number on incorrect interval response

by Michael Gage -
Try using Context("Interval"); from the beginning of the problem.

I think that the fact that pi was defined when you are in numeric context
might be causing the response you indicate.

Context("Interval");
$int = Compute("[pi/12, 5pi/12] U [13pi/12, 18pi/12]");
TEXT($int->cmp->evaluate("45")->pretty_print);

Gave me a sensible error message. (pi is automatically defined
in Interval context.):

"Your answer isn't an interval, set or union (it looks like a real number)"
In reply to Adam Weyhaupt

Re: Can't convert an empty value to a real number on incorrect interval response

by Davide Cervone -
This was an error in the MathObjects code for checking unions. I have fixed it in the latest version of pg/lib/Value/AnswerCheckers.pm, which you can obtain from the CVS repository. Thanks for reporting the bug.

Davide