fix(text-response): fix null handling of old solution evaluation breakdowns#8473
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime error when rendering text-response answer JSON for legacy autograding results that predate the introduction of evaluation_results, and ensures instructors can re-run autograding for affected text-response questions to repopulate the missing breakdown.
Changes:
- Guard
solutionResultsrendering in the text-response Jbuilder partial on presence ofevaluation_resultsto avoidnil.index_bycrashes for legacy records. - Extend the grading UI to show the Re-evaluate Answer button for autogradable text-response questions (in addition to programming questions).
- Add controller-spec regression coverage for both legacy (no
evaluation_results) and current (hasevaluation_results) autograding result shapes when rendering#show.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
app/views/course/assessment/answer/text_responses/_text_response.json.jbuilder |
Skips solutionResults block unless evaluation_results exists, preventing nil.index_by 500s for older persisted results. |
client/app/bundles/course/assessment/submission/containers/QuestionGrade.tsx |
Enables Re-evaluate Answer for autogradable text-response questions to allow regeneration of missing breakdown data. |
spec/controllers/course/assessment/submission/answer/answers_controller_spec.rb |
Adds end-to-end #show regression tests covering both legacy and current autograding result structures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Bug
Rollbar flagged a
NoMethodError: undefined method 'index_by' for nilwhen renderingthe text response answer partial
(
_text_response.json.jbuilder).The
solutionResultsblock reads the persisted auto-grading result:The
evaluation_resultskey was only introduced in commitb6da95a4ad("feat(text-response): implement spreadsheet formula autograding"). Answers graded
before that commit have an auto-grading result containing
messagesbut noevaluation_resultskey, so the lookup returnsniland.index_byraises, 500-ing theanswer view.
The guard on the surrounding condition only checked that
resultexisted, not that itcontained
evaluation_results:Remediation
Tighten the guard so the entire
solutionResultsblock is skipped whenevaluation_resultsis absent.We are not backfilling existing DB records. Legacy answers simply render without a
grading breakdown; a user can regrade the answer to repopulate
evaluation_resultsand restore the breakdown on demand.
The recovery path above depends on a grader being able to re-run autograding, but the
Re-evaluate Answer button in
QuestionGrade.tsxwas only rendered for programming and autogradable rubric-based-response questions. We extended the button's render condition to also cover autogradable text-response questions.
Scope check
Audited every
evaluation_resultsreference acrossapp,lib, andspec. The jbuilderis the only read-site of the persisted
auto_grading.result['evaluation_results']hash. All other references are producer-side (building the results in the grading
services) and cannot be nil in the same way. The sibling
result['messages']read issafe —
messageshas existed since the original grading service, so every record has it.Tests
Added regression coverage to
answers_controller_spec.rb(the
#showaction renders this jbuilder end-to-end viarender_views)