Skip to content

Add feedback.add_image to show plots with test results - #42

Merged
eliotwrobson merged 1 commit into
mainfrom
claude/feedback-images
Nov 11, 2026
Merged

eliotwrobson merged 1 commit into
mainfrom
claude/feedback-images

Conversation

@eliotwrobson

Copy link
Copy Markdown
Collaborator

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 matplotlib Figure or Axes, such as a plot queried from student code, or PNG bytes. It adds the image to the test's images in results.json, which <pl-external-grader-results> shows under the test. A plot is drawn as a PNG from the Figure that the grader rebuilt from the student's plot. matplotlib is only imported when a plot is passed, so the :lite image still works without it.

quick_start.md documents 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

  • Unit tests in tests/test_feedback.py decode each image and check for the PNG signature.
  • The test_plain_matplotlib scenario 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

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>
@eliotwrobson
eliotwrobson marked this pull request as ready for review November 11, 2026 17:13
@eliotwrobson
eliotwrobson merged commit 3126734 into main Nov 11, 2026
5 checks passed
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