Conversation
The v2 report templates pipe `percentage` and `accuracy` through `"%.Nf"|format(...)`, which raises TypeError on None and surfaces as a Lambda 500. Upstream stores these as DynamoDB NULL when no questions were attempted in a subject (e.g. a student skipped all 25 Maths questions: 0 correct / 0 wrong is mathematically undefined, so the producer wrote NULL rather than 0). Two-layer fix: - render_v2_report() now coerces None -> 0 for `percentage` and `accuracy` on both `overall_performance` and each entry in `subject_performance`, so any consumer of the v2 payload sees clean numerics. - v2 and v2_print templates additionally guard each `%.Nf|format(...)` call with `or 0` as a defense-in-depth fallback. Also imports `json` at the top of routers/student_quiz_reports.py — it was used at line 656 (chapter_to_link_map = json.load(...)) but never imported, a latent NameError on the v3 codepath that flake8 flagged when committing this change. One-line drive-by fix. Follow-up worth filing separately: the v2 producer / ETL should emit 0.0 (or an explicit not-attempted flag) instead of NULL for these fields, and any existing rows with NULL accuracy should be backfilled. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-templates Fix 500 on student_quiz_report_v2 when a subject is fully skipped
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.
No description provided.