Difference between revisions of "WeightedGrader"
Jump to navigation
Jump to search
(New page: <h2>Matching Problems That Have Static Graphic Images</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> <em>This code shows how to assign different weights (pe...) |
m |
||
Line 90: | Line 90: | ||
<td style="background-color:#eeccff;padding:7px;"> |
<td style="background-color:#eeccff;padding:7px;"> |
||
<p> |
<p> |
||
− | Answer Evaluation: Use WEIGHTED_ANS( evaluator, weight) instead of ANS( evaluator ). |
+ | 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 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. |
The weights should be positive integers that sum to 100. |
Revision as of 00:46, 2 November 2009
Matching Problems That Have Static Graphic Images
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("x^2 * t"); $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 \( x^2 t \): \{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( ($answer2)->cmp(), 20 ); ENDDOCUMENT(); |
Answer Evaluation: Use |