PointsInAnswers

From WeBWorK_wiki
Revision as of 01:26, 24 January 2010 by Pearson (talk | contribs) (New page: <h2>Points in Student Answers</h2> <!-- Header for these sections -- no modification needed --> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This PG co...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Points in Student Answers


This PG code shows how to check student answers that are points.

Problem Techniques Index

PG problem file Explanation
DOCUMENT();

loadMacros(
"PGstandard.pl",
"contextLimitedPoint.pl",
"PGcourse.pl",
);

TEXT(beginproblem());

Initialization: We load the contextLimitedPoint.pl macro which automatically loads MathObjects.pl. The LimitedPoint context does not allow operations between points.

Alternatively, instead of loading contextLimitedPoint.pl, we could have loaded MathObjects.pl and parserVectorUtils.pl. This would allow operations, such as addition and subtraction, between points.

Context("LimitedPoint");

$f = Formula("2-x");

$xint = Point("(2,0)");
$yint = Point("(0,2)");

Setup: Everything is as usual.

If we had loaded parserVectorUtils.pl instead, we would use Context("Vector2D"); for two-dimensional space or Context("Vector"); for three-dimensional space.

Context()->texStrings;
BEGIN_TEXT
If \( y = f(x) = $f \), find
the x- and y-intercepts.  Enter your
answers as points \( (a,b) \) that 
include parentheses.
$BR
x-intercept: \{ ans_rule(15) \}
$BR
y-intercept: \{ ans_rule(15) \}
END_TEXT
Context()->normalStrings;

Main Text: The main text section of the file is as we'd expect.

ANS( $xint->cmp() );
ANS( $yint->cmp() );

ENDDOCUMENT();

Answer Evaluation: As is the answer.

Problem Techniques Index