Difference between revisions of "WeightedGrader"

From WeBWorK_wiki
Jump to navigation Jump to search
m
m
Line 2: Line 2:
   
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
 
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
<em>This code shows how to assign different weights (percentages) to each answer in a problem.
+
<em>This code shows how give full credit if all answers are correct and zero credit if some answers are incorrect.
 
</em>
 
</em>
 
</p>
 
</p>
Line 9: Line 9:
 
[[IndexOfProblemTechniques|Problem Techniques Index]]
 
[[IndexOfProblemTechniques|Problem Techniques Index]]
 
</p>
 
</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:#ffdddd;border:black 1px dashed;">
  +
<pre>
  +
install_problem_grader(~~&std_problem_grader);
  +
  +
$showPartialCorrectAnswers = 0;
  +
  +
ANS($a->cmp());
  +
ANS($b->cmp());
  +
ANS($c->cmp());
  +
</pre>
  +
<td style="background-color:#ffcccc;padding:7px;">
  +
<p>
  +
Answer Evaluation: We use
  +
<code>install_problem_grader(~~&std_problem_grader);</code> to give full
  +
credit only if all answers are correct, and zero credit otherwise. We should
  +
probably also hide feedback on whether answers are partially correct or
  +
not. This problem grader is recommended for true / false and multiple choice
  +
questions to prevent students from guessing and receiving either feedback or
  +
partial credit that tells them whether their guess was correct.
  +
</p>
  +
</td>
  +
</tr>
  +
</table>
  +
  +
  +
  +
  +
  +
  +
  +
  +
<p style="background-color:#eeeeee;border:black solid 1px;padding:3px;">
  +
<em>This code shows how to assign different weights (percentages) to each answer in a problem.
  +
</em>
  +
</p>
  +
 
<table cellspacing="0" cellpadding="2" border="0">
 
<table cellspacing="0" cellpadding="2" border="0">
 
<tr valign="top">
 
<tr valign="top">

Revision as of 17:16, 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.

Problem Techniques Index


PG problem file Explanation
install_problem_grader(~~&std_problem_grader);

$showPartialCorrectAnswers = 0;

ANS($a->cmp());
ANS($b->cmp());
ANS($c->cmp());

Answer Evaluation: We use install_problem_grader(~~&std_problem_grader); to give full credit only if all answers are correct, and zero credit otherwise. We should probably also hide feedback on whether answers are partially correct or not. This problem grader is recommended for true / false and multiple choice questions to prevent students from guessing and receiving either feedback or partial credit that tells them whether their guess was correct.





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 weightedGrader.pl macro file and immediately install it using install_weighted_grader();.

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_ANS( evaluator, weight ); instead of ANS( evaluator );. 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.



Problem Techniques Index