AnswerInExponent
Jump to navigation
Jump to search
Answer Blanks in the Exponent
This PG code shows how to check student answers that are equations. Note that this is an insertion, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGcourse.pl", "unionTables.pl", ); TEXT(beginproblem()); |
Initialization:
We need to include the macros file |
Context("Numeric")->variables->are(a=>"Real",b=>"Real"); $n = random(3,9,1); # TeX $expression = "a^{$n} b^{$n}"; # MathObjects $base = Formula("a*b"); $exponent = Formula("$n"); # # Display exponents nicely # $w1 = 10; # width of 1st answer blank $w2 = 10; # width of 2nd answer blank Context()->texStrings; if ($displayMode eq 'TeX') { $showpower = "\( \displaystyle $expression = (" . ans_rule($w1) . ")^{" . ans_rule($w2) . "}\)"; } else { $showpower = ColumnTable( "\( \displaystyle $expression = \Big( \) " . ans_rule($w1) . " \( \Big) \)", ans_rule($w2).$BR.$BR, indent => 0, separation => 0, valign => "BOTTOM" ); } Context()->normalStrings; |
Setup: We have a little bit of code to display the answer blanks nicely in different modes. |
Context()->texStrings; BEGIN_TEXT Rewrite the following using a single exponent. $BR $BR $showpower END_TEXT Context()->normalStrings; |
Main Text:
The problem text section of the file is as we'd expect. We insert the nicely formatted answer blanks using |
$showPartialCorrectAnswers = 1; ANS( $base->cmp() ); ANS( $exponent->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |