Difference between revisions of "AnswerBlankInExponent1"

From WeBWorK_wiki
Jump to navigation Jump to search
(PGML example link)
(add historical tag and give links to newer problems.)
 
(3 intermediate revisions by the same user not shown)
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/Algebra/AnswerBlankInExponent.html a newer version of this problem]</p>
  +
  +
 
<h2>Answer Blank in the Exponent</h2>
 
<h2>Answer Blank in the Exponent</h2>
   
Line 5: Line 10:
 
This PG code shows how to put an answer blank in the exponent.
 
This PG code shows how to put an answer blank in the exponent.
 
</p>
 
</p>
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1.pg FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1.pg]
+
<!-- * File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1.pg FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1.pg] -->
 
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1_PGML.pg FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1_PGML.pg]
 
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1_PGML.pg FortLewis/Authoring/Templates/Algebra/AnswerBlankInExponent1_PGML.pg]
   
Line 16: Line 21:
   
 
<tr valign="top">
 
<tr valign="top">
<th> PG problem file </th>
+
<th style="width: 40%"> PG problem file </th>
 
<th> Explanation </th>
 
<th> Explanation </th>
 
</tr>
 
</tr>
Line 43: Line 48:
   
 
loadMacros(
 
loadMacros(
"PGstandard.pl",
+
"PGstandard.pl",
"MathObjects.pl",
+
"MathObjects.pl",
"PGcourse.pl",
+
"unionTables.pl",
"unionTables.pl",
+
"PGML.pl",
  +
"PGcourse.pl"
 
);
 
);
   
Line 109: Line 114:
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<td style="background-color:#ffdddd;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML
BEGIN_TEXT
 
 
Rewrite the following using a single exponent.
 
Rewrite the following using a single exponent.
$BR
 
  +
[$showpower]***
$BR
 
  +
END_PGML
$showpower
 
END_TEXT
 
Context()->normalStrings;
 
 
</pre>
 
</pre>
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
Line 139: Line 140:
 
<p>
 
<p>
 
<b>Answer Evaluation:</b>
 
<b>Answer Evaluation:</b>
  +
  +
Because the answer blanks are traditional <code>ans_rule</code>, then we need to use this style of answer checking.
 
</p>
 
</p>
 
</td>
 
</td>
Line 148: Line 151:
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<td style="background-color:#ddddff;border:black 1px dashed;">
 
<pre>
 
<pre>
Context()->texStrings;
 
  +
BEGIN_PGML_SOLUTION
BEGIN_SOLUTION
 
${PAR}SOLUTION:${PAR}
 
 
Solution explanation goes here.
 
Solution explanation goes here.
END_SOLUTION
 
  +
END_PGML_SOLUTION
Context()->normalStrings;
 
 
COMMENT('MathObject version.');
 
   
 
ENDDOCUMENT();
 
ENDDOCUMENT();

Latest revision as of 04:40, 18 July 2023

This article has been retained as a historical document. It is not up-to-date and the formatting may be lacking. Use the information herein with caution.

This problem has been replaced with a newer version of this problem


Answer Blank in the Exponent

Click to enlarge

This PG code shows how to put an answer blank in the exponent.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros(
  "PGstandard.pl",
  "MathObjects.pl",
  "unionTables.pl",
  "PGML.pl",
  "PGcourse.pl"
);

TEXT(beginproblem());

Initialization:

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 some code to display the answer blanks nicely in different modes, which you shouldn't need to change except perhaps the width for each answer blank.

BEGIN_PGML
Rewrite the following using a single exponent.
[$showpower]***
END_PGML

Main Text: We insert the nicely formatted answer blanks using $showpower.

$showPartialCorrectAnswers = 1;

ANS( $base->cmp() );
ANS( $exponent->cmp() );

Answer Evaluation: 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:

Templates by Subject Area