fix: pass offerings to slotUsedWeight in semester-row so FY units aren't double-counted" #15
Open
coldfinity wants to merge 1 commit into
Open
Conversation
…n't double-counted semester-row.tsx was the only call site of slotUsedWeight that omitted the offerings parameter. Without it, full-year units had their entire CP counted toward usedWeight in each semester (weight=2 for a 12cp unit instead of weight=1), causing the 'X / Y units' display to show incorrect numbers. Fixes monashcoding#13
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.
Problem
Full-year (FY) units like FIT3170 (12cp, runs across S1+S2) appear in both S1 and S2 of a year, with each twin contributing half the unit's workload per semester. The planner displays
usedWeight / capacity unitson the left rail to show how full each semester is.But semester-row was double-counting FY units:
2 / 4 units1 / 4 units2 / 4each1 / 4each5 / 4 units(overflow!)3 / 4 unitsA student adding a single FY unit would see "2 / 4 units" and think the semester was half-full when it wasn't. With multiple FY units the display could even show
usedWeight > capacity.Root cause
slotUsedWeightintypes.tshas an optionalofferingsparameter. When present, it checks whether a unit is full-year viaisFullYearTwinSlotand halves its CP contribution per semester (so a 12cp FY unit = weight 1 per semester, not 2). Withoutofferings, the FY check is always skipped.semester-row.tsxwas the only call site (out of 10) that omittedofferings:offerings?semester-row.tsxsemester-slot.tsxdraggable-unit-row.tsxplan-grid.tsx(6 calls)progress.tsvalidation.tsFix
2-line change in
packages/webapp/components/planner/semester-row.tsx:Testing
pnpm --filter webapp build
To verify
FULL_YEAR)1 / 4 unitsfor each semester, not2 / 42 / 4, not4 / 4and overflowingFixes #13.