Loading and Use - PGML

From WeBWorK
Revision as of 19:20, 11 May 2015 by Dpvc (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Loading the macro file

If you are going to use PGML in your problem, you must include "PGML.pl" in the loadMacros() call at the beginning of your problem.


If you don't, you'll get a message about PGML::Format2 not being defined.

Producing Text using PGML

The text that you want processed by PGML should be enclosed in BEGIN_PGML and END_PGML, each on a separate line. That is,

 ... your PGML code here ...

You can have as many such PGML sections as you like within one problem.

Producing Solutions using PGML

The text of the solution should be enclosed in BEGIN_PGML_SOLUTION and END_PGML_SOLUTION, each on a separate line. That is,

 ... your PGML code here ...

PGML's math formatting and command substitution commands are particularly useful here, as you can include intermediate computations directly within the PGML itself:

 If [:x = [$a]:], then [:x+1 = ([$a]+1) = [@ $a+1 @]:]

There is no need to use a separate variable for the value of $a+1, as the result of this computation will be inserted into the solution at that point.

Producing Hints using PGML

The text for the hint should be enclosed in BEGIN_PGML_HINT and END_PGML_HINT, each on a separate line. That is,

 ... your PGML code here ...

As with solutions, you can perform computations and mathematical typesetting within the PGML hint:

 What happens when [:x = [@ $a - $b @]:]?

There is no need for a separate variable for the value of $a-$b.

follow us