Opening the book…
| Section | What it controls | What to check when debugging |
|---|---|---|
| OPL header | Metadata, searchability, and attribution. | Missing TITLE/DESCRIPTION or wrong DBsubject tags. |
| Preamble | Macros, rendering switches, and global knobs. | Missing macro files, wrong load order, or disabled features. |
| Setup | Values, constraints, answers, and graders. | Bad ranges, unit mismatches, or tolerance mistakes. |
| Statement | PGML prompt text, structure, and blanks. | Blank binding, missing inserts, or formatting breaks. |
| Solution | Explanations, trust, and grading alignment. | Mismatch between solution conventions and the checker. |
This page shows the full problem file as a reference copy so you can see the entire flow from top to bottom. For an overview of the five sections, see Sections within a PG question. The prompt text uses PGML. Read the file once as a story: macros are loaded, values are chosen, the prompt is written, answers are graded, and a solution explains the work.
When you start editing, avoid making changes on this page directly. Use the section pages to make one targeted change at a time, then come back here to confirm that the full file still reads cleanly and that values and answers are consistent throughout.
As you read, notice which lines are structural and which lines are content. Structural lines are macro loading and section delimiters; content lines are the prompt text, choice lists, and the explanation in the solution.
Section anchors (reference map)
Use this table to find the line where each section starts and ends. When debugging, start by identifying which section contains the error, then jump to the section-specific page for detailed guidance.
| Section | Starts at | Ends at | One-line description |
|---|---|---|---|
| OPL header | ## TITLE(...) | ## Institution(...) | Metadata that makes the problem searchable. |
| Preamble | # ===== PREAMBLE ===== | # ===== SETUP ===== | Loads macros and switches that unlock features. |
| Setup | # ===== SETUP ===== | # ===== STATEMENT ===== | Defines values, constraints, and answer objects. |
| Statement | # ===== STATEMENT ===== | # ===== SOLUTION ===== | Contains the PGML prompt students read. |
| Solution | # ===== SOLUTION ===== | ENDDOCUMENT(); | Explains the target and matches the grading rules. |
Each section page (4.2 through 4.6) walks through the purpose, common edits, and failure patterns for that part of the file. Start with the section closest to your error. This page is a reference copy so you can see the whole file in one place after you make changes in the section-specific pages.
The tables below give you a one-line summary of what each section does, what you typically edit there, and what fails most often.
Section quick reference
OPL header
Why this exists: it documents metadata for search and attribution before any code runs.
| Common edits | Common failures |
|---|---|
| Update TITLE, KEYWORDS, and DBsubject tags. | Missing DESCRIPTION or empty tags. |
Preamble
Why this exists: it declares the macros and global options that make the file render.
| Common edits | Common failures |
|---|---|
| Add or remove a macro file. | Missing macro that defines a feature. |
Setup
Why this exists: it defines the answer objects and correct choices.
| Common edits | Common failures |
|---|---|
| Edit choice lists or correct answers. | Correct answer no longer matches the list. |
Statement
Why this exists: it is the PGML prompt with readable structure and blanks.
| Common edits | Common failures |
|---|---|
| Rewrite the story or add a table. | Blank not bound to an answer. |
Solution
Why this exists: it explains the grading target and the method.
| Common edits | Common failures |
|---|---|
| Clarify the correct option or rationale. | Solution label does not match grading. |
Complete file (reference copy)
This is the complete worked example assembled from sections 4.2 through 4.6. Read it once as a story -- macros load, values are chosen, the prompt appears, answers are graded, and the solution explains the work.
# ===== OPL HEADER =====
## TITLE('Color choice using radio buttons')
## DESCRIPTION
## Select the correct color label from two radio button formats and confirm the choice labels.
## ENDDESCRIPTION
## KEYWORDS('radio buttons','choice list','PGML prompt')
## DBsubject('Biochemistry')
## DBchapter('Lab techniques')
## DBsection('Reporting conventions')
## Date('2026-01-28')
## Author('Example author')
## Institution('Example institution')
# ===== PREAMBLE =====
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
"parserRadioButtons.pl",
"PGcourse.pl",
);
# ===== SETUP =====
$radio1 = RadioButtons(
[ 'Red', 'Blue', 'Green', 'None of these' ],
'Blue',
);
$radio2 = RadioButtons(
[ 'Red', 'Blue', 'Green', 'None of these' ],
2,
separator => $SPACE x 5
);
# ===== STATEMENT =====
BEGIN_PGML
My favorite color is
[_]{$radio1}
The same question with horizontal options:
My favorite color is [_]{$radio2}
END_PGML
# ===== SOLUTION =====
BEGIN_PGML_SOLUTION
The correct answer to the first is [$radio1->correct_ans].
The correct answer to the second is [$radio2->correct_ans].
END_PGML_SOLUTION
ENDDOCUMENT();
This page titled 4.1: Full file was last modified on Fri, 27 Feb 2026 15:21:39 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Neil R. Voss.
The book could not be loaded just now.