attendance module
Class attendance across registered subjects. Overview cards, a goal percentage, and a day-to-day calendar.
Related: Architecture Overview, Data Layer & API Integration.
Component architecture#
flowchart TD Att["Attendance.jsx"] --> Card["AttendanceCard.jsx"] Att --> Circle["CircleProgress.jsx"] Att --> Cal["ui/calendar"] Att --> Tabs["ui/tabs overview daily"] Att --> Sheet["ui/sheet tracker"] Card --> Circle Card --> Chart["recharts LineChart"]
State management and props interface#
| Prop | Purpose |
|---|---|
w |
WebPortal or MockWebPortal |
attendanceData |
Cache keyed by registration_id |
semestersData |
Meta from get_attendance_meta |
selectedSem |
Current semester |
attendanceGoal |
1–100, default 75 |
subjectAttendanceData |
Daily rows per subject name |
selectedSubject |
Open sheet |
activeTab |
"overview" or "daily" |
dailyDate |
Day-to-day date |
calendarOpen |
Calendar popover |
isTrackerOpen |
Prefetch progress sheet |
subjectCacheStatus |
idle / fetching / cached |
Each has a matching setter from AuthenticatedApp.
Data flow and fetching strategy#
flowchart TD
Mount["mount"] --> Meta["w.get_attendance_meta"]
Meta --> Latest["meta.latest_semester"]
Latest --> Att["w.get_attendance header latestSem"]
Att -->|NO Attendance Found| Prev["semesters[1]"]
Change["handleSemesterChange"] --> Hit{"attendanceData[id]?"}
Hit -->|yes| Skip["stop"]
Hit -->|no| Fetch["get_attendance"]On miss of the latest semester, Attendance falls back to the previous entry in meta.semesters.
Subject data processing#
studentattendancelist maps to cards. Attended and total sum L/T/P present and class counts.
| Field | Meaning |
|---|---|
subjectcode |
Display name |
Ltotalclass, Ltotalpres |
Lecture |
Ttotalclass, Ttotalpres |
Tutorial |
Ptotalclass, Ptotalpres |
Practical |
LTpercantage |
Combined (API spelling) |
subjectid, individualsubjectcode |
Daily fetch keys |
classesNeeded = ceil((goal * total - 100 * attended) / (100 - goal))
classesCanMiss = floor((100 * attended - goal * total) / goal)
handleGoalChange keeps values in 1–100.
Feature: overview tab#
flowchart TD List["subjects map"] --> Card["AttendanceCard"] Card --> Click["setSelectedSubject"] Click --> Daily["fetchSubjectAttendance if uncached"]
AttendanceCard strips trailing (...) from names, shows L/T/P percents, CircleProgress for combined, and Attend X / Can miss Y.
Feature: day-to-day tab#
flowchart TD Tab["activeTab daily"] --> Prefetch["Promise.all subjects"] Prefetch --> Status["subjectCacheStatus"] Status --> Cal["Calendar hasActivity"] Cal --> List["classes for dailyDate"]
Statuses: idle, fetching, cached. A floating CircleProgress opens a sheet with Check / Loader2 / AlertCircle per subject.
hasActivity adds an inset primary bar on dates that have classes.
Feature: subject detail sheet#
flowchart TD Sheet["Sheet"] --> Cal["Calendar modifiers present/absent"] Sheet --> Detail["classes for selectedDate"] Sheet --> Line["processAttendanceData LineChart"]
Modifiers cover one, two, or three classes per day (solid, split gradient, conic mix). Colors use color-mix with --chart-3 and --chart-5.
processAttendanceData sorts records, accumulates present/total, one point per date, Line on percentage.
Data fetching methods#
fetchSubjectAttendance collects Lsubjectcomponentid, Psubjectcomponentid, Tsubjectcomponentid, then:
w.get_subject_daily_attendance(
selectedSem,
subjectData.subjectid,
subjectData.individualsubjectcode,
subjectcomponentids
)
Return shape: { studentAttdsummarylist: [{ datetime, classtype, present, attendanceby }] }.
UI components used#
Select, Input, Calendar, Tabs, Sheet, Progress, Recharts, lucide Check Loader2 AlertCircle.
Sticky header uses top-14. Theme tokens: --foreground, --chart-*.
Demo mode data structure#
MockWebPortal.get_attendance_meta sorts EVESEM first in Jan–July.
attendance.semestersData
attendance.attendanceData["2025EVESEM"]
attendance.subjectAttendanceData["15B11EC611"]
Error handling#
Latest semester empty → previous semester. Semester-specific miss caches { error: "Attendance not available for this semester" } and the UI prints that string.
Performance optimizations#
Semester cache, subject daily cache, subjectCacheStatus to skip work. Daily fetch runs only on the daily tab or card click.
Integration points#
Parent: AuthenticatedApp. Data: w. UI: Base UI Components, Custom Feature Components.