Repository navigation
Add feedback.add_image to show plots with test results - #42
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eliotwrobson
added a commit
to PrairieLearn/PrairieLearn
that referenced
this pull request
Nov 11, 2026
Uses feedback.add_image from PrairieLearn/grader-python-v2#42, which needs to be published before this merges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
eliotwrobson
marked this pull request as ready for review
November 11, 2026 17:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The legacy grader showed students their plot with the grading results. This grader had no way to return an image, so plot questions lost that feedback.
feedback.add_image(image, label=None)takes a matplotlibFigureorAxes, such as a plot queried from student code, or PNG bytes. It adds the image to the test'simagesinresults.json, which<pl-external-grader-results>shows under the test. A plot is drawn as a PNG from theFigurethat the grader rebuilt from the student's plot. matplotlib is only imported when a plot is passed, so the:liteimage still works without it.quick_start.mddocuments it in a new "Showing Plots to Students" section. That file conflicts with the rewrite in #38, so I'll move the section over to whichever of the two merges second.Testing
tests/test_feedback.pydecode each image and check for the PNG signature.test_plain_matplotlibscenario adds a queried plot to the results. The scenario runner now checks image labels and data URL prefixes. It doesn't compare PNG bytes, because those depend on the matplotlib version.🤖 Generated with Claude Code