Skip to content

Stop single problem hardcopy generation if the TeX file can not be written. - #3236

Open
drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:bugfix/hardcopy-invalid-theme-error
Open

drgrice1 wants to merge 1 commit into
openwebwork:developfrom
drgrice1:bugfix/hardcopy-invalid-theme-error

Conversation

@drgrice1

Copy link
Copy Markdown
Member

If the hardcopy theme for a single problem hardcopy generated by render_rpc (for example, from the problem editor) can not be found, then write_tex records an error and returns without writing anything to the hardcopy.tex file, not even the \batchmode line. However, the error was ignored, and hardcopy generation continued with the empty TeX file.

When the PDF is generated, LaTeX stops at an error prompt for the empty file. On a production server where the standard input of the server is not a terminal, LaTeX immediately exits, and the user is sent a zip file containing the empty TeX file instead of the error message about the missing theme. On a development server running in a terminal (morbo), LaTeX waits for input from the terminal, and since it is run with system, the entire server stops responding until the LaTeX process is killed.

Now hardcopy generation stops and the errors are returned if writing the TeX file failed.

To reproduce the issue:

  1. Create a course hardcopy theme in the course templates/hardcopyThemes directory. For example, in the problem editor click "Edit Selected Theme" on the "Generate Hardcopy" tab, and then use "Save As" to save the theme in the course, and make sure to use a different file name.
  2. Open a problem in the problem editor, go to the "Generate Hardcopy" tab, and select the course hardcopy theme.
  3. In another browser tab, delete the course hardcopy theme using the File Manager (or just delete the file from the command line).
  4. In the problem editor click "Generate Hardcopy". The theme menu was created when the page was loaded, so the deleted theme is still sent.

Without this change a zip file containing an empty hardcopy.tex file is downloaded (or the server hangs if it is running in a terminal). With this change the error message "Couldn't locate file for theme ..." is shown.

…itten.

If the hardcopy theme for a single problem hardcopy generated by
`render_rpc` (for example, from the problem editor) can not be found, then
`write_tex` records an error and returns without writing anything to the
`hardcopy.tex` file, not even the `\batchmode` line. However, the error
was ignored, and hardcopy generation continued with the empty TeX file.

When the PDF is generated, LaTeX stops at an error prompt for the empty
file. On a production server where the standard input of the server is
not a terminal, LaTeX immediately exits, and the user is sent a zip file
containing the empty TeX file instead of the error message about the
missing theme. On a development server running in a terminal (morbo),
LaTeX waits for input from the terminal, and since it is run with
`system`, the entire server stops responding until the LaTeX process is
killed.

Now hardcopy generation stops and the errors are returned if writing the
TeX file failed.

To reproduce the issue:

1. Create a course hardcopy theme in the course `templates/hardcopyThemes`
   directory. For example, in the problem editor click "Edit Selected
   Theme" on the "Generate Hardcopy" tab, and then use "Save As" to save
   the theme in the course, and make sure to use a different file name.
2. Open a problem in the problem editor, go to the "Generate Hardcopy" tab,
   and select the course hardcopy theme.
3. In another browser tab, delete the course hardcopy theme using the
   File Manager (or just delete the file from the command line).
4. In the problem editor click "Generate Hardcopy". The theme menu was
   created when the page was loaded, so the deleted theme is still sent.

Without this change a zip file containing an empty `hardcopy.tex` file is
downloaded (or the server hangs if it is running in a terminal). With
this change the error message "Couldn't locate file for theme ..." is
shown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drgrice1
drgrice1 force-pushed the bugfix/hardcopy-invalid-theme-error branch from 405b2f8 to 0063c78 Compare October 14, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant