Answer blank in the exponent
Download file: AnswerBlankInExponent.pg
DOCUMENT(); loadMacros('PGstandard.pl', 'PGML.pl', 'PGcourse.pl');
Preamble
These standard macros need to be loaded.Context()->variables->are(a => 'Real', b => 'Real'); $n = random(3, 9); # TeX $expression = "a^{$n} b^{$n}"; # MathObjects $base = Formula("a*b"); $exponent = Formula("$n"); # Display exponents nicely $exp = MODES( HTML => "<span>\(\displaystyle $expression= \Big(\)" . ans_rule(4) . '\(\Big)\)</span><span style="vertical-align: 12pt;">' . ans_rule(4) . '</span>', TeX => "\( \displaystyle $expression = (" . ans_rule(4) . ")^{" . ans_rule(4) . "}\)" );
Setup
We want the only variables to be a
and b
and choose a random power.
The exponential layout is in HTML using a pair of adjacent span
elements with the right one shifted up using the CSS style vertical-align
. In hardcopy mode, we use the LaTeX exponent.
BEGIN_PGML Rewrite the following using a single exponent. [$exp]* END_PGML
Statement
We insert exponential stored as $exp
.
ANS($base->cmp()); ANS($exponent->cmp());
Answer
Because the answer blanks are traditional ans_rule, then we need to use this style of answer checking.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.