Difference between revisions of "WeightedGrader"
m |
m |
||
Line 19: | Line 19: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
+ | loadMacros("PGanswermacros.pl"); |
||
+ | |||
+ | # usual initialization, setup, and main text go here |
||
+ | |||
+ | # Answer evaluation |
||
+ | |||
install_problem_grader(~~&std_problem_grader); |
install_problem_grader(~~&std_problem_grader); |
||
Line 29: | Line 35: | ||
<td style="background-color:#ffcccc;padding:7px;"> |
<td style="background-color:#ffcccc;padding:7px;"> |
||
<p> |
<p> |
||
− | Answer Evaluation: |
+ | Answer Evaluation: Be sure to load <code>PGanswermacros.pl</code> or |
+ | <code>PGstandard.pl</code> (which loads PGanswermacros.pl). We use |
||
<code>install_problem_grader(~~&std_problem_grader);</code> to give full |
<code>install_problem_grader(~~&std_problem_grader);</code> to give full |
||
credit only if all answers are correct, and zero credit otherwise. We should |
credit only if all answers are correct, and zero credit otherwise. We should |
Revision as of 17:20, 7 November 2009
Weighted Graders
This code shows how give full credit if all answers are correct and zero credit if some answers are incorrect.
PG problem file | Explanation |
---|---|
loadMacros("PGanswermacros.pl"); # usual initialization, setup, and main text go here # Answer evaluation install_problem_grader(~~&std_problem_grader); $showPartialCorrectAnswers = 0; ANS($a->cmp()); ANS($b->cmp()); ANS($c->cmp()); |
Answer Evaluation: Be sure to load |
This code shows how to assign different weights (percentages) to each answer in a problem.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGcourse.pl", "MathObjects.pl", "weightedGrader.pl", ); install_weighted_grader(); TEXT(beginproblem); |
Initialization: We need to include the |
Context("Numeric"); Context()->variables->add(t=>"Real"); Context()->strings->add(A=>{},B=>{}); $r = random(2,4,1); $answer1 = Real("pi * $r**2"); $answer2 = Formula("($r - 1) * x**2 * t") -> reduce; $answer3 = String("A"); |
Set-up: To show how this works with MathObjects, we add some variables and strings to the context. |
Context()->texStrings; BEGIN_TEXT Enter \( \pi $r^2 \): \{ans_rule(10)\} Enter \( $answer2 \): \{ans_rule(10)\} Enter A: \{ans_rule(10)\} END_TEXT Context()->normalStrings; |
Main Text: Answer boxes are as usual. |
$showPartialCorrectAnswers = 0; WEIGHTED_ANS( ($answer1)->cmp(), 40 ); WEIGHTED_ANS( ($answer2)->cmp(), 40 ); WEIGHTED_ANS( ($answer3)->cmp(), 20 ); ENDDOCUMENT(); |
Answer Evaluation: Use |