Difference between revisions of "WeightedGrader"
m |
m |
||
Line 13: | Line 13: | ||
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
− | <em><b>Standard Problem Grader:</b> give full credit if all answers are correct and zero credit |
+ | <em><b>Standard Problem Grader:</b> give full credit if all answers are correct and zero credit otherwise. |
</em> |
</em> |
||
</p> |
</p> |
||
Line 170: | Line 170: | ||
</tr> |
</tr> |
||
</table> |
</table> |
||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
+ | <em><b>Weighted Grader with Credit Answer Option:</b> assign different weights (percentages) to each answer in a problem, and provide one answer blank that, if correct, will supersede all other answer blanks and award full credit. |
||
+ | </em> |
||
+ | </p> |
||
+ | |||
+ | <table cellspacing="0" cellpadding="2" border="0"> |
||
+ | <tr valign="top"> |
||
+ | <th> PG problem file </th> |
||
+ | <th> Explanation </th> |
||
+ | </tr> |
||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#ddffdd;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | DOCUMENT(); |
||
+ | |||
+ | loadMacros( |
||
+ | "PGbasicmacros.pl", |
||
+ | "PGchoicemacros.pl", |
||
+ | "PGanswermacros.pl", |
||
+ | "PGauxiliaryFunctions.pl", |
||
+ | "weightedGrader.pl" |
||
+ | ); |
||
+ | |||
+ | install_weighted_grader(); |
||
+ | $showPartialCorrectAnswers = 1; |
||
+ | |||
+ | TEXT(beginproblem()); |
||
+ | </pre> |
||
+ | </td> |
||
+ | <td style="background-color:#ccffcc;padding:7px;"> |
||
+ | <p> |
||
+ | Initialization: We need to include the <code>weightedGrader.pl</code> macro file and immediately install it using <code>install_weighted_grader();</code>. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | # problem set up |
||
+ | $a = random(2,9,1); |
||
+ | $region = "x = $a y, \quad y^3 = x \quad (\mbox{with } y\geq 0)"; # already displaymath mode |
||
+ | $lineofrotation = "the y-axis"; |
||
+ | |||
+ | |||
+ | </pre> |
||
+ | </td> |
||
+ | <td style="background-color:#ffffcc;padding:7px;"> |
||
+ | <p> |
||
+ | Set-up: Everything is as usual. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | BEGIN_TEXT |
||
+ | |||
+ | The volume of the solid obtained by rotating the region enclosed by |
||
+ | \[ |
||
+ | $region |
||
+ | \] |
||
+ | about $lineofrotation can be computed using the method of disks or washers via an integral |
||
+ | $BR |
||
+ | $BCENTER |
||
+ | \( \displaystyle V = \int_a^b \) |
||
+ | \{NAMED_ANS_RULE('optional1',50)\} |
||
+ | \{NAMED_POP_UP_LIST('optional2',['?','dx','dy'])\} |
||
+ | $ECENTER |
||
+ | $BR |
||
+ | with limits of integration |
||
+ | \( a = \) \{NAMED_ANS_RULE('optional3',10)\} and |
||
+ | \( b = \) \{NAMED_ANS_RULE('optional4',10)\}. |
||
+ | $BR |
||
+ | $BR |
||
+ | The volume is \( V = \) \{ans_rule(50)\} cubic units. |
||
+ | |||
+ | $PAR |
||
+ | ${BITALIC}Note: You can earn full credit if the last question |
||
+ | is correct and all other questions are either blank or correct.${EITALIC} |
||
+ | |||
+ | END_TEXT |
||
+ | </pre> |
||
+ | <td style="background-color:#ffcccc;padding:7px;"> |
||
+ | <p> |
||
+ | Main Text: Answer boxes are as usual. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | <tr valign="top"> |
||
+ | <td style="background-color:#eeddff;border:black 1px dashed;"> |
||
+ | <pre> |
||
+ | # answers |
||
+ | $integrand="pi*($a*y)**2 - pi*(y**3)**2"; |
||
+ | $differential="dy"; |
||
+ | $lowerlimit="0"; |
||
+ | $upperlimit="sqrt($a)"; |
||
+ | $volume = ((4*pi)/21)*($a**3.5); |
||
+ | |||
+ | # answer weights for integrand, differential, lowerlimit, upperlimit, and volume |
||
+ | @weights=(50,2,4,4,40); |
||
+ | |||
+ | # answer evaluators |
||
+ | @ans_eval=( |
||
+ | fun_cmp($integrand, vars=>['x','y'], limits=>[[1,2],[1,2]]), |
||
+ | str_cmp($differential), |
||
+ | num_cmp($lowerlimit), |
||
+ | num_cmp($upperlimit), |
||
+ | num_cmp($volume) |
||
+ | ); |
||
+ | |||
+ | NAMED_WEIGHTED_ANS('optional1', @ans_eval[0], @weights[0]); |
||
+ | NAMED_WEIGHTED_ANS('optional2', @ans_eval[1], @weights[1]); |
||
+ | NAMED_WEIGHTED_ANS('optional3', @ans_eval[2], @weights[2]); |
||
+ | NAMED_WEIGHTED_ANS('optional4', @ans_eval[3], @weights[3]); |
||
+ | CREDIT_ANS(@ans_eval[4],['optional1','optional2','optional3','optional4'],@weights[4]); |
||
+ | |||
+ | COMMENT('Gives partial credit for correct answers to initial questions |
||
+ | or full credit for answering only the the final question correctly.'); |
||
+ | |||
+ | ENDDOCUMENT(); |
||
+ | </pre> |
||
+ | <td style="background-color:#eeccff;padding:7px;"> |
||
+ | <p> |
||
+ | Answer Evaluation: Use <code>WEIGHTED_ANS( evaluator, weight );</code> instead of <code>ANS( evaluator );</code>. |
||
+ | The code given assigns 40% to each of the first two answers, and 20% to the last answer. |
||
+ | The weights should be positive integers that sum to 100. |
||
+ | </p> |
||
+ | </td> |
||
+ | </tr> |
||
+ | </table> |
||
+ | |||
+ | |||
Revision as of 17:12, 26 November 2009
Weighted Graders
If a question has n answer blanks, the default weight for each answer is 1/n. We describe several different ways to weight answers differently.
- The standard problem grader assigns full credit if all answers are correct, and zero credit otherwise. This all-or-nothing grader should always be used for matching, multiple choice, and true / false questions, otherwise students will be able to deduce how many answers are correct by the partial credit reported by webwork.
- The weighted grader allows you to assign a weight to each answer blank in a problem.
- The weighted grader with the credit answer option allows you to specify one answer blank to be the final answer which, if answered correctly, will provide full credit for all other answer blanks in the problem. (This is not yet documented here.)
Standard Problem Grader: give full credit if all answers are correct and zero credit otherwise.
PG problem file | Explanation |
---|---|
####################### # Initialization loadMacros("PGanswermacros.pl"); # Usual 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()); |
Initialization: Be sure to load
Answer Evaluation: We use
|
Weighted Grader: assign different weights (percentages) to each answer in a problem.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PG.pl", "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "PGgraphmacros.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 |
Weighted Grader with Credit Answer Option: assign different weights (percentages) to each answer in a problem, and provide one answer blank that, if correct, will supersede all other answer blanks and award full credit.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGbasicmacros.pl", "PGchoicemacros.pl", "PGanswermacros.pl", "PGauxiliaryFunctions.pl", "weightedGrader.pl" ); install_weighted_grader(); $showPartialCorrectAnswers = 1; TEXT(beginproblem()); |
Initialization: We need to include the |
# problem set up $a = random(2,9,1); $region = "x = $a y, \quad y^3 = x \quad (\mbox{with } y\geq 0)"; # already displaymath mode $lineofrotation = "the y-axis"; |
Set-up: Everything is as usual. |
BEGIN_TEXT The volume of the solid obtained by rotating the region enclosed by \[ $region \] about $lineofrotation can be computed using the method of disks or washers via an integral $BR $BCENTER \( \displaystyle V = \int_a^b \) \{NAMED_ANS_RULE('optional1',50)\} \{NAMED_POP_UP_LIST('optional2',['?','dx','dy'])\} $ECENTER $BR with limits of integration \( a = \) \{NAMED_ANS_RULE('optional3',10)\} and \( b = \) \{NAMED_ANS_RULE('optional4',10)\}. $BR $BR The volume is \( V = \) \{ans_rule(50)\} cubic units. $PAR ${BITALIC}Note: You can earn full credit if the last question is correct and all other questions are either blank or correct.${EITALIC} END_TEXT |
Main Text: Answer boxes are as usual. |
# answers $integrand="pi*($a*y)**2 - pi*(y**3)**2"; $differential="dy"; $lowerlimit="0"; $upperlimit="sqrt($a)"; $volume = ((4*pi)/21)*($a**3.5); # answer weights for integrand, differential, lowerlimit, upperlimit, and volume @weights=(50,2,4,4,40); # answer evaluators @ans_eval=( fun_cmp($integrand, vars=>['x','y'], limits=>[[1,2],[1,2]]), str_cmp($differential), num_cmp($lowerlimit), num_cmp($upperlimit), num_cmp($volume) ); NAMED_WEIGHTED_ANS('optional1', @ans_eval[0], @weights[0]); NAMED_WEIGHTED_ANS('optional2', @ans_eval[1], @weights[1]); NAMED_WEIGHTED_ANS('optional3', @ans_eval[2], @weights[2]); NAMED_WEIGHTED_ANS('optional4', @ans_eval[3], @weights[3]); CREDIT_ANS(@ans_eval[4],['optional1','optional2','optional3','optional4'],@weights[4]); COMMENT('Gives partial credit for correct answers to initial questions or full credit for answering only the the final question correctly.'); ENDDOCUMENT(); |
Answer Evaluation: Use |