FormulaAnswer1

From WeBWorK_wiki
Jump to navigation Jump to search
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 is a Number or a Formula - Try it out

Click to enlarge

This PG code shows how to write a question whose answer is a number or a formula.


Templates by Subject Area

PG problem file Explanation

Problem tagging data

Problem tagging:

DOCUMENT();

loadMacros('PGstandard.pl','MathObjects.pl','PGML.pl','PGcourse.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 do { $b = random(2,9,1); } until ( $b != $a ); to generate distinct random numbers.

BEGIN_PGML
Enter [`[$answer1]`]: [____]{$answer1} [@ helpLink('number') @]*

Enter [`[$answer2]`]: [____]{$answer2} [@ helpLink('formula') @]*
END_PGML

Main Text:

  • The helpLink command show some additional help for entering values.

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION
ENDDOCUMENT();

Solution:

Templates by Subject Area