ProductAttendance

Attendance

One-line: Daily student attendance per class, with history, calendar, and a student self-view.

What it does

Attendance lets a school record who was present, absent, late, or excused for each class, one day at a time. A class teacher marks the whole class in a single action, and the school can then review attendance history by class, by student, or as a calendar that merges in holidays. Students (and, on the roadmap, parents) can see their own attendance and percentages.

Who uses it

  • Class teachers — mark attendance for their assigned class, mainly on the mobile app (MyClassesScreen, MarkAttendanceScreen).
  • School admins / office staff — review grids, per-student calendars, and reports in admin-web at /attendance.
  • Students — view their own attendance (GET /api/attendance/me) on mobile (MyAttendanceScreen).
  • Branch sub-admins — restricted to attendance for classes/students in their own school units.

Key concepts

  • Attendance session — one attendance_sessions row per class per day (v2 model), optionally finalized.
  • Attendance record — one attendance_records row per student per session, holding the status and an optional note.
  • Statusespresent, absent, late, excused.
  • Legacy vs v2 — a flat attendance table coexists with the newer session-based model; both are live.

How it works

  • Mark by class + datePOST /api/attendance/mark upserts all student records at once and returns a summary (present/absent/late counts). Re-marking is allowed so corrections overwrite prior values.
  • History — fetch by class (/class/<class_id>), by student (/student/<student_id>), or filter by date, from_date/to_date, academic_year_id, with pagination.
  • Student self-viewGET /api/attendance/me returns the student’s own totals and monthly breakdown.
  • Calendar/api/attendance/calendar-holidays merges attendance with the holidays table, tagging each date present, absent, holiday, or weekend.

Rules & edge cases

  • Future dates blockedget_or_create_session rejects any session_date after today; holiday dates are rejected too.
  • Skipped rows are reportedupsert_records saves valid rows and returns a skipped list of { student_id, reason } for students not in the class or with an invalid status. Nothing is silently dropped.
  • Teacher scope — a class teacher can only mark their assigned class (class_teachers check).
  • Branch scope — branch-restricted sub-admins can only touch classes/students in their units (core.branch_scope); self-views stay unscoped.
  • Plan gating — the module requires the attendance plan feature to be enabled for the tenant.
  • Tenant scoping — all data is isolated per tenant_id.

Where it lives

  • Backend: server/modules/attendance/ (models.py, routes.py, session_routes.py, services.py, session_services.py), prefix /api/attendance.
  • Admin-web: page /attendance, admin-web/src/services/attendanceService.ts, admin-web/src/components/attendance/.
  • Mobile: client/modules/attendance/.
  • Plan feature key: attendance.