Last week I discussed the merits of formatting materials to be placed in the Connexions repository in CNXML. This week we'll explore one great markup feature of CNXML: the <exercise> tag.
What is it?
If you have written, or plan on writing, educational materials, chances are that you will have some exercises or problem sets in your content. An <exercise> in CNXML specifies:
- one <problem>,
- zero, one, or more <solution> items, and
- zero, one, or more <commentary> items.
Connexions automatically numbers and formats your exercises for professional layout both online and in print. Online, the solutions are "hidden" until the reader clicks a link to reveal the answer. Here's how an exercise looks with the solution hidden:

And here is how it looks after the solution is revealed:

In the PDF, the solutions for each exercise will be moved to the end of a chapter in most cases, just like in a conventional textbook, though that default can be overridden by the author.
The CNXML markup
While editing your module, click on the "insert" dropdown menu and choose <exercise> from the menu.
"Edit-in-Place will create an exercise template for you, which you can then fill in with your problem and solution. For the example shown above, the CNXML would look something like this (I have added in some optional commentary):
<exercise id='hyd_test'>
<problem id="id9">
<para id='hyd_testp1'>
The color of a hydrangea changes with the pH of the
soil. What color would the hydrangea be if the soil
were highly acidic? Highly basic? Neutral?
</para>
</problem>
<solution id="id10">
<para id='hyd_sol1p1'>
Highly acidic soil produces blue flowers. Highly
basic soil produces pink flowers. Neutral soil produces
very pale cream flowers.
</para>
</solution>
<commentary id="ex1_comment">
<para id="ex1_comment_para">
Who would have known?!
</para>
</commentary>
</exercise>
One way to override the default behavior of having the solution at the end of each module in the PDF is to change this line:
<solution id="id10">
to this:
<solution id="id10" print-placement="here">


Your module will now proudly display the text "Download this file", with "file" hyperlinked to your file. (In the downloadable PDF, the URL will show up as a footnote.) You can also