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:
The problem file takes the basic structure:
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 isTEXT(&beginproblem);
Randomization is a big part of writing problems. See the randomization page for more information.
This is put between pairs ofBEGIN_TEXT
andEND_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.
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" callednum_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.
This is only one line, but if you are working on a copy of another problem, your life is that much easier. It isENDDOCUMENT();
The work represented here was produced with partial support from
a grant by the National Science Foundation (DUE-0125369).