feat: grade-relative FLN certification distance algorithm - #218
Open
jgupta05072003-code wants to merge 1 commit into
Open
feat: grade-relative FLN certification distance algorithm#218jgupta05072003-code wants to merge 1 commit into
jgupta05072003-code wants to merge 1 commit into
Conversation
Certification was checked everywhere (backend + frontend, 9 call sites) as a flat currentLevel >= 5 threshold, regardless of grade. That's wrong: the 93-level framework assigns different level ranges per class (Class 2 ends at level 61, Class 3 at 75, Class 4 at 93 - see FLN_LEVELS_LIST), so a Class 4 student at level 60 was being counted as "certified" for having crossed a flat bar meant for nothing in particular. backend/src/certification.ts is the source of truth: getDistanceToCertification returns how many levels remain until a student's grade-appropriate ceiling (0 = certified, null = classGroup not a recognized enrolled grade). Mirrored on the frontend as CLASS_CERTIFICATION_LEVEL/isCertified next to FLN_LEVELS_LIST since that's where the class->level-range mapping actually lives. Wired in: - GET /api/students now returns certificationDistance per student - GET /api/stats and GET /api/analytics(/superadmin) certification counts/rates now use the grade-relative check instead of the flat one - All 7 frontend call sites in RoleDashboards.tsx/PanelViews.tsx doing their own currentLevel >= 5 math updated to isCertified() Verified: tsc --noEmit clean on both workspaces; aggregation logic checked against a scratch MongoDB collection (4 students across Class 2/4, correctly counted 2 certified - the two at their grade's ceiling, not the two merely above the old flat threshold of 5).
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.
Summary
This is the algorithm Pavani flagged as the top pilot-readiness blocker in the 2026-08-17 sync: student current level → distance to FLN certification. Per clarification, "distance" means how many more levels a student needs to cover, after their diagnostic placement, to be certified for their specific grade — not a flat number.
Turns out the whole codebase (9 call sites, backend + frontend) was checking certification as a flat
currentLevel >= 5, regardless of class. That's wrong under the 93-level framework: each grade owns a different level range (Class 2 → levels 43-61, Class 3 → 62-75, Class 4 → 76-93, perFLN_LEVELS_LIST). A Class 4 student at level 60 was being counted as certified for crossing a bar that has nothing to do with their grade's actual ceiling.Changes
backend/src/certification.ts(new) — source of truth.getDistanceToCertification(classGroup, currentLevel)returns levels remaining (0 = certified,null= unrecognized grade).CLASS_CERTIFICATION_LEVELmap: Class 2→61, Class 3→75, Class 4→93 (only these three are enrolled today perseed.ts).GET /api/studentsnow returnscertificationDistanceper student.GET /api/statsandGET /api/analytics(/superadmin) certification counts/rates switched from the flat Mongo$gte: 5match to a grade-aware$or.CLASS_CERTIFICATION_LEVEL/isCertified()next toFLN_LEVELS_LIST(the actual source of the class→level-range mapping) inRoleDashboards.tsx; all 7 othercurrentLevel >= 5call sites acrossRoleDashboards.tsx/PanelViews.tsxupdated to use it.Test plan
tsc --noEmitclean on both workspaces