This scripts helps to write a WeBWork problem by filling out the main sections that any problem must have. Just fill out the text fields, and use the buttons at the bottom of this page to merge and download the .pg file.
This script does not render or check the accuracy of the code typed. For this purpose upload the file to your WeBWork server or use a local render as Rederly. This is an updated version of the tool created at https://www.mathorama.com/.

1. Description

Enter the description and meta information of the problem. This section is optional but it is commonly used to tag and distribute WeBWork problems.

2. Initialization

This is the initialization section of the problem. The first executed line of the problem must be the DOCUMENT(); command. Recall that every command must end with a semicolon. The loadMacros command loads the Macros needed for the problem.

3. Problem Set Up

Set up the problem context, the variables and the answer using PERL syntax. The variable $showPartialCorrectAnswers = 1; set to 1 means that feedback as to which sub-questions have been correctly answered in the problem will be given, otherwise (set to 0) the feedback just indicates that there is a wrong answer somewhere.

4. Display 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_PGML and END_PGML 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); the text is assumed to be TeX code. The value of a perl variable $x is displayed by [$x]. The line [_]{$answer} displays an answer box for studens, and it is compared with the PERL variable $answer.

5. Answers or Hints

Use this field to use other answers evaluators (e.g. weighted) or include hints to students. This is for techniques a bit more advanced.

6. Solution

The PGML_SOLUTION block displays instructor's solution for the problem after a due date set in the WeBWork homework. This block is optional and it is used when more than just the correct answer wants to be shown to students. The ENDDOCUMENT(); line must be the last command in the file.

The .pg file

Merge all the sections into a single file.
Reset all section fields
Show the merged problem: