Skip to main content

The PreTeXt Guide

Subsection 7.1.1 Using an Existing WeBWorK Problem

If a problem already exists and is accessible from the hosting course’s templates/ folder, then you can try to simply include it as a @source attribute. For example if it is a problem in the Open Problem Library (OPL), then relative to the templates/ folder, its path is Library/... and you may use:
<webwork source="Library/PCC/BasicAlgebra/Exponents/" />
Or if you have a problem’s PG file, you can upload it into the hosting course’s templates/local/ folder and use it with:
<webwork source="local/" />

Warning Not Every PG Problem is Compatible with PreTeXt.

Some problems that work fine within WeBWorK are not compatible with PreTeXt. Typically, these are exercises that use older PG coding techniques. To be compatible with PreTeXt, all of the macros used by a problem must be updated to give PreTeXt output. We have done this with modern PG macros and macros that are frequently used. But still, not every OPL problem (for example) is compatible with PreTeXt. In some cases, maybe it would be straightforward to train the macros to give PreTeXt output. But in many cases, older macros and problem files are not structured well and PreTeXt is all about good structure. So it could be a significant project to retrofit PreTeXt compatibility.
If you elect to use a problem that is incompatible with PreTeXt but you don’t yet know that, a few things could happen. One is that when you process the problems to gather static representations, you will get an error message that the problem did not return valid XML.
Or you might coincidentally get valid XML back, but something is just missing or wrong. There’s no automated check for that; you should read the output to check that the problem is complete. We recommend reading your PDF output with hints, answers, and solutions exposed, to be sure you are seeing the static version of the exercise.
If there is an incompatible OPL problem that you would really like to use, you have three options:
  • Author the problem in PreTeXt from scratch as described elsewhere in this section.
  • Edit the code for that OPL problem to use compatible macros.
  • Edit the incompatible macros to be compatible with PreTeXt.
The last two options involve contributing to the OPL and PG repositories on GitHub, so it is more expedient to use the first option.