FormulaAnswer1: Difference between revisions
Jump to navigation
Jump to search
(Created page with '<h2>Answer is a Number or a Formula</h2> <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> This PG code shows how to write a question whose answer is a nu…') |
No edit summary |
||
Line 66: | Line 66: | ||
Context("Numeric"); | Context("Numeric"); | ||
$a = | $a = non_zero_random(-9,9,1); | ||
do { $b = random(2,9,1); } until ( $b != $a ); | do { $b = random(2,9,1); } until ( $b != $a ); | ||
$answer1 = Compute("$a"); | $answer1 = Compute("$a"); | ||
$answer2 = Compute("$a x + $b"); | $answer2 = Compute("$a x^($b) + $b"); | ||
</pre> | </pre> | ||
</td> | </td> | ||
Line 76: | Line 76: | ||
<p> | <p> | ||
<b>Setup:</b> | <b>Setup:</b> | ||
We use <code>do { $b = random(2,9,1); } until ( $b != $a );</code> to generate distinct random numbers. | |||
</p> | </p> | ||
</td> | </td> |
Revision as of 21:44, 1 December 2010
Answer is a Number or a Formula
This PG code shows how to write a question whose answer is a number or a formula.
- Download file: File:FormulaAnswer1.txt (change the file extension from txt to pg when you save it)
- File location in NPL:
NationalProblemLibrary/FortLewis/Authoring/Templates/Misc/FormulaAnswer1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.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"); |
Setup:
We use |
Context()->texStrings; BEGIN_TEXT Enter \( $answer1 \): \{ ans_rule(20) \} \{ AnswerFormatHelp("numbers") \} $BR $BR Enter \( $answer2 \): \{ ans_rule(20) \} \{ AnswerFormatHelp("formulas") \} END_TEXT Context()->normalStrings; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $answer1->cmp() ); ANS( $answer2->cmp() ); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |