Write a WeBWorK Problem

WeBWorK problem files can be edited through the web. The problem file has to already exist. So, we usually work from a basic problem which has all of the required boiler plate already in place.

Once you know generally what a problem will do, the two most important questions are:

There are separate web pages devoted to what we can do in each of these areas, the answers page and the randomization page.

The problem file takes the basic structure:

Boiler plate which starts every problem

This is a good reason to start with a copy of another problem -- it is longish to type and it is always the same. There are places to adjust things in comments (such as the keywords), but this is not essential. The last line of this section is
TEXT(&beginproblem);
						

Randomization and computation

Randomization is a big part of writing problems. See the randomization page for more information.

Problem text itself

This is put between pairs of BEGIN_TEXT and END_TEXT. You can use variable names inside, and WeBWorK will substitute the values in for you. You can also indicate other formatting, which is described on the formatting page.

This part should also have places for students to put their answers. This is done with lines like

\{ans_rule(40)\}
which makes an answer space 40 characters wide. You can have more than one answer space if you like.

Answers

You need to tell WeBWorK how to determine if a student's answers are correct. This is done with a line like:
ANS(num_cmp($ans1));
			
which says that the answer is in variable $ans1 (which hopefully you computed above), and the student's answer should be tested with the "answer evaluator" called num_cmp, which does standard number comparison.

If there is more than one answer blank in the problem, you need more than one ANS statement. Just give the answers in the same order as the answer blanks appear.

Closing Boiler Plate

This is only one line, but if you are working on a copy of another problem, your life is that much easier. It is
ENDDOCUMENT();


John Jones
Last modified: Mon Jul 8 10:33:08 MST 2002

NSF Logo The work represented here was produced with partial support from a grant by the National Science Foundation (DUE-0125369).