Webwork Sample 1

1. Tagging

There is an on-line list of current chapter and section names and a similar list of keywords. The list of keywords should be comma separated and quoted (e.g., KEYWORDS('calculus','derivatives')).

2. Init

This is the initialization section of the problem. The first executed line of the problem must be the DOCUMENT(); command. Note that every command must end with a semicolon. The loadMacros command loads information that works behind the scenes.

3. Set Up

Contexts and context explanations are given on this help page
All scalar variables are prefaced with a dollar sign: thus $a is a variable that has a (non-vector, non-array) value. We also define $trigFunc to be a MathObject

4. Text

The TEXT(beginproblem()); line displays a header for the problem, and the Context()->texStrings line sets how formulas are displayed in the text, and we reset this after the text section. Everything between the BEGIN_TEXT and END_TEXT lines (each of which must appear alone on a line) is shown to the student. Mathematical equations are delimited by \( \) (for inline equations) or \[ \] (for displayed equations); in these contexts inserted text is assumed to be TeX code. There are a number of variables that set formatting: $PAR is a paragraph break (like \par in TeX). This page gives a list of variables like this. Finally, \{ \} sets off code that will be executed in the problem text. Here, ans_rule(20) is a function that inserts an answer blank 20 characters wide.

5. Answer

The problem answer is set by the ANS( $trigDeriv->cmp() ); line, which simply says that the answer is marked by comparing the student's answer with the trigonometric function derivative that we defined before.

Then, we explain the solution to the student. This solution will show up when the student clicks the "show solution" checkbox after they've finished the problem set. The ENDDOCUMENT(); command is the last command in the file.>

The .pg file

There is an extra line used for testing with the Interactive Problem Lab

checkAnswer($result, "1.0");

the first argument is a MathObject, the second the student's answer string

More info on testing PGLabs here

Alternatively, you can try WPI's WbWrkGUI where you make questions with a free java application you can download, and get video tutorials.