Writing Your Own Homework Problems Using PGML

From WeBWorK
Revision as of 10:21, 6 May 2016 by Travis (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Intro To Writing Your Own Homework Problems Using PGML

Introduction

  • PGML makes writing your own homework problems so much nicer than what came before. Many chores which previously were difficult are now easier, if not automated away. The best part is that there is little to learn to get started. PGML is so elegant and intuitive that you can often get started by simply viewing and tweaking existing PGML based problem files.


So Why Isn't PGML Used Everywhere If It Is So Great?

  • If PGML is so great, you may wonder why you don't see it used everwhere in the publically available WebWork problem libraries. Many of those libraries were written before PGML existed. Since many newcomers base their own custom problems on those same libraries, there is a lot (and a growing!) amount of problems that are not PGML based. However, now that you know the truth you can be one of the fortunate ones to start using PGML now. Even better is the fact that you can convert non-PGML based problems you like to PGML often quite easily.

MAA PREP 2015 Problem Authoring Course Videos

Typical PGML Problem Example

  DOCUMENT();
  loadMacros(
    "PGstandard.pl",
    "PGML.pl",
    "MathObjects.pl",
    "PGcourse.pl",
    "parserNumberWithUnits.pl",
    "contextArbitraryString.pl",
    "parserMultiAnswer.pl",
    "parserPopUp.pl",
    "contextInequalities.pl",
    "PGgraphmacros.pl",
  );
  TEXT(beginproblem());
  $showPartialCorrectAnswers = 1;

The contents in the above box will rarely change much in your custom WebWork homework problems. Depending on what features you use in your problems, you may or may not need all the macros I have loaded above. On the other hand, one strategy is to always include any and every macro you have ever used in the past, or will use in the future, so as to not have to bother thinking about this initial boilerplate.

  Context("Numeric") ; 
  Context()->flags->set(tolerance => 0.01);

You will want to define a "context" for your PGML homework problem. If your answers will be numbers or formulas, then just set it to Numeric and do not worry about it for now. Later you may want to learn about other contexts to allow things like strings and inequalities. The second line tells WebWork to accept student submissions as correct if they differ from the correct answer given below by 1% or less.

  ######################################################################
  BEGIN_PGML
  Simplify [`2 + 4 \cdot 5`].
  [____________]{"22"}
  Now simplify [`2x + 4x + 5x`].
  [____________]{"11x"}
  END_PGML
  ######################################################################

The is what you will be changing the most as you create your own problems. What the student sees always goes in between BEGIN_PGML and END_PGML. If you want to include LaTeX, simply enclose it inside [` and `]. Your answer field is represented by [____________]. After the answer field, you specify the correct answer you desire in braces. In this example, the correct answer for the first question is a number and for the second it is an algebraic expression. If your answer is a number or formula, you can happily use the Compute function for a long time. Your problems can have only 1 question or even more than 2 if you wish. By the way, the hash marks which being and end this section are optional. I include them so I can easily see this part of any PGML problem quickly and easily.

  ENDDOCUMENT();

This last part is more boilerplate that should not change much if at all.

For Further Study

For further exploration of PGML, see the many PGML examples

follow us