## Section16.5WeBWorK Exercises

It is possible to embed WeBWorK exercises into a PreTeXt document. It is possible to build an HTML version in which readers can answer these exercises and find out if their answer is correct or incorrect. However, results of WeBWorK exercises cannot yet be recorded to your gradebook. Because WeBWorK content belongs inside an <exercise>, you can include WeBWorK exercises in any of the elements that can contain an <exercise> such as a <worksheet> and <reading-questions>. There's some configuration required use WeBWorK. Please see Chapter 7 and Chapter 35 for more details. As soon as you add WeBWorK exercises, compiling to produce any output format becomes a multistep process.

When a WeBWorK exercise lives on the server, the code takes one simple form.

The code in Listing 16.5.1 produces the following output:

Optional introduction

$$\displaystyle \int_0^{1} (4 e^x+5 \sin x)\, dx$$ =

$$9.17161578449548$$

Solution.

SOLUTION

\begin{equation*} \begin{array}{rcl} \displaystyle \int_0^{1} (4 e^x+5 \sin x)\, dx \amp =\amp \displaystyle 4 e^x-5 \cos x \Big]_0^{1} \\ \amp =\amp (4 e^{1} - 5 \cos 1) - (4 e^0 - 5 \cos0 ) \\ \amp =\amp 4 e^{1} - 5 \cos 1 + 1 \end{array} \end{equation*}

Optional conclusion

It is also possible to code WeBWorK exercises directly in your PreTeXt source. This shows the most primitive sort of such exercise. Chapter 7 goes into greater detail.

The code in Listing 16.5.3 produces the following output: