Difference between revisions of "PointAnswers1"

From WeBWorK_wiki
Jump to navigation Jump to search
(PGML example link)
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:
   
 
[[File:PointAnswers1.png|300px|thumb|right|Click to enlarge]]
 
[[File:PointAnswers1.png|300px|thumb|right|Click to enlarge]]
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
+
<p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;">
 
This PG code shows how to evaluate answers that are points or lists of points.
 
This PG code shows how to evaluate answers that are points or lists of points.
 
</p>
 
</p>
* Download file: [[File:PointAnswers1.txt]] (change the file extension from txt to pg when you save it)
 
  +
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/PointAnswers1.pg FortLewis/Authoring/Templates/Precalc/PointAnswers1.pg]
* File location in NPL: <code>FortLewis/Authoring/Templates/Precalc/PointAnswers1.pg</code>
 
  +
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Precalc/PointAnswers1_PGML.pg FortLewis/Authoring/Templates/Precalc/PointAnswers1_PGML.pg]
 
   
 
<br clear="all" />
 
<br clear="all" />
Line 169: Line 168:
   
 
[[Category:Top]]
 
[[Category:Top]]
[[Category:Authors]]
+
[[Category:Sample Problems]]
  +
[[Category:Subject Area Templates]]

Revision as of 21:24, 13 June 2015

Answer is a Point or a List of Points

Click to enlarge

This PG code shows how to evaluate answers that are points or lists of points.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"AnswerFormatHelp.pl",
"contextLimitedPoint.pl",
);

TEXT(beginproblem());

Initialization: We only need to load contextLimitedPoint.pl if we want to prevent operations between points.

Context("LimitedPoint");

$f = Compute("x^2-1");

$xint = List( Point("(1,0)"), Point("(-1,0)") );

$yint = List( Point("(0,-1)") );

Setup: We could have used Context("Point"); instead, which would allow mathematical operations between points (such as adding points as if they were vectors). The x-intercepts are clearly a list of points. We used a list with only one element for the y-intercepts so that a student who mistakenly enters two points will be told their second point is incorrect. If we did not use a list for the y-intercepts, a student who enters two points would be given an error message instead.

Context()->texStrings;
BEGIN_TEXT
Enter the x-intercept(s) and y-intercept(s)
of \( y = $f \).  Enter a point as \( (a,b) \),
including the parentheses.  If there is more 
than one correct answer, enter a comma 
separated list of points.
$BR
$BR
x-intercept(s): \{ ans_rule(20) \}
\{ AnswerFormatHelp("points") \}
$BR
y-intercept(s): \{ ans_rule(20) \}
\{ AnswerFormatHelp("points") \}
END_TEXT
Context()->normalStrings;

Main Text: Be sure to tell students the proper syntax for how to enter their answers.

$showPartialCorrectAnswers = 1;

ANS( $xint->cmp() );

ANS( $yint->cmp() );

Answer Evaluation:

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT();

Solution:

Templates by Subject Area