Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ logs/*
conf/*
!conf/*.dist*
!conf/*.config
!conf/snippets

node_modules

Expand Down
101 changes: 101 additions & 0 deletions assets/hardcopyThemes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Hardcopy Themes

A hardcopy theme is an XML file with root `<theme>`. The `<theme>` element has an attirubute `label` that is used to
define a label for the theme, for example, `label="Empty"`. It has children:

* `<description>`
* `<preamble>`
* `<presetheader>`
* `<postsetheader>`
* `<problemheader>`
* `<problemfooter>`
* `<problemdivider>`
* `<setfooter>`
* `<setdivider>`
* `<userdivider>`
* `<postamble>`

The `<description>` element contains a simple text description of the theme. All other elements contain text snippets
that will be inserted into a `.tex` file.

The `<preamble>` and `<postamble>` wrap the file. Note that `webwork2` will write `\batchmode` to the `.tex` file even
before `<preamble>` is written. The `<preamble>` must include `\usepackage{webwork2}` to load `webwork2.sty` for many
things to work.

Next `webwork2` will loop through users (often just one) and loop through problem sets (often just one) and write TeX
for all combinations. `<userdivider>` and `<setdivider>` are snippets of TeX that are inserted when transitioning to a
new user or a new set. Typically these should just start a new page and reset page numbering.

When an individual user-set is being processed, first the `<presetheader>` snippet will be used. Then the PG header
file will be processed. Then the `<postsetheader>` snippet will be used. At the end of the set `webwork2` attempts to
make the last page display a copyright claim. Then the `<setfooter>` snippet is used.

Each problem is wrapped in `<problemheader>` and `<problemfooter>`, and `<problemdivider>` is used between adjacent
problems.

## Packages

A theme preamble can load packages, but as soon as it loads `webwork2`, it is already loading `path`, `listings`,
`hyperref`, and `ifthen`. So you can use tools from these packages without loading them in your theme.

Also `webwork2` loads `pg.sty` from the `pg` distribution. This loads `amsmath`, `amsfonts`, `amssymb`, `booktabs`,
`tabularx`, `colortbl`, `caption`, `xcolor`, `multicol`, `mhchem`, and `graphicx`. So again you can use tools from
these packages without loading them in your theme.

## Macros

The following macros are provided by the `webwork2` package. They may be empty, but `webwork2` should populate them
with appropriate values as the `.tex` file is built. So you can use these when building your theme.

* `\webworkCourseName`
* `\webworkCourseTitle`
* `\webworkCourseURL`
* `\webworkUserId` (the user's username)
* `\webworkStudentId` (the user's Student ID)
* `\webworkFirstName`
* `\webworkLastName`
* `\webworkEmailAddress`
* `\webworkSection`
* `\webworkRecitation`
* `\webworkSetId` (the actual name of the set which may have underscores)
* `\webworkPrettySetId` (a version where underscores have been converted to spaces)
* `\webworkDescription`
* `\webworkOpenDate`
* `\webworkReducedScoringDate`
* `\webworkDueDate`
* `\webworkAnswerDate`
* `\webworkProblemNumber` (the number of the problem in the set)
* `\webworkProblemId` (may differ from the problem number for a versioned test with randomized order)
* `\webworkProblemWeight`
* `\webworkLeftHeader` (a multiline expression with the set name and due date(s))
* `\webworkCenterHeader` (empty by default)
* `\webworkRightHeader` (a multiline expression with the user's name, ID, section, and recitation)
* `\webworkLeftFooter` (a hyperlink to the course with text the course title)
* `\webworkCenterFooter` (empty by default)
* `\webworkRightFooter` (localized "Page" followed by the page number)

Words and phrases might be localized automatically by `webwork2` in the future, but a theme can override these.

* `\webworkLocalizeAssignment`
* `\webworkLocalizeSet`
* `\webworkLocalizeProblem`
* `\webworkLocalizeUsername`
* `\webworkLocalizeFullCreditBy`
* `\webworkLocalizeCloses`
* `\webworkLocalizeSection`
* `\webworkLocalizeRecitation`
* `\webworkLocalizePage`
* `\webworkLocalizePoint`

## Config

Theme files belong in `webwork2/assets/hardcopyThemes` or in a course's `templates/hardcopyThemes` folder. Both of
these paths can be configured in `localOverrides.conf`, following the initialization in `defaults.config`. If a theme
in `templates/hardcopyThemes` has the same filename as a theme in `webwork2/assets/hardcopyThemes`, the one from
`templates/hardcopyThemes` will be used.

A course will "see" all the theme files in these locations and make them available to be enabled in Course Config.
Only the enabled themes will be offered for use when producing a hardcopy.

In addition to enabling themes in Course Config, you can also set the default hardcopy theme for regular hardcopy
production, and separately set a default hardcopy theme for use by the PG Editor.
69 changes: 69 additions & 0 deletions assets/hardcopyThemes/basic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<theme label="Basic">

<description>
This theme produces hardcopies with minimal page headers displaying the set
title and useername, and minimal problem numbering.
</description>

<preamble>
\documentclass{article}
\usepackage{webwork2}
\usepackage[text={6in,9in},centering]{geometry}
\usepackage{fancyhdr}
\renewcommand{\webworkLeftHeader}{%
\ifthenelse{\equal{\webworkPrettySetId}{}}{}{\ifthenelse{\thepage=1}{\large\scshape\webworkLocalizeSet: \webworkPrettySetId}{}}%
}
\renewcommand{\webworkRightHeader}{%
\ifthenelse{\equal{\webworkUserId}{}}{}{\ifthenelse{\thepage=1}{\bfseries\webworkLocalizeUsername: \webworkUserId}{}}%
}
\parindent=0pt
\pagestyle{fancy}
\begin{document}
</preamble>

<presetheader>
\renewcommand{\headrulewidth}{0pt}
\fancyhead[L]{\webworkLeftHeader}
\fancyhead[C]{\webworkCenterHeader}
\fancyhead[R]{\webworkRightHeader}
\fancyfoot[L]{\webworkLeftFooter}
\fancyfoot[C]{\webworkCenterFooter}
\fancyfoot[R]{\webworkRightFooter}
</presetheader>

<postsetheader>
\bigskip
</postsetheader>

<problemheader>
{\bfseries\webworkLocalizeProblem~\ifthenelse{\equal{\webworkProblemNumber}{}}{\#}{\webworkProblemNumber}}
\nobreak
\smallskip
</problemheader>

<problemfooter></problemfooter>

<problemdivider>
\vspace{2pc+6pc-1pc}
\goodbreak
</problemdivider>

<setfooter>
</setfooter>

<setdivider>
\newpage
\setcounter{page}{1}
</setdivider>

<userdivider>
\newpage
\setcounter{page}{1}
</userdivider>

<postamble>
\end{document}
</postamble>

</theme>
73 changes: 73 additions & 0 deletions assets/hardcopyThemes/basicTwoCol.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" ?>
<theme label="Basic&#x2014;Two Column">

<description>
This theme produces hardcopies with minimal page headers displaying the set
title and useername, and minimal problem numbering. With two columns.
</description>

<preamble>
\documentclass{article}
\usepackage{webwork2}
\usepackage[text={6in,9in},centering]{geometry}
\setlength{\columnsep}{.25in}
\setlength{\columnseprule}{.4pt}
\usepackage{fancyhdr}
\renewcommand{\webworkLeftHeader}{%
\ifthenelse{\equal{\webworkPrettySetId}{}}{}{\ifthenelse{\thepage=1}{\large\scshape\webworkLocalizeSet: \webworkPrettySetId}{}}%
}
\renewcommand{\webworkRightHeader}{%
\ifthenelse{\equal{\webworkUserId}{}}{}{\ifthenelse{\thepage=1}{\bfseries\webworkLocalizeUsername: \webworkUserId}{}}%
}
\parindent=0pt
\pagestyle{fancy}
\begin{document}
</preamble>

<presetheader>
\renewcommand{\headrulewidth}{0pt}
\fancyhead[L]{\webworkLeftHeader}
\fancyhead[C]{\webworkCenterHeader}
\fancyhead[R]{\webworkRightHeader}
\fancyfoot[L]{\webworkLeftFooter}
\fancyfoot[C]{\webworkCenterFooter}
\fancyfoot[R]{\webworkRightFooter}
</presetheader>

<postsetheader>
\bigskip
\begin{multicols*}{2}
</postsetheader>

<problemheader>
{\bfseries\webworkLocalizeProblem~\ifthenelse{\equal{\webworkProblemNumber}{}}{\#}{\webworkProblemNumber}}
\nobreak
\smallskip
</problemheader>

<problemfooter></problemfooter>

<problemdivider>
\vspace{2pc+6pc-1pc}
\goodbreak
</problemdivider>

<setfooter>
\end{multicols*}
</setfooter>

<setdivider>
\newpage
\setcounter{page}{1}
</setdivider>

<userdivider>
\newpage
\setcounter{page}{1}
</userdivider>

<postamble>
\end{document}
</postamble>

</theme>
72 changes: 72 additions & 0 deletions assets/hardcopyThemes/boxed.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" ?>
<theme label="Boxed">

<description>
This theme uses the tcolorbox package to put each exercisee in a box.
</description>

<preamble>
\documentclass[11pt]{article}
\usepackage{webwork2}
\usepackage[text={7in,9in},centering]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}
\newtcolorbox{webworkexercise}[2]{
breakable,
enhanced jigsaw,
title={
{\bfseries\webworkLocalizeProblem~\ifthenelse{\equal{#1}{}}{\#}{#1}}\hfill
(\ifthenelse{\equal{#2}{}}{\#}{#2}~\webworkLocalizePoint)
}
}
\usepackage{fancyhdr}
\parindent=0pt
\setlength{\parskip}{1pc}
\pagestyle{fancy}
\begin{document}
</preamble>

<presetheader>
\renewcommand{\headrulewidth}{0pt}
\fancyhead[L]{\webworkLeftHeader}
\fancyhead[C]{\webworkCenterHeader}
\fancyhead[R]{\webworkRightHeader}
\fancyfoot[L]{\webworkLeftFooter}
\fancyfoot[C]{\webworkCenterFooter}
\fancyfoot[R]{\webworkRightFooter}
</presetheader>

<postsetheader>
\medskip
</postsetheader>

<problemheader>%
\begin{webworkexercise}{\webworkProblemNumber}{\webworkProblemWeight}%
</problemheader>

<problemfooter>%
\end{webworkexercise}%
</problemfooter>

<problemdivider>
\smallskip
\goodbreak
</problemdivider>

<setfooter></setfooter>

<setdivider>
\newpage%
\setcounter{page}{1}%
</setdivider>

<userdivider>
\newpage%
\setcounter{page}{1}%
</userdivider>

<postamble>
\end{document}
</postamble>

</theme>
68 changes: 68 additions & 0 deletions assets/hardcopyThemes/boxedRows.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<theme label="Boxed&#x2014;Rows">

<description>
This theme uses the tcolorbox package to put each exercisee in a box.
Exercises progress row-major instead of the usual column-major, in two columns.
Exerecises in this theme will not break across pages, so this theme is better
suited for sets with short exercises.
</description>

<preamble>
\documentclass[10pt]{article}
\usepackage{webwork2}
\usepackage[text={7.5in,9in},centering]{geometry}
\usepackage{tcolorbox}
\tcbuselibrary{raster}
\newtcolorbox{webworkexercise}[2]{
title={
{\bfseries\webworkLocalizeProblem~\ifthenelse{\equal{#1}{}}{\#}{#1}}\hfill
(\ifthenelse{\equal{#2}{}}{\#}{#2}~\webworkLocalizePoint)
},
}

\usepackage{fancyhdr}
\parindent=0pt
\setlength{\parskip}{1pc}
\pagestyle{fancy}
\begin{document}
</preamble>

<presetheader>
\renewcommand{\headrulewidth}{0pt}
\fancyhead[L]{\webworkLeftHeader}
\fancyhead[C]{\webworkCenterHeader}
\fancyhead[R]{\webworkRightHeader}
\fancyfoot[L]{\webworkLeftFooter}
\fancyfoot[C]{\webworkCenterFooter}
\fancyfoot[R]{\webworkRightFooter}
</presetheader>

<presetheader>
\bigskip
\begin{tcbraster}[raster columns=2, raster valign=top]
</presetheader>

<problemheader>\begin{webworkexercise}{\webworkProblemNumber}{\webworkProblemWeight}%</problemheader>

<problemfooter>\end{webworkexercise}</problemfooter>

<problemdivider></problemdivider>

<setfooter>\end{tcbraster}</setfooter>

<setdivider>
\newpage%
\setcounter{page}{1}%
</setdivider>

<userdivider>
\newpage%
\setcounter{page}{1}%
</userdivider>

<postamble>
\end{document}
</postamble>

</theme>
Loading