Implement AttendanceHistoryPage — attendance session history
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Implement AttendanceHistoryPage — a paginated, sortable overview of all attendance sessions for a classroom. Coaches can filter by date range, navigate to any session to edit it, or start a new session from this page. Builds on the stub added in #14236.
Complexity: Medium Target branch: release-v0.19.x
Context
AttendanceHistoryPage is the hub coaches land on after submitting a new session, and the page they return to after editing. It gives a full picture of attendance over time for a class and acts as the navigation hub between AttendanceNewPage and AttendanceEditPage.
The Change
AttendanceHistoryPage (kolibri/plugins/coach/frontend/views/attendance/AttendanceHistoryPage.vue):
CoachAppBarPagewith a back link to the class home page and a "Mark attendance" button linking toATTENDANCE_NEWKTable— sortable table with columns: Date (link to edit session), Present count, Absent count; default sort by date descending- Date range filter (
KSelect) — options: Past 7 days, Past 30 days (default), Past 365 days, All time, Custom- Selecting Custom opens a
KDateRangepicker; on apply, a formattedMM-DD-YYYY – MM-DD-YYYYoption is added to the dropdown
- Selecting Custom opens a
- Pagination — 10 sessions per page with prev/next controls
- Empty state — "No attendance sessions found" message when no sessions match the filter
- Sessions fetched via
fetchSessionswithstart_dateandend_dateparams on mount and on filter change
Design Spec
| Description | Screen |
|---|---|
| Attendance history table | |
| Date range filter options |
Out of Scope
- Taking a new attendance session (separate issue —
AttendanceNewPage) - Editing an existing session (separate issue —
AttendanceEditPage)
Acceptance Criteria
General
- [ ] Sessions are fetched on mount and re-fetched when the date range filter changes
- [ ]
KTabledisplays sessions with Date, Present, and Absent columns, sorted by date descending by default - [ ] Date column entries are links that navigate to
ATTENDANCE_EDITfor that session - [ ] "Mark attendance" button links to
ATTENDANCE_NEW - [ ] "Back to class" link navigates to the class home page
- [ ] Date range filter defaults to "Past 30 days" and includes: Past 7 days, Past 30 days, Past 365 days, All time, Custom
- [ ] Selecting Custom opens a
KDateRangepicker; applying adds a formattedstart – endoption to the dropdown - [ ] Sessions are paginated at 10 per page with prev/next controls
- [ ] "No attendance sessions found" empty state is shown when no sessions match the filter
Accessibility and i18n
- [ ] All user-visible strings are internationalised
- [ ] Date range filter and pagination controls are keyboard navigable
- [ ]
KDateRangevalidation errors are displayed for invalid, future, or out-of-range dates
Testing
- [ ] Sessions load and render correctly in the table
- [ ] Date range filter fetches sessions with correct
start_dateandend_dateparams - [ ] Custom date range applies correctly and updates the dropdown
- [ ] Pagination renders correct subset of sessions
- [ ] Empty state renders when no sessions are returned
References
- Issue #14236 — stub page being fleshed out
- Issue #14242 —
AttendanceNewPage, linked from "Mark attendance" button - Issue #14022 — original feature spec with design references
🤖 This issue was written with AI assistance, under supervision, review and final edits by [@akolson] 🤖
Watching for resolution on behalf of learningequality/kolibri#14243.
Implementation Plan — AttendanceHistoryPage
Architecture
The page uses the existing useAttendance composable (extended with server-side pagination support) to fetch sessions from the AttendanceSessionViewSet API. Sessions are displayed in a KTable with Date, Present, and Absent columns. A KSelect dropdown provides preset date range filters plus a Custom option that opens KDateRange. Server-side pagination via OptionalPageNumberPagination with 10 items per page.
Phases
Phase 1: Extend useAttendance composable
- Add
fetchPaginatedSessions(classId, params)that usesgetCollectionto access pagination metadata (page,count,total_pages) stored by the KolibriCollectionclass - Add
paginationStateref - Update composable mock + tests
Phase 2: Build AttendanceHistoryPage + backend annotations
- Replace stub with full implementation:
CoachAppBarPagewrapper with "Back to class" link + "Mark attendance" buttonKTablewith sortable Date (links toATTENDANCE_EDIT), Present, Absent columnsKSelectdate range filter: Past 7 days, Past 30 days (default), Past 365 days, All time, CustomKDateRangepicker for custom date range — adds formatted option to dropdown- Prev/next pagination controls (10 per page)
- Empty state: "No attendance sessions found"
- All strings internationalized via
createTranslator+ sharedattendanceStrings
- Add
annotate_querysettoAttendanceSessionViewSetforpresent_count/total_counton the main list endpoint (currently only on/recent/action)
Phase 3: Frontend tests
- Component tests covering: page structure, session table rendering, data loading with date params, empty state, pagination controls
Files Changed
| File | Change |
|---|---|
composables/useAttendance.js |
Add fetchPaginatedSessions, paginationState |
composables/__mocks__/useAttendance.js |
Add mock |
composables/__tests__/useAttendance.spec.js |
Pagination tests |
attendanceStrings.js |
Add shared strings |
AttendanceHistoryPage.vue |
Full implementation |
attendance/api.py |
Add annotate_queryset |
attendance/test/test_api.py |
Test count annotations |
__tests__/AttendanceHistoryPage.spec.js |
New component tests |
Implementation Complete — AttendanceHistoryPage
All three phases are implemented with passing tests.
Summary of changes
Phase 1: Composable extension
- Added
fetchPaginatedSessionsandpaginationStatetouseAttendancecomposable - Uses
getCollection+.metadatafor pagination info (page, count, total_pages) - Updated mock for downstream tests
Phase 2: Page component + backend
- Replaced stub
AttendanceHistoryPage.vuewith full implementation:- CoachAppBarPage wrapper with "Back to class" link + "Mark attendance" button
- KTable with Date (links to edit), Present, Absent columns
- KSelect date range filter (7d, 30d default, 365d, All time, Custom)
- KDateRange picker for custom date range
- Server-side pagination with prev/next controls
- Empty state: "No attendance sessions found"
- All strings internationalized via
createTranslator+ sharedattendanceStrings
- Added shared i18n strings (
noSessionsFoundMessage,dateLabel) toattendanceStrings.js - Added
annotate_querysettoAttendanceSessionViewSetforpresent_count/total_counton list endpoint
Phase 3: Tests
- 11 component tests covering page structure, data loading, table rendering, empty state, pagination
- Updated
AttendancePages.spec.jsto remove stub test (replaced by dedicated spec)
Test evidence
Frontend: 37/37 passed, 4/4 suites
Backend: 17/17 passed (5 deselected: pre-existing Python 3.14 compat issues)
Lint: 7 files, 0 errors
Files changed
| File | Change |
|---|---|
composables/useAttendance.js |
Added fetchPaginatedSessions, paginationState |
composables/__mocks__/useAttendance.js |
Added mock entries |
composables/__tests__/useAttendance.spec.js |
3 new pagination tests |
strings/attendanceStrings.js |
Added noSessionsFoundMessage, dateLabel |
AttendanceHistoryPage.vue |
Full page implementation |
attendance/api.py |
Added annotate_queryset for counts |
attendance/test/test_api.py |
1 new annotation test |
__tests__/AttendanceHistoryPage.spec.js |
11 new component tests |
__tests__/AttendancePages.spec.js |
Removed stub test |
Self-Review Findings & Fixes
Reviewed git diff release-v0.19.x...HEAD against issue requirements.
Findings fixed:
- Removed non-functional
sortable/disableBuiltinSortingfrom KTable — sort headers appeared clickable but had no handler. Removed to avoid misleading UI (server already returns date-descending order). - DRYed up
recentaction inapi.py— now callsself.annotate_queryset()instead of duplicating thepresent_count/total_countannotations inline. - Replaced
formatDisplayDatewith locale-aware$formatDate— the hardcodedMM-DD-YYYYformat was US-centric; now uses the i18n date formatter for proper localization. - Fixed null flash on
selectedDateRange— was initialized asref(null)and set inonMounted, causing a brief null state before mount. Now initialized directly with the "Past 30 days" default. - Added missing custom date range test — acceptance criterion "Custom date range applies correctly and updates the dropdown" was untested.
Remaining (nitpick-level, not fixed):
- Test uses
@vue/test-utilsinstead of Vue Testing Library (consistent with 10+ other coach plugin tests) formatDisplayDatei18n concern resolved by$formatDatereplacement
Test evidence:
- 30/30 tests passing across 3 suites (useAttendance, AttendanceHistoryPage, AttendancePages)
- Lint: 2 files, 0 errors
Mostly fixed in #14379