FormulaAnswer1: Difference between revisions
Jump to navigation
Jump to search
Paultpearson (talk | contribs) (Add link to PGML version in OPL) |
(Updated this example to PGML and switched AnswerFormatHelp.pl to helpLink.) |
||
Line 42: | Line 42: | ||
DOCUMENT(); | DOCUMENT(); | ||
loadMacros( | loadMacros('PGstandard.pl','MathObjects.pl','PGML.pl'); | ||
); | |||
TEXT(beginproblem()); | TEXT(beginproblem()); | ||
Line 64: | Line 60: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> | <td style="background-color:#ffffdd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
Context( | Context('Numeric'); | ||
$a = non_zero_random(-9,9,1); | $a = non_zero_random(-9,9,1); | ||
Line 86: | Line 82: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> | <td style="background-color:#ffdddd;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
BEGIN_PGML | |||
Enter [`[$answer1]`]: [____]{$answer1} [@ helpLink('number') @]* | |||
Enter | |||
Enter [`[$answer2]`]: [____]{$answer2} [@ helpLink('formula') @]* | |||
END_PGML | |||
Enter | |||
</pre> | </pre> | ||
<td style="background-color:#ffcccc;padding:7px;"> | <td style="background-color:#ffcccc;padding:7px;"> | ||
<p> | <p> | ||
<b>Main Text:</b> | <b>Main Text:</b> | ||
< | * The <tt>helpLink</tt> command show some additional help for entering values. | ||
</p> | </p> | ||
</td> | </td> | ||
Line 128: | Line 102: | ||
<td style="background-color:#ddddff;border:black 1px dashed;"> | <td style="background-color:#ddddff;border:black 1px dashed;"> | ||
<pre> | <pre> | ||
BEGIN_PGML_SOLUTION | |||
Solution explanation goes here. | Solution explanation goes here. | ||
END_PGML_SOLUTION | |||
ENDDOCUMENT(); | ENDDOCUMENT(); | ||
</pre> | </pre> |
Revision as of 15:51, 10 March 2023
Answer is a Number or a Formula - Try it out

This PG code shows how to write a question whose answer is a number or a formula.
- File location in OPL: FortLewis/Authoring/Templates/Misc/FormulaAnswer1.pg
- PGML location in OPL: FortLewis/Authoring/Templates/Misc/FormulaAnswer1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros('PGstandard.pl','MathObjects.pl','PGML.pl'); TEXT(beginproblem()); |
Initialization: |
Context('Numeric'); $a = non_zero_random(-9,9,1); do { $b = random(2,9,1); } until ( $b != $a ); $answer1 = Compute("$a"); $answer2 = Compute("$a x^($b) + $b")->reduce(); |
Setup:
We use |
BEGIN_PGML Enter [`[$answer1]`]: [____]{$answer1} [@ helpLink('number') @]* Enter [`[$answer2]`]: [____]{$answer2} [@ helpLink('formula') @]* END_PGML |
Main Text:
|
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT(); |
Solution: |