Skip to content

Conversation

drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Oct 8, 2025

Currently if the display mode is "images", then the student and correct answer previews don't work. The images are never actually rendered, thus the image files are never created, and so the alt value is shown which is the original TeX for the answer. The reason for this is that the image generator runs before the post content processor runs. So equation images in the problem are rendered, but not those in the feedback. That was done because of the hack of inserting the string MaRkEr followed by the image number hash when the image is initially inserted into the problem text, and then later replacing that with the alignment styel when the image is rendered. That results in invalid HTML which Mojo::DOM doesn't like.

To fix the issue the MaRkEr hack is reworked. Instead of that string, a data-imagegen-alignment-marker attribute is used whose value is the image number hash. Since that is valid HTML, Mojo::DOM is fine with it and leaves it as it is. So the image generator can now be run after the post content processor runs, and that renders the images in feedback as well.

Care is needed for the images in feedback when the data-imagegen-alignment-marker is replaced. Since the rendered img tag is inside the data-bs-content attribute of the feedback button, it is HTML encoded. So instead of double quotes, the HTML double quote escape character (") is used.

Another option would be to eliminate the "images" display mode. Clearly no one is using it, since I think this bug would have been noticed rather quickly when WeBWorK and PG 2.19 were released if anyone was using it.

Currently if the display mode is "images", then the student and correct
answer previews don't work.  The images are never actually rendered,
thus the image files are never created, and so the `alt` value is shown
which is the original TeX for the answer.  The reason for this is that
the image generator runs before the post content processor runs.  So
equation images in the problem are rendered, but not those in the
feedback.  That was done because of the hack of inserting the string
`MaRkEr` followed by the image number hash when the image is initially
inserted into the problem text, and then later replacing that with the
alignment styel when the image is rendered. That results in invalid HTML
which `Mojo::DOM` doesn't like.

To fix the issue the `MaRkEr` hack is reworked.  Instead of that string,
a `data-imagegen-alignment-marker` attribute is used whose value is the
image number hash.  Since that is valid HTML, `Mojo::DOM` is fine with
it and leaves it as it is.  So the image generator can now be run after
the post content processor runs, and that renders the images in feedback
as well.

Care is needed for the images in feedback when the
`data-imagegen-alignment-marker` is replaced.  Since the rendered `img`
tag is inside the `data-bs-content` attribute of the feedback button, it
is HTML encoded.  So instead of double quotes, the HTML double quote
escape character (") is used.
@drgrice1 drgrice1 force-pushed the bugfix/feedback-in-image-displaymode branch from 1b9b2e8 to 3dba462 Compare October 8, 2025 22:59
@somiaj
Copy link
Contributor

somiaj commented Oct 9, 2025

Aren't images for formulas also going to have accessibility issues? This could be another reason to drop support for them.

@drgrice1
Copy link
Member Author

drgrice1 commented Oct 9, 2025

The images do provide an alt attribute. The alt attribute is the LaTeX that is used to generate the equation. That may not be very good, but it is something.

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.

2 participants