Difference between revisions of "AnswerInExponent"
Jump to navigation
Jump to search
m (1 revision: import all default namespace pages from old wiki) |
|||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/problem-techniques/AnswerInExponent.html a newer version of this problem]</p> |
||
<h2>Answer Blanks in the Exponent</h2> |
<h2>Answer Blanks in the Exponent</h2> |
||
Latest revision as of 15:50, 20 June 2023
This problem has been replaced with a newer version of this problem
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. |