Implement coach workflow for attendance tracking
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
In this new workflow, a coach can now mark an attendance session, see previous attendance history logs, and edit previous sessions.
Target branch: release-v0.19.x
Acceptance Criteria
Taking attendance
- [ ] A new section for Class Attendance is added to the Class home page. The section features a prominent "mark attendance" button. The section is first on the top left on browser, and first on the stacked grid on medium and small breakpoints.
- [ ] The section displays a sparkline chart for the most recent 5 previous attendance sessions.
- [ ] When the coach clicks on the "mark attendance" button, it opens a new page for the current attendance session.
- [ ] The attendance page is a
- [ ] At the top of the attendance taking view, an H1 includes the date and the time of the session. The date time is formatted as Date-Month-Year, 00:00.
- [ ] When creating a new session, the date in the header must be a valid date time associated with the timestamp of when the user navigated into the route
/attendance/new - [ ] Class coaches can only take attendance for their own class. Facility Coaches and Admins can take attendance for any classes
- [ ] Coaches mark attendance in a table with two columns: the learners full name and a KSwitch to indicate presence or absence.
- [ ] There are no visible headers in the UI, but there should be visibility-hidden headers, and the table should be semantically accurate as a table.
- [ ] The table should be paginated with 50 learners per page.
- [ ] The learners should be sorted alphabetically by the first letter of their full name.
- [ ] The default state of all KSwitch should be false.
- [ ] When the KSwitch state is True, the row is annotated with "present" immediately to the left of the KSwitch, and has a
$themePalette.blue.v_100background color. - [ ] At the top of the table, there should be another
KSwitchlabeled "Mark all learners present" - [ ] When marking all learners as present, the user is prompted with a
KModalto confirm the changes for any edits - [ ] The bottom bar displays the number of present and absent learners.
- [ ] Submitting attendance should save the attendance to the database.
- [ ] The user should be redirected to the
attendance/historypage after a successful save. A snackbar confirmation should appear on redirect - [ ] If there is an error, the user should remain on the
attendance/newpage and the error should be surfaced to the user in a snackbar.
Editing attendance
- [ ] The attendance history provides a overview of previous sessions, which are links to open the page for the attendance from that session. Past sessions are editable.
- [ ] The attendance history is displayed as a
KTablewith the columsn - [ ] A coach or admin can edit attendance for a previous session after taking attendance, for the current date or previous dates.
- [ ] After attendance is saved, the header associated with an attendance page (at
/attendance/:id) is the datetime stamp at which the attendance was saved to the database. - [ ] On the attendance history page, a date range filter should be implemented with a KDropdown menu containing the following options: Past 7 days, Past 30 days, Past 365 days, custom. "Past 30 days" is the default.
- [ ] If a user selects custom, a KDateRange should open, allowing the user to make a custom selection. When the user makes a selection, the dropdown menu should have a new option added that includes the date range in the format
MM-DD-YYYY - MM-DD-YYYY
Reference images
| Description | Screen(s) |
|---|---|
| A new section for Class Attendance is added to the Class home page. The section features a prominent "mark attendance" button. The section is first on the top left on browser, and first on the stacked grid on medium and small breakpoints. | |
When the coach clicks on the "mark attendance" button, it opens a new page for the current attendance session. At the top of the attendance taking view, an H1 includes the date and the time of the session. Coaches mark attendance in a table view with two columns: the learners full name and a KSwitch to indicate presence or absence. There are no visible headers in the UI, but there should be visibility-hidden headers, and the table should be semantically accurate as a table. The table should be paginated with 50 learners per page. The learners should be sorted alphabetically by the first letter of their full name. The default state of all KSwitch should be false. |
|
When the KSwitch state is True, the row is annotated with "present" immediately to the left of the KSwitch, and has a primary_100 background color. The bottom bar displays the number of present and absent learners. |
|
| The attendance history provides a overview of previous sessions, which are links to open the page for the attendance from that session. Past sessions are editable. | |
On the attendance history page, a date range filter should be implemented with a KDropdown menu containing the following options: Past 7 days, past 30 days, past 365 days, custom. "Past 30 days" is the default. If a user selects custom, a KDateRange should open, allowing the user to make a custom selection. |
|
When editing a session, the user is prompted with a KModal to confirm the changes for any edits |
|
When marking all learners as present, the user is prompted with a KModal to confirm the changes for any edits |
|
If the user navigates away from the page before choosing "Submit attendance" or "Cancel", the should be prompted with a KModal "Are you sure you want to leave this page?" with the options "Continue" or "Cancel" |
Implementation Plan: Attendance Tracking for Coaches
I've analyzed the codebase and designed a phased implementation plan. Here's a summary of the approach:
Architecture Overview
Two-model approach:
AttendanceSession— one record per attendance-taking event (linked to classroom, coach, timestamps)AttendanceRecord— one record per learner per session (linked to session, learner, present/absent boolean)
Both models extend AbstractFacilityDataModel with Morango sync support.
API: REST endpoints under /api/attendance/ for CRUD operations, plus a /recent/ endpoint optimized for the sparkline chart.
Frontend: New route module, composable, and API resource following existing coach plugin patterns (mirroring how quizzes/lessons are structured).
Phased Plan
Phase 1: Data Models & Migrations
- Create
kolibri/core/attendance/Django app withAttendanceSessionandAttendanceRecordmodels RoleBasedPermissionsscoped tocollection(classroom) — coaches for own class, admins for any class- Morango
morango_model_name,infer_dataset,calculate_partitionfor sync
Phase 2: REST API Endpoints
AttendanceSessionViewSetwith nestedAttendanceRecordserialization- Filtering by
collection(class) and date range (start_date/end_date) - Custom
/recent/action returning aggregated present/total counts for sparkline
Phase 3: Frontend Plumbing
- API resource (
attendanceSession.js), composable (useAttendance.js) - Route definitions for
attendance/new,attendance/history,attendance/:id - Page name constants, translation strings, app.js integration
Phase 4: Attendance Taking Page (/:classId/attendance/new)
CoachImmersivePagewith H1 showing session date/time (DD-MM-YYYY, HH:MM)- Semantic table with
CoreTable: learner name +KSwitchtoggle, visibility-hidden headers - Pagination at 50 learners/page, alphabetical sort
- Present rows: blue background (
$themePalette.blue.v_100) + "present" label - "Mark all present"
KSwitchwithKModalconfirmation BottomAppBarwith present/absent counts + submit/cancel- Submit → save → redirect to history with snackbar; error → remain + error snackbar
beforeRouteLeavenavigation guard with "leave page?"KModal
Phase 5: Attendance History Page (/:classId/attendance/history)
CoachAppBarPagewithKTableshowing sessions (date/time link, present, absent, total)- Date range
KDropdownMenu: Past 7 / 30 (default) / 365 days / Custom - Custom selection: date range picker using native date inputs (note:
KDateRangedoesn't exist in KDS v5.5.1) - Custom range adds formatted
MM-DD-YYYY - MM-DD-YYYYoption to dropdown
Phase 6: Attendance Editing (/:classId/attendance/:attendanceId)
- Shares table UI with Phase 4 via extracted
AttendanceTablecomponent - Loads existing session data, H1 shows original save timestamp
KModalconfirmation on save; same error handling and navigation guard patterns
Phase 7: Class Home Page Integration
- New
AttendanceBlockcomponent — first position inKGridlayout - Prominent "Mark attendance"
KButton(primary) AttendanceSparkline— lightweight inline SVG chart (polyline + dots) showing attendance % for 5 most recent sessions- Responsive: first on top-left for desktop, first in stack for mobile
Notes
- No charting library needed — sparkline is 5-point SVG polyline
KDateRangereferenced in issue doesn't exist; using native date inputs with KDS-consistent styling- All attendance pages follow existing coach plugin patterns for consistency
🤖 Generated with Claude Code
I think I have a plan: Add Django attendance models with Morango sync, REST API with date filtering, coach attendance-taking/editing/history pages with sparkline chart on class home page, across 7 implementation phases.
Progress Update: Phases 1 & 2 Complete
Phase 1: Data Models & Migrations ✅
- Created
kolibri.core.attendanceDjango app withAttendanceSessionandAttendanceRecordmodels - Both extend
AbstractFacilityDataModelwith Morango sync support (morango_model_name,infer_dataset,calculate_partition,calculate_source_id) RoleBasedPermissionsscoped to collection (classroom) - coaches for own class, admins for any- 20 model tests passing
Phase 2: REST API Endpoints ✅
AttendanceSessionViewSet(ModelViewSet) with nestedAttendanceRecordserialization- Custom
AttendanceSessionPermissionsto handle nested data in permission validation AttendanceSessionFilterwithDateTimeFilterfor date range queries (start_date/end_date)/recent/endpoint returning aggregated present/total counts for sparkline- 10 API tests passing (CRUD, permissions, date filtering, recent endpoint)
- Registered at
/api/attendance/attendancesession/
Next: Phase 3 - Frontend API Resources & Routing
Progress Update: Phase 4 Complete
Phase 4: Attendance Taking Page ✅
- Full implementation of
AttendanceNewPage.vuereplacing placeholder from Phase 3 - CoachImmersivePage wrapper with date/time heading (DD-MM-YYYY, HH:MM)
- Learner table with KSwitch toggles, alphabetical sort, blue row highlighting for present
- "Mark all present" with KModal confirmation dialog
- Pagination at 50 learners/page with prev/next navigation
- BottomAppBar with present/absent counts + submit/cancel buttons
- Submit flow: saves via API → redirect to history with snackbar; error → stays on page
- Navigation guard with "leave page?" confirmation modal for unsaved changes
- 19 unit tests covering all acceptance criteria
Next: Phase 5 - Attendance History Page
Progress Update: Phases 5 & 6 Complete
Phase 5: Attendance History Page ✅
AttendanceHistoryPage.vuewith session table (date/time link, present, absent, total columns)- Date range filter dropdown: Past 7 / 30 (default) / 365 days / Custom
- Custom date range picker with native date inputs + apply button
- Custom range adds formatted
MM-DD-YYYY - MM-DD-YYYYoption to dropdown - Empty state message when no sessions found
- 13 tests covering table rendering, date formatting, filtering, and custom ranges
Phase 6: Attendance Editing ✅
AttendanceEditPage.vuefor editing existing attendance sessions- Loads session data and shows original save timestamp in heading
- Same table UI as attendance-taking (KSwitch toggles, mark-all, blue row highlights, pagination)
- Save confirmation KModal before submitting changes
- Tracks original state for accurate
hasUnsavedChangesdetection in navigation guard - 12 tests covering data loading, toggling, save confirmation, error handling, and navigation guard
All 44 attendance tests passing (19 + 13 + 12)
Next: Phase 7 - Class Home Page Integration (AttendanceBlock + sparkline)
Progress Update: All Phases Complete
Phase 7: Class Home Page Integration ✅
AttendanceBlock.vue- First grid item on coach class home page withspan: 6layoutAttendanceSparkline.vue- Lightweight inline SVG chart (polyline + dots) showing attendance % trend for 5 most recent sessions- Uses
$themeTokens.primaryfor chart color,role="img"with aria-label for accessibility - "Mark attendance"
KButtonlinking to attendance/new page - "View all" link to attendance/history page
- Empty state when no sessions exist
- 19 tests (10 sparkline + 9 block)
Summary: All 7 Phases Complete
| Phase | Tests |
|---|---|
| Phase 1: Data Models | 20 |
| Phase 2: REST API | 10 |
| Phase 3: Frontend Plumbing | — |
| Phase 4: Attendance Taking | 19 |
| Phase 5: Attendance History | 13 |
| Phase 6: Attendance Editing | 12 |
| Phase 7: Home Page Integration | 19 |
| Total | 93 |
All 63 frontend tests passing. Full attendance tracking workflow implemented: take attendance, view history with date filtering, edit past sessions, and sparkline chart on class home page.
Successfully implemented and released in 0.19.3