Difference between revisions of "WeightedGrader"
Jump to navigation
Jump to search
m |
m |
||
Line 46: | Line 46: | ||
$r = random(2,4,1); |
$r = random(2,4,1); |
||
$answer1 = Real("pi * $r**2"); |
$answer1 = Real("pi * $r**2"); |
||
− | $answer2 = Formula("x |
+ | $answer2 = Formula("($r - 1) * x**2 * t") -> reduce; |
$answer3 = String("A"); |
$answer3 = String("A"); |
||
Line 65: | Line 65: | ||
Enter \( \pi $r^2 \): \{ans_rule(10)\} |
Enter \( \pi $r^2 \): \{ans_rule(10)\} |
||
− | Enter \( |
+ | Enter \( $answer2 \): \{ans_rule(10)\} |
Enter A: \{ans_rule(10)\} |
Enter A: \{ans_rule(10)\} |
||
Revision as of 00:50, 2 November 2009
Weighted Graders
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( ($answer2)->cmp(), 20 ); ENDDOCUMENT(); |
Answer Evaluation: Use |