# Attendance Workflow

## Teacher flow

1. Open `/teacher`
2. Review today's sessions and alerts for missing attendance
3. Open `/teacher/sessions`
4. Choose a session and open the attendance screen
5. Mark `present / absent / late / excused`
6. Save or `Save & complete`

## What happens on save

- Attendance is upserted by `(attendance_session_id, enrollment_id)`
- Only `confirmed` enrollments appear in the attendance sheet
- Every save is written to `audit_logs`
- If the session is the cohort's first scheduled session:
  - `enrollments.first_session_attended_at` is set for present/late learners
  - `enrollments.attendance_confirmed_at` is set on first presence confirmation

## Admin flow

- `/admin/attendance` shows overview KPIs and per-session summary
- `/admin/attendance/manage` keeps the manual attendance screen for operations
- `/admin/attendance/no-show` lists confirmed learners who missed the first session after the operating threshold
- From the no-show list, operations can queue a WhatsApp follow-up in the outbox using the `no_show_followup` template

## Publish / status rules

- Attendance list shows only enrollments with `status = confirmed`
- Cancelled sessions cannot be edited
- Locked sessions are treated as completed
- Teacher access is limited to assigned cohorts/sessions through:
  - `course_sessions.instructor_id`
  - or `cohort_instructors.instructor_user_id`

## Notes

- Public registration fields do not affect attendance visibility until the enrollment is confirmed
- The current module is ready for optional reminder hooks later without changing the core attendance workflow
