Skip to main content

Section 10.3 Processing

Subsection 10.3.1 Extraction and Merging

A PreTeXt project that uses WeBWorK must first have its WeBWorK content extracted into an auxiliary XML file before anything else can be done. Use the mbx script to extract PreTeXt content from the WeBWorK server into a folder, which you might call webwork-extraction/ as in this example:

$ mbx -c webwork -s <server> -d webwork-extraction <xml>

The WeBWorK server needs to be version 2.14 or later, specified with its protocol and domain, like https://webwork-ptx.aimath.org. (If you do not have a server, you may use https://webwork-ptx.aimath.org.)

You may need to specify a path to the webwork-extraction folder. Any image files that the WeBWorK server generates will be stored inside this folder. An auxiliary XML file called webwork-extraction.xml will be created in this folder. (Note that you can name the folder whatever you like, but the auxiliary file that is created will always be named webwork-extraction.xml.)

Next, use xsltproc with pretext-merge.xsl to merge your entire source tree with the extracted WeBWorK content. The string parameter webwork.extraction must identify the auxiliary XML file created in the previous step. Store the output in some file, for example merge.ptx in this example:

$ xsltproc --stringparam webwork.extraction webwork-extraction.xml pretext-merge.xsl <xml> > merge.ptx

Note that you may need to provide file paths to webwork-extraction.xml and pretext-merge.xsl.

Subsection 10.3.2 HTML output

When you execute xsltproc using mathbook-html.xsl, apply it to the merged file described above, not your original source. For example:

$ xsltproc mathbook-html.xsl merge.ptx

There are several string parameters you may pass to xsltproc.

stringparam options
webwork.inline.static

'no' (default) means inline exercises render as interactive.

'yes' means inline exercises render as static.

'preview' (planned) means inline exercises render as static until you click to activate them.

webwork.divisional.static

'no' means divisional exercises render as interactive.

'yes' (default) means divisional exercises render as static.

'preview' (planned) means divisional exercises render as static until you click to activate them.

html.knowl.exercise.inline

'no' means inline exercises appear on page load.

'yes' (default) means inline exercises are hidden in knowls.

html.knowl.exercise.sectional

'no' (default) means divisional exercises appear on page load.

'yes' means divisional exercises are hidden in knowls.

Subsection 10.3.3 output

When you execute xsltproc using mathbook-latex.xsl, apply it to the merged file described above, not your original source. For example:

$ xsltproc mathbook-latex.xsl merge.ptx

One string parameter you can pass to xsltproc is latex.fillin.style, which can take values 'underline' (the default) or 'box'.

Subsection 10.3.4 Creating Files for Uploading to WeBWorK

All of the <webwork> that you have written into your project can be “harvested” and put into their own .pg files by the mbx script. These files are created with a folder structure that follows the chunking scheme you specify. This process also creates set definition files (.def) for each chunk (say, for each section): one for inline exercises and one for divisional exercises. For <webwork> problems that come from the WeBWorK server, the .def file will include them as well. This archiving process creates set header .pg files for each set definition.

As with other WeBWorK processing, you must use the extraction and merge process first that is described in Subsection 10.3.1. For example:

$ xsltproc --stringparam chunk.level 1 pretext-ww-problem-sets.xsl merge.ptx

This creates a folder named after your book title, which has a folder tree with all of the .pg and .def files laid out according to your chunk level. You can compress this folder and upload it into an active WeBWorK course where you may then assign the sets to your students (and modify, as you like).