CH 10Basic

Attendance Management

Two attendance systems run side by side today: a class-section-based daily attendance system (DailyAttendance) that powers leave requests, chronic-absence detection, locking, and the admin school-wide overview, and an older course-level attendance system (Attendance) still used by the teacher's per-course marking screens and student self-check-in. Both feed parent notifications and downstream analytics.

Basic Tier Features

Basic

Class-Section Daily Attendance

Basic
  • DailyAttendance model: school → class → section → student → date, with 8 status values (present, absent, late, half_day, medical_leave, approved_leave, holiday, excused)
  • Bulk mark a whole class-section for a date in one request; unique compound index prevents duplicate records
  • A class with no sections is marked as a whole: omit sectionId and the record has no section (DailyAttendance.section is optional). A class that has sections still needs one chosen, otherwise the request is rejected with 400
  • Admin school-wide overview: per-class/section totals and percentage, aggregated in a single pipeline
  • Parent notification created automatically for absent/late/half-day marks
  • Web: /dashboard/admin/attendance (overview) · /dashboard/parent/attendance, /dashboard/student/attendance

Legacy Course-Level Attendance

Basic
  • Original Attendance model: one record per student per course per date (present/absent/late/excused)
  • Teacher bulk-marks a course roster via a single MongoDB bulkWrite upsert — used by the course-scoped teacher UI
  • Course-level attendance analytics: per-student present/absent counts and percentage via aggregation
  • Student self-check-in (studentMarkToday / studentToday) when a school enables self-marking
  • Web: /dashboard/teacher/attendance/[courseId]/today, /[date], /calendar

Leave Requests

Basic
  • Parent submits a leave request for a child: type (medical/personal/emergency/sports/school_activity/other), date range, reason, supporting documents
  • Teacher or admin reviews and approves/rejects with remarks
  • On approval, attendance records for every day in the range are bulk-written as medical_leave or approved_leave and linked back to the leave request
  • Web: /dashboard/parent/leave-requests (submit) · /dashboard/admin/attendance (review queue)

Chronic Absence Detection

Basic
  • Aggregation over a rolling window (default 30 days) flags students at or above an absence-count threshold (default 3)
  • Threshold and window are query-parameter configurable per request
  • Surfaces on the admin "At-Risk Students" tab with student name, admission number, and absence count

Attendance Corrections & Locking

Basic
  • Every DailyAttendance record carries a lockExpiry (default 48 hours after marking) and an isLocked flag
  • Marking is blocked outright if any targeted record is already locked
  • Correcting a locked record requires the super_admin role; the previous status, reason, and approver are stored on the record
  • Every correction is written to AuditLog with actor, old value, new value, and IP

Teacher & Staff Attendance

Basic
  • TeacherAttendance model: present/absent/late/half_day/on_leave, with check-in/check-out time strings
  • Teacher self-marks their own daily attendance; admin views school-wide teacher attendance for any date
  • Monthly self-summary with present/absent counts and percentage
  • This dataset is shared with the Chapter 19 HR & Payroll module for staff attendance reporting

Attendance Analytics

Basic
  • Monthly per-student analytics for a class-section: total, present, absent, late, leave counts and percentage
  • Results sorted ascending by percentage so the lowest-attendance students surface first
  • Attendance percentage is consumed downstream by Chapter 12 report cards (attendance summary block) and promotion eligibility checks

Staff Check-In / Check-Out with Location — New

Basic
  • POST /api/hr/attendance/check-in and /check-out: every staff role records its own day. The date and HH:MM time come from the server clock (IST), never from the phone
  • Status is set at check-in: present, or late when the time is past the assigned shift's start plus its grace period (15 minutes by default). Staff without a shift are always present
  • TeacherAttendance gains checkInLocation and checkOutLocation ({ lat, lng, accuracy in metres, address, capturedAt }). Both are optional on the API and range-checked (lat ±90, lng ±180)
  • Mobile requires a location: it asks for foreground location permission, reads a high-accuracy fix (15 s timeout, then the last known position) and reverse-geocodes an address when it can. If permission is denied or GPS is off, check-in is blocked with an instruction. Web asks the browser and carries on without a location if it is refused
  • Check-in is idempotent for a day. A day already marked on_leave returns 409. Check-out needs a check-in first and is never earlier than the check-in time
  • Admin register: GET /api/hr/attendance/register lists every HR-enrolled staff member for a date with status, times, both locations, remarks and a selfMarked flag. Staff with no record show as not_marked; staff on approved leave as on_leave
  • POST /api/hr/attendance/bulk saves only the rows an admin changed (max 500). Marking a row absent or on_leave clears its times and its locations
  • Locations are recorded, not verified: nothing compares them with the school's address and a mock-GPS app can fake them. Approved regularization requests change the times but keep the original locations
  • Mobile: (admin)/my-hr.tsx (check in/out + own history), (admin)/hr-attendance.tsx (register). Web: /dashboard/my-hr, /dashboard/admin/hr/attendance

Staff Attendance Export — New

Basic
  • Mobile exports the filtered register as a real .xlsx file (Staff_Attendance_<date>.xlsx) and opens the share sheet
  • Columns: Date, Employee Name, Email, Role, Status, Check-In, Check-In Location, Check-In Map Link, Check-Out, Check-Out Location, Check-Out Map Link
  • Location columns carry the street address (or coordinates when no address could be found) and a Google Maps link. Absent and on-leave rows export blank times and locations
  • Web exports the same columns plus Remarks as CSV (Staff_Attendance_Register_<date>.csv)
  • Free-text cells (names, emails, addresses) are escaped against spreadsheet formula injection

