grades module
Three tabs. SGPA/CGPA chart, grade cards, marks. Real marks go through Pyodide and PyMuPDF. Demo marks come from download_marks.
See Attendance Module, Exams Module, Subjects Module, Profile Module.
| Tab | Method |
|---|---|
| Overview | w.get_sgpa_cgpa() |
| Semester | w.get_grade_card(semester) |
| Marks | demo w.download_marks, real Pyodide PDF |
Component architecture#
flowchart TD Grades["Grades.jsx"] --> Chart["InteractiveGPAChart / LineChart"] Grades --> GC["GradeCard.jsx"] Grades --> MC["MarksCard.jsx"] Grades --> Dialog["download marks Dialog"] Grades --> Py["loadPyodide + wheels"]
State management#
Core data state#
flowchart TD Overview["gradesData"] --> Chart Cards["gradeCards[registration_id]"] --> GC Marks["marksData[registration_id]"] --> MC
Caches skip refetch when the semester key exists.
Data flow and API integration#
Initial data loading#
flowchart TD Mount["Grades mount"] --> SGPA["w.get_sgpa_cgpa"] Mount --> SemGC["w.get_semesters_for_grade_card"] Mount --> SemM["w.get_semesters_for_marks"]
Semester change: set loading, pick semester, if gradeCards[value] use it, else w.get_grade_card(semester) and write cache.
Overview tab#
Data visualization#
flowchart LR Data["gradecard rows"] --> Line["SGPA chart-1 CGPA chart-2"]
Fields include stynumber, sgpa, cgpa, earnedgradepoints, totalcoursecredit. Grid uses --border, axes --muted-foreground.
Semester tab#
Grade card structure#
flowchart TD Select["semester Select"] --> Card["GradeCard"] Card --> Code["subject code + desc"] Card --> Grade["letter getGradeColor"] Card --> Pts["credits + points"]
getGradeColor maps A+ → text-grade-aa through F → text-grade-f.
Marks tab#
Dual-mode operation#
flowchart TD
Pick["selectedMarksSem"] --> Kind{"w instanceof MockWebPortal"}
Kind -->|yes| DL["w.download_marks"]
Kind -->|no| PDF["Pyodide fetch PDF parse_report"]Real path:
- Endpoint
/studentsexamview/printstudent-exammarks/{instituteid}/{registration_id}/{registration_code} - Headers from
w.session.get_headers(generate_local_name()) loadPyodide(), load PyMuPDF andjiit_marks-0.2.0from${artifactBaseUrl}parse_report(doc)then convert to JS
Wheels are listed in VitePWA additionalManifestEntries.
Marks data structure#
flowchart TD
Root["{ courses: [] }"] --> Course["code name"]
Course --> Exams["exams Mid Term End Term"]
Exams --> Marks["OM FM"]MarksCard progress bar. Colors: outstanding ≥80, good ≥60, average ≥40, poor below.
Download marks dialog#
handleDownloadMarks calls w.download_marks(semester). Real mode downloads the PDF. Demo returns JSON and does not write a file.
UI components and styling#
Radix Tabs three columns. Select on semester and marks tabs. Chart ResponsiveContainer height 250.
Error handling#
- Overview:
"Unexpected end of JSON input"→ “Grade sheet is not available” - Empty semester lists → not available yet
- PDF errors log;
marksLoadingalways clears infinally
Integration with mock data system#
fakeData.grades.gradesData
fakeData.grades.gradeCardSemesters
fakeData.grades.gradeCards[semKey]
fakeData.grades.marksSemesters
fakeData.grades.marksData[semKey]
Matching MockWebPortal methods: get_sgpa_cgpa, get_semesters_for_grade_card, get_grade_card, get_semesters_for_marks, download_marks.
Performance considerations#
Separate caches, lazy marks load, 30MB SW cache for wheels.
Theme integration#
--chart-1 SGPA, --chart-2 CGPA, --grade-*, --marks-*. See Theme System.