- If student enters a number -> an error message saying "Your answer is not a point"
- If a student enters a point -> no extra error message, just "Incorrect"
Below is what I have so far. When I type a number in I get the desired message of "Your answer isn't a point", but the problem is that when I enter a point, the error message that still pops up is "Your answer isn't a number (it looks like a point)".
Any help would be greatly appreciated.
Thanks,
*Brittni
###########################
# Initialization
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",,
"parserAssignment.pl",
"AnswerFormatHelp.pl",
"PGML.pl",
"PGcourse.pl",
"contextLimitedPoint.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
$refreshCaschedImages = 1;
##########################
# Setup
Context("Numeric");
Context()->variables->add(t => 'Real');
##Random variables for slope ##
$a=list_random(0,1);
##formulas for x(t) and y(t)##
Context()->noreduce('(-x)-y','(-x)+y');
$x_t=Formula("t+(1/t)")->reduce;
$y_t=Formula("t-(1/t)")->reduce;
Context("LimitedPoint"); ## Maybe this is needed to allow students to enter a point without an error message, even though the answer is "none" here.
$blank = Point("(1,2)");
$pointChecker = sub {
my ($correct,$student,$ansHash) = @_;
Value->Error("Your answer isn't a point.") unless $student->class eq "Point";
return 1;
};
#################################
##Main text##
BEGIN_PGML
Given the parametric curve
[` \displaystyle x(t)=[$x_t], \hspace{.25cm} y(t)=[$y_t] `].
Find all the points on the curve at which the slope of the tangent line is [`m=[$a] `].
Enter your solution as a comma separated list of ordered pairs [`(x,y)`] or if there are no points on the curve at which the slope of the tangent line is the given slope enter NONE.
[_______________________________] [@ AnswerFormatHelp("points") @]*
END_PGML
ANS(String("NONE")->cmp(checker=>$pointChecker)->withPostFilter(sub {
my $ans = shift;
$ans->{ans_message} = "Incorrect"
if $ans->{ans_message} eq "Your answer isn't a number (it looks like a point)";
return $ans;
}));
#################################
# Solution
#BEGIN_PGML_SOLUTION
#Solution explanation goes here.
#END_PGML_SOLUTION
COMMENT('Uses PGML.');
ENDDOCUMENT();