From WeBWorK_wiki
Revision as of 21:01, 26 February 2020 by Gage (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

On-line labs for rendering of PG code. These two labs allow you to experiment with PG syntax.

Test your PG code fragments[edit]

Click on this link to go to PG calculator:

For example you could enter the code fragment below into the calculator:

   $f = Compute("x^2-3x+5");
   $fp = $f->D; # calculate the derivative
   checkAnswer($fp, "2x-3");      # the first argument is a MathObject, the second the student's answer string
  • On the last line TEXT prints the results of (reading from left to right)
    • Constructing the AnswerEvaluator for the contents of the Formula $fp
    • Evaluating the string "2x-3" using this AnswerEvaluator to produce an AnswerHash
    • Recursively representing the contents of the AnswerHash in a nice table.

checkAnswer() inserts its arguments into a more complicated command. e.g. last line above becomes:


PGML markup lab[edit]

  • Experiment with the new PG markup language syntax (PGML) which simplifies the graphical layout of the mathematics question.

Several dozen questions illustrating the use of PGML:

To use these commands in your own courses you will need to include in your loadMacros() segment. Start the display of your problem text with BEGIN_PGML which expands to


and end with END_PGML. These are used instead of the usual BEGIN_TEXT/END_TEXT construction. You can use both BEGIN_TEXT/END_TEXT and BEGIN_PGML/END_PGML in the same problem, if you wish. See SampleProblem4 for an example (with explanation) that uses PGML.