Fix grade average: allow large grade matrices and decouple bonus from the final grade#12
Merged
Conversation
…al grade - Raise the grade-scale row limit from 30 to 200 so fine-grained percent→grade matrices (e.g. 32 rows) can be saved. The jsonb column has no limit; the cap was purely an over-strict validation that rejected the save with an error. - Compute a module's final grade purely from the achieved percentage via the grade scale. A configured assignment bonus is still computed and shown for information, but no longer shifts the final grade (neither percent points nor grade steps). This keeps the grade the user derives from percentage + matrix stable, and makes the ECTS-weighted dashboard average match a manual calculation. - Drop the now-misleading inline "bonus applied" label next to the percentage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LWLUNyHYuCpouMEUo3P456
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.
Fixes a dashboard grade-average discrepancy. Two root causes:
1. Grade matrix (Notenmatrix) could not be saved
The percent→grade scale is stored in a
jsonbcolumn with no size limit, but the server action validated it withgradeScaleSchema.max(30). A user with a 32-row matrix got a validation error on save. Because the matrix never saved, the app fell back to the 10-row default scale, so module grades were derived from the wrong scale — which is what threw off the ECTS-weighted dashboard average.src/app/[locale]/(app)/studies/actions.ts). A percent→grade table can legitimately be fine-grained (up to ~one row per percentage point). Grade-value range stays1–6(German scale). No schema/migration change — the column is alreadyjsonb.2. Bonus must not change the final grade
A per-module assignment bonus (
percent_points/grade_steps) was raising the grade derived from the achieved percentage. The final grade a user enters via percentage + matrix should be final and not shifted by a bonus.moduleFinalGradenow derives the grade purely fromachieved percentage → grade scale(src/lib/grades.ts). The bonus is still computed and returned for informational display, but no longer alters the grade or the reported percentage.Verification
vitestgrade tests updated to assert the bonus no longer changes the grade, plus a new test proving the same module yields the same grade with or without a configured bonus. Full suite green (77 passing),tsc --noEmitandeslintclean..max(30)rejects a 32-row scale, the new.max(200)accepts it, and a 32-row scale round-trips through thegrade_scalejsonb column.🤖 Generated with Claude Code
https://claude.ai/code/session_01LWLUNyHYuCpouMEUo3P456
Generated by Claude Code