Subject-Teacher Access Control — New

Basic
  • A teacher can mark, view, correct and analyse course attendance only for subjects they teach (as main teacher or co-teacher). Anyone else gets 403 "You are not the teacher of this subject"
  • Applies to POST /api/attendance/mark, GET /api/attendance/course/:courseId, PUT /api/attendance/:attendanceId and GET /api/attendance/analytics/:courseId. Admins and super admins are unaffected
  • Checked on every request through utils/courseAccess.teachesCourse, so when an admin gives a subject to another teacher (Chapter 11) the previous teacher loses access immediately

Planned — Not Yet Implemented

Not Yet Implemented

Basic
  • Biometric and RFID attendance check-in — marking is manual only today
  • Excel/CSV/PDF export of class attendance reports (daily, monthly, student history) — only the staff attendance register exports today
  • Morning/afternoon sub-tracking within a Half-Day record — currently a single half_day status, not a split object
  • Bulk correction of multiple records in one request, and bulk leave approval
  • Attendance-driven exam hall-ticket blocking (attendance % currently feeds report cards and promotion checks, but does not yet gate exam registration directly)

API Reference — Chapter 10

Class Daily Attendance

POST/api/class-attendance/mark

Bulk-mark a class-section for a date (teacher, admin, super_admin)

GET/api/class-attendance

Fetch records filtered by classId, sectionId, date

GET/api/class-attendance/school-overview

Admin: school-wide daily summary grouped by class-section

GET/api/class-attendance/analytics

Monthly per-student analytics for a class-section

GET/api/class-attendance/chronic-absentees

List students flagged for chronic absence

GET/api/class-attendance/student/:studentId/summary

Student/parent-facing attendance summary + records

PUT/api/class-attendance/:id/correct

Correct a record (audited); super_admin required if locked

POST/api/class-attendance/lock

Lock all records for a class-section-date

Leave Requests

POST/api/class-attendance/leave-requests

Parent (or admin) submits a leave request for a student

GET/api/class-attendance/leave-requests

List leave requests, filterable by studentId/status

PUT/api/class-attendance/leave-requests/:id/review

Teacher/admin approves or rejects; approval bulk-updates attendance

Teacher Attendance

POST/api/class-attendance/teacher/mark

Teacher self-marks attendance with check-in/check-out

GET/api/class-attendance/teacher/my

Teacher's own monthly attendance + summary

GET/api/class-attendance/teacher/school

Admin: school-wide teacher attendance for a date

Legacy Course Attendance

POST/api/attendance/mark

Bulk-mark attendance for a course and date (teacher, admin)

GET/api/attendance/course/:courseId

List attendance for a course, optional ?date=

GET/api/attendance/student/:studentId

List a student's attendance records

PUT/api/attendance/:attendanceId

Update a single attendance record

GET/api/attendance/analytics/:courseId

Per-student present/absent counts and percentage for a course

POST/api/attendance/student/mark

Student self-marks today's attendance

GET/api/attendance/student/today

Student views today's own attendance record

Staff Check-In & Register (HR module)

POST/api/hr/attendance/check-in

Signed-in staff member checks in; server sets date and time, optional location in the body

POST/api/hr/attendance/check-out

Check out; optional location. Requires a check-in for the day

GET/api/hr/attendance/register

HR: every enrolled staff member for ?date= with times, locations and not_marked / on_leave

POST/api/hr/attendance/bulk

HR: save the changed register rows (max 500)

GET/api/hr/attendance

HR: attendance records filtered by employee, date range and status

GET/api/hr/attendance/today

Today records: HR sees everyone, other staff only their own

Frontend Pages

PathRoleDescriptionTier
/dashboard/admin/attendanceAdminSchool overview, teacher attendance, leave review, chronic-absence tabBasic
/dashboard/admin/analytics/attendanceAdminAttendance analytics dashboardBasic
/dashboard/teacher/attendanceTeacherCourse list for attendance markingBasic
/dashboard/teacher/attendance/[courseId]/todayTeacherMark today's attendance for a courseBasic
/dashboard/teacher/attendance/[courseId]/[date]TeacherMark/edit attendance for a specific dateBasic
/dashboard/teacher/attendance/[courseId]/calendarTeacherCalendar view of a course's marked datesBasic
/dashboard/student/attendanceStudentOwn attendance record viewBasic
/dashboard/parent/attendanceParentChild's daily attendance summary (class-section based)Basic
/dashboard/parent/leave-requestsParentSubmit and track leave requests for a childBasic
/dashboard/my-hrEvery staff roleCheck in / check out with location and own attendance historyBasic
/dashboard/admin/hr/attendanceAdminStaff register with check-in and check-out locations, CSV exportBasic

Mobile Screens

(student)/attendance.tsx
Personal attendance calendar and percentage
Basic
(parent)/attendance.tsx
Linked children's attendance widgets
Basic
(teacher)/attendance.tsx
Bulk-mark attendance for a selected course
Basic
(admin)/attendance.tsx
School-wide attendance summary
Basic
(admin)/my-hr.tsx
Staff check-in / check-out with location (re-exported by every staff role)
Basic
(admin)/hr-attendance.tsx
Staff register with locations under the times, Excel export
Basic