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.

@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.

@pstaabp
Copy link
Member

pstaabp commented Oct 21, 2025

I think removing images would be fine. Are there any reasons for anyone to use images?

That being said, shouldn't the images setting in the Display Settings of the User Settings switch this?
image

I did this and MathJax still shows up. I had to uncheck MathJax in the Course Configuration to get images to display.

That being said, this does fix the problem.

@drgrice1
Copy link
Member Author

When you change the "Display Settings" from the "User Settings" page, it does change the display mode that is used. However, there are some cases where the previous setting will persist after you make that change. For example, if you have a problem open in one tab and have navigated around using page links (so that the displayMode URL parameter is added), and then open the user settings in another tab, then the setting in the prior tab will stay with the old setting because the displayMode URL parameter is overriding the database setting.

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 3dba462 to ec8627c Compare October 21, 2025 19:39
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.

3 participants