Skip to main content

The PreTeXt Guide

Subsection 4.12.8 Coding Exercises and Projects

A Coding Exercise is formed by placing a <program> element after the <statement> of an <exercise>. The main distinction is that this is a signal that the interactivity is provided by the <program>, and therefore the <exercise> will not be understood as a short answer exercise (Subsection 4.12.9). For this reason, the <program> should be requested as one of the interactive realizations (Subsection 4.15.2, Subsection 4.15.3).
The identical construction may be used with any PROJECT-LIKE (List 4.2.2.2) such as an <activity>. As of 2022-06-17 this only applies to the form that uses a <statement>, but will soon also apply to <task> within PROJECT-LIKE.
Realize that it is always possible to place a <program> inside of a <statement>, and if there is no <program> that is after the <statement> (or another signal for an interactive exercise) then the <exercise> will be classified as a short-answer exercise. It may be instructive to understand that in a static realization, a <program> at the end of a <statement> may be visually identical to an <exercise> where the <program> is after the <statement>, even though the former is a short-answer exercise and the latter is a coding exercise (which will render differently for different output formats and hosting platforms).