Fix target-grade simulator: make achievability check rounding-consistent#13
Merged
Merged
Conversation
The "what do I need?" simulator compared the required remaining average to the raw target, while every grade in the app is displayed rounded to one decimal. As a result a target whose best achievable final rounds to it (e.g. a best case of 1.504, shown everywhere as "1.5") was reported as unreachable, even though the dashboard would display the achieved grade as exactly the target. Extract the logic into a tested pure function `requiredGradeForGoal` and round the required grade to one decimal before classifying it, so the simulator stays consistent with the rest of the app (the borderline case now reads "you need a 1.0" instead of "unreachable"). 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.
The dashboard "what do I need?" (Zielnote) simulator reported a target as unreachable in a case where the best achievable final grade rounds to exactly that target.
Problem
The simulator compared the required remaining average against the raw target, but every grade in the app is displayed rounded to one decimal. Example (real user data): 60 ECTS graded at a 2.0 average, 60 ECTS remaining, target 1.5.
(The raw math itself was correct: a 1.2 average on the remainder yields a 1.6 final, not 1.5 — 1.2 is actually the requirement for a 1.6 target.)
Change
requiredGradeForGoalinsrc/lib/grades.tsand round the required grade to one decimal before classifying it, matching the rest of the app.safe/unreachablethresholds reuse the existingBEST_GRADE/PASS_THRESHOLDconstants.src/components/learn/grade-goal.tsxnow calls the shared function instead of computing inline.Verification
grades.test.tscover the exact reported scenario (1.5 → needed 1.0; 1.6 → needed 1.2), plus truly-unreachable, safe, and no-remaining-ECTS cases. Full grade suite green (26 tests),tsc --noEmitandeslintclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01LWLUNyHYuCpouMEUo3P456
Generated by Claude Code