A simple, but functional example to begin with. If you are just learning how to add, you can test yourself here.
Compute the sum of \(6\) and \(1\text{:}\)
\(6 + 1 =\)
Answer.
\(7\)
Solution.
\(6 + 1 = {7}\text{.}\)
That was a simple problem. Let’s move on.
If you are familiar with WeBWorK, then it may be a surprise to you to be interacting with a WeBWorK problem this way, without having logged in to WeBWorK.
Checkpoint1.1.2.Declaring a Problem Seed.
You can also declare a seed to specify a version of any problem that has randomization. Here is the same problem (“copied” in the PreTeXt source), but with a seed specified.
Compute the sum of \(5\) and \(8\text{:}\)
\(5 + 8 =\)
Answer.
\(13\)
Solution.
\(5 + 8 = {13}\text{.}\)
Checkpoint1.1.3.Controlling Randomness.
You can code your problem with randomization, but then use a specific seed and WeBWorK’s $envir{problemSeed} to override that randomization for the purposes of the version that will appear in HTML and print output.
Compute the sum of \(1\) and \(2\text{:}\)
\(1 + 2 =\)
Answer.
\(3\)
Solution.
\(1 + 2 = {3}\text{.}\)
Checkpoint1.1.4.Special Answer Checking.
One of the strengths of WeBWorK is its ability to give intelligent feedback for incorrect answers.
There is general feedback for when the student’s answer is in an entirely different ballpark from the correct answer. Try entering something like “y”.
There is general feedback for when the student’s answer is not in the right form. Try entering “x^2*x^3”, which, right or wrong, is unsimplified.
And problems can be written to detect and respond to common mistakes. Try entering an answer where you multiply the two exponents (instead of adding them, which would be correct.)
Use the properties of exponents to simplify \({x^{5}x^{3}}\text{.}\)
\({x^{5}x^{3}}=\)
Answer.
\(x^{8}\)
Solution.
We add the exponents as follows, while including a gratuitous reference to the quadratic formula:
Hints can be inserted into exercises. Whether a hint is visible in the HTML depends on the value of $showHint in PGcourse.pl in the WeBWorK course that is hosting these exercises. How the hint is displayed in the pdf output is controlled in the usual way that an PTX hint is controlled.
This problem has no randomization at all, not even if it were exported to be part of a problem set on a WeBWorK server. As such, it really doesn’t need any lines of Perl code in its setup, so you have the option of skipping that part of the authoring process.
\(1+2=\)
Answer.
\(3\)
For more about problems that do not require any randomization, see the PTX Author Guide 1 .
Project1.1.1.Inside a <project>.
If you like, you can have a WeBWorK inside a PROJECT-LIKE block. Just like with an <exercise>, it can be preceded with an optional <introduction> and followed by an optional <conclusion>.