Repository navigation
Add an option to include a screenshot of the problem in feedback emails. - #3247
Alex-Jordan wants to merge 10 commits into
Conversation
|
Sounds like another issue with the modern-screenshot package. I could ask Claude to investigate and it might propose another adjustment to compensate. But before I do that, how are we feeling about this feature? I don't need to insist on adding this. An aside. I did notice something sort of like this, but not with a homework system. Sometimes when people share links to Google Docs, Google Sheets, etc., the email will have an image of that document. But it is static from that moment, and if the underlying document is updated, the recipient of the email still sees a snapshot from when the email was sent. |
|
With Claude's help, this now draws spans for checkboxes and radio buttons in the copy of the div that is used by modern-screenshot to take the screenshot. In my testing, I now see checked/selected boxes/buttons as appropriate. |
|
Trying to test this. I don't have a smtp set up on my develop machine. It doesn't look like the screenshot is saved in a tmp directory anywhere or am I wrong. If this is true, is there another way to view the screenshot? |
|
> Trying to test this. I don't have a smtp set up on my develop machine. It doesn't look like the screenshot is saved in a tmp directory anywhere or am I wrong. If this is true, is there another way to view the screenshot?
You get to see the screenshot when you click Email Instructor before you
send. So maybe it's enough just to enable Email Instructor.
|
|
Finally tracked down the reason I never saw the screenshot. I think this might be a safari issue. @Alex-Jordan did you test in Safari? I'm getting a javascript error: Blocked script execution in 'about:srcdoc' because the document's frame is sandboxed and the 'allow-scripts' permission is not set. I'm seeing everything correctly in chrome. I'll look into seeing if this is on my end (some setting) or there's an option in |
17d63fe to
97c24f4
Compare
|
This is now rebased, addressing some conflicts. I checked with Safari and did not experience what @pstaabp experienced. However, there was an issue with box shadow borders being offset in the screenshot. Claude pinned this down as coming from WebKit browsers drawing box shadows differently, and added a commit to address that by drawing such things differently for modern-screenshot to take its screenshot. @pstaabp Is there some extension you have in Safari that might be responsible for the blocking you experienced? |
97c24f4 to
561faa7
Compare
|
Just checked again and seems to be working in Safari now. I don't think I had any extensions that would block it. |
| my $filename = 'screenshot-' . ($set ? $set->set_id . '-' . $problem->problem_id : 'problem') . '.png'; | ||
| $filename =~ s/[^\w.-]/_/g; | ||
| $email->{parts} = [ | ||
| Email::MIME->create( |
There was a problem hiding this comment.
I do not like that this attaches the screenshot to the email twice. The primary reason that I do not like getting screenshots from students is because of how large it makes the email which makes downloading the email slower as well as causes extra processing by the email client to render the email. Attaching the image twice will not help with this, and is not necessary. See the method in lib/WeBWorK/TwoFactorAuthentication.pm that does this. This email is a bit different since it has a text and html part, but the technique still works.
There was a problem hiding this comment.
OK, I pushed a change to the email layout such that there is only one copy of a screenshot there now.
Also in looking at lib/WeBWorK/TwoFactorAuthentication.pm I saw your comment about using logo at tthe start of an image's Content-ID. In my testing, I am not needing to do that in order to successfully receive one of these Email Instructor emails at my personal gmail address. Do you think that comment is out of date? OR maybe only applies to QR code images?
There was a problem hiding this comment.
I am planning to do some more testing on that logo comment. That is behavior that I saw when testing at the time that I implemented two factor authentication. However, it is completely undocumented behavior for gmail. I suspect it might not be gmail that causes that issue, but perhaps something else in the email sending chain of events. In any case, don't worry about that for now.
|
Pull request #3302 is the result of what I discovered regarding that comment about the |
|
Ignore my comment about either this or #3302 needing to be updated once the other is merged. For some reason I was thinking that this is adding a new email that is sent, but that is not the case. #3302 already adds the Message-ID to this email. Yeah, perhaps the screenshot being shown on the feedback page is nice for students to see what they may not have in memory. Although it might have accessibility issues if considered in that way? |
drgrice1
left a comment
There was a problem hiding this comment.
I think that this looks good.
I am not entirely fond of the mass of code in htdocs/js/Problem/problem.js to construct the screenshot. Hopefully the modern-screenshot library improves (or perhaps another better such library found) and eventually not all of that is needed.
I am also not entirely fond of the server side image processing to reduce the screenshot size. For that also, hopefully the modern-screenshot library improves and it generates smaller images to begin with in the future.
|
In testing I noticed a few things.
This isn't a feature I plan on using as of now (I might change my mind if I hear good use case stories about it). So don't change things just for me, these are just things I noticed for you to consider. |
|
I tested GraphTool and plots images, and they worked. I forgot to test plotly 3D images. I see that they are not coming through. Scaffolds cannot be forced open. That doesn't make sense. If the intent of the problem is to reveal parts step by step, then how can you even suggest that? That would reveal parts of the problem the student is not supposed to see yet. Note that the unopened parts of a scaffold are not even in the DOM (they are nowhere client side), and the javascript has no hope of including those in the screenshot. |
|
I mean whatever scaffolds can be opened. So it would only be able to open all the ones up to where the student got stuck. |
|
One thing I noticed with GraphTool problems is that the screenshot generate was pretty slow, and is slower when more things have been graphed. It takes several seconds before the form is submitted while the screenshot is being generated. Since this is |
|
Oops. Accidental button press mid comment. I meant to add, that since the screenshot is being generated by javascript, there is no indication to the user as to why the page is just sitting there doing nothing like a slow server response. For a slow server response, most browsers give a loading indicators. But with this there is nothing. Perhaps a loading overlay or something could be added. Otherwise you might have users start to click the button several times thinking that it didn't take the first time. |
|
For scaffolds, if a student is stuck on section 3, section 1 and 2 are completed and closed by default. So it might be useful to see the student answers in the first two scaffolds to help support the student in the third. So open all scaffolds that could be opened could be useful in the screenshot. |
|
Yeah, in that case the closed scaffolds could be include, but I think that will be problematic to actually accomplish with this. Also, note that this depends on the settings for the scaffold. The settings I use keep the previously answered scaffolds open. |
|
And students can open/closed scaffolds, so what is actually shown in the screenshot could be dependent on what the student has done. If it isn't easy to open them, I wouldn't worry about it to much. I was just commenting it could be useful to have them opened in the screenshot. |
I'm looking into that. Unfortunately it will probably mean more special code for making up for a modern-screenshot deficiency.
I don't think so. The idea is a screenshot to show what the student was seeing at that moment. And to give the instructor an understanding at a glance about which exercise the message is about. If there's a need to really dig into the exercise, the instructor will need to log in and look there.
I'll move the button.
If the problem actually has errors such that it fails to render, then those errors are send instead of any screenshot. If there are less severe perl warnings, what do we think should happen? There are two kinds: kinds a student would see and kinds that would only be revealed to an instructor. What behavior do we want? |
|
plotly draws in canvas elements, and that was not covered well by this. But it will be with my next push. graphTool and other things draw svg, and modern-screenshot handles that slowly. I'm going to try having svg's be exported to png from the student's screen first, and then plant those inside the screenshot rather than redo the svgs from graphTool, etc. |
If `$mail{feedbackScreenshot}` is set in site.conf (it is disabled by
default), then when the "Email Instructor" button is clicked on a problem
page, a screenshot of the rendered problem is taken in the browser and sent to
the feedback page. The feedback page shows the screenshot with a checkbox that
allows the student to choose to include it. The checkbox is unchecked by
default, so that screenshots are only sent when they would be helpful. The
screenshot is embedded in the html version of the email (in a
multipart/related part referenced by its content id), and attached to the text
version of the email (in a multipart/mixed part). Screenshots larger than the
maximum attachment size are not included.
The screenshot is taken with the modern-screenshot javascript package. The
following issues with that package are worked around:
* Pseudo elements whose content is an image (such as the icons in the answer
feedback buttons) are rendered as the text of the image url.
* Open popovers (such as answer feedback popovers) are positioned relative to
their offset parent, which is often outside of the problem body, and so are
not in the right place or not in the screenshot at all. The screenshot is
also expanded to include popovers that extend outside of the problem body.
* An overflow of visible is not copied for svg elements, and so parts of
MathJax output that extend outside of the svg (for example the tail of a Q)
are clipped.
The PNG images created by browsers are not well compressed. So the screenshot
is converted to a palette image with at most 256 colors and compressed with
GD when it is received by the server. This reduces the size of a typical
screenshot to about 30% of the original size with no visible difference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t fail to render. If a problem fails to render, then the first 20 lines of the PG error message are passed to the feedback page when the "Email Instructor" button is clicked, and are included in the feedback email. A screenshot of the problem is not taken in this case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…screenshots. modern-screenshot does not copy the current state of checkboxes, radio buttons, or select options to the cloned problem. In addition, Firefox does not render checkboxes and radio buttons in the screenshot. So checkboxes and radio buttons are replaced in the clone with drawn elements that show their current state, and the selected attribute is set on select options that are currently selected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cae1ddd to
2a9da9a
Compare
|
OK, the changes recently discussed are here. Two things not here are:
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shot code. Screenshots of problems are generated faster, particularly for problems with graphs and images and in Firefox and Safari. The code is also simplified and more robust when taking a screenshot times out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2a9da9a to
eb50368
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I added one more commit so that the email shows perl warnings that the student saw. There is also a note to the student when composing the message that the warnings will be included in the email. So they don't need to copy those warnings into their message. Test this out by putting |
There was a problem hiding this comment.
I am starting to question this pull request now. The amount of code and hacks in the problem.js file that are needed to get the screenshots to actually work well is really concerning. Furthermore, I am starting to look closer at that code, and am seeing things that are being abstracted nonsensically. These are examples of AI really not understanding what it is doing, but just applying heuristics and guess work. One abstraction that is clearly not needed is the createMarker method. Defining it in that way is an absurd abstraction of a simple array.
I am not really seeing any difference in speed for screenshots with the GraphTool problems with the latest changes. Also, the plotly3d screenshots are now working, but those are even slower to generate than the GraphTool problems.
|
I could put this in draft mode and see if the modern-screenshot developers
make improvements in the next 6 months, so these workarounds could be
removed. I could report the issues and see what happens.
JavaScript is not my strength, and I'm not able to give Claude's code there
the same scrutiny I can give to other things. I'll try more though in the
future.
Alex Jordan
Mathematics Instructor
Portland Community College
…On Sat, Nov 21, 2026, 7:23 PM Glenn Rice ***@***.***> wrote:
***@***.**** requested changes on this pull request.
I am starting to question this pull request now. The amount of code and
hacks in the problem.js file that are needed to get the screenshots to
actually work well is really concerning. Furthermore, I am starting to look
closer at that code, and am seeing things that are being abstracted
nonsensically. These are examples of AI really not understanding what it is
doing, but just apply heuristics and guess work. One abstraction that is
clearly not needed is the createMarker method. Defining it in that way is
an absurd abstraction of a simple array.
I am not really seeing any difference in speed for screenshots with the
GraphTool problems with the latest changes. Also, the plotly3d screenshots
are now working, but those are even slower to generate than the GraphTool
problems.
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/openwebwork/webwork2/pull/3247?email_source=notifications&email_token=ABEDOAFGISR3ANVB7NVUTQD52JL4BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMBRGAYDCMZTGUZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM*pullrequestreview-6010013353__;Iw!!Ka_JY85zDv0FFw!keQetwEiqYETfy0r5-zIXTZKWkDqNsHWRF1sZqlEmciPaf-1noMbMz4RO6DPenlrmZAMO1e1JwH3O7_T5gdpCoZkbaA$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ABEDOACQFXQC62CFE5B3SWT52JL4BAVCNFSNUABDKJSXA33TNF2G64TZHMZTANRUGU3TGO2JONZXKZJ3GU4TGNZVHA2TKMBUUF3AE__;!!Ka_JY85zDv0FFw!keQetwEiqYETfy0r5-zIXTZKWkDqNsHWRF1sZqlEmciPaf-1noMbMz4RO6DPenlrmZAMO1e1JwH3O7_T5gdpohdcPRs$>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://urldefense.com/v3/__https://github.com/notifications/mobile/ios/ABEDOAGVQTULRO4CEXL7H2T52JL4BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMBRGAYDCMZTGUZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y__;!!Ka_JY85zDv0FFw!keQetwEiqYETfy0r5-zIXTZKWkDqNsHWRF1sZqlEmciPaf-1noMbMz4RO6DPenlrmZAMO1e1JwH3O7_T5gdpkjqlteQ$>
and Android
<https://urldefense.com/v3/__https://github.com/notifications/mobile/android/ABEDOAGMIKDHYDSVFSPRMNL52JL4BA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMBRGAYDCMZTGUZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI__;!!Ka_JY85zDv0FFw!keQetwEiqYETfy0r5-zIXTZKWkDqNsHWRF1sZqlEmciPaf-1noMbMz4RO6DPenlrmZAMO1e1JwH3O7_T5gdpeo4H_nw$>.
Download it today!
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Yeah, I can help with cleaning up the JavaScript. Sometimes the code generated by AI is painful to read and understand because it adds convoluted code to achieve a simple end. |


As described in the title. But also, if the problem fails to render, rather than a screenshot, include the error message in the email. When I have
$external_authset, this will be useful for letting me see the student's issue without needing to log in. (Maybe this feature should only come into play when$external_authis set?)Claude's first commit message explains more fully how the screenshot behavior is controlled:
If
$mail{feedbackScreenshot}is set in site.conf (it is disabled bydefault), then when the "Email Instructor" button is clicked on a problem
page, a screenshot of the rendered problem is taken in the browser and sent to
the feedback page. The feedback page shows the screenshot with a checkbox that
allows the student to choose to include it. The checkbox is unchecked by
default, so that screenshots are only sent when they would be helpful. The
screenshot is embedded in the html version of the email (in a
multipart/related part referenced by its content id), and attached to the text
version of the email (in a multipart/mixed part). Screenshots larger than the
maximum attachment size are not included.
The screenshot is taken with the modern-screenshot javascript package. The
following issues with that package are worked around:
feedback buttons) are rendered as the text of the image url.
their offset parent, which is often outside of the problem body, and so are
not in the right place or not in the screenshot at all. The screenshot is
also expanded to include popovers that extend outside of the problem body.
MathJax output that extend outside of the svg (for example the tail of a Q)
are clipped.
The PNG images created by browsers are not well compressed. So the screenshot
is converted to a palette image with at most 256 colors and compressed with
GD when it is received by the server. This reduces the size of a typical
screenshot to about 30% of the original size with no visible difference.