Implement AttendanceEditPage — edit existing attendance session
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Implement AttendanceEditPage — allows coaches to update attendance records for a previously saved session. The page loads the existing session, pre-populates the learner toggles, tracks changes against the original state, and prompts for confirmation before saving. Builds on the stub added in #14236 and shares the same learner table pattern as AttendanceNewPage (#14242).
Complexity: Medium Target branch: release-v0.19.x
Context
Once a session is saved, coaches can revisit it from AttendanceHistoryPage to correct mistakes or update records. AttendanceEditPage is structurally similar to AttendanceNewPage — the key differences are that it loads existing data on mount, tracks which records have changed, and requires confirmation before saving to prevent accidental overwrites.
The Change
AttendanceEditPage (kolibri/plugins/coach/frontend/views/attendance/AttendanceEditPage.vue):
CoachImmersivePagewith H1 showing the session date/time (fromsession_start_datetime, formatted viaformatAttendanceDateTime); showsKCircularLoaderwhile session is loading- Learner table — same structure as
AttendanceNewPage: searchable, paginated at 50 per page, sorted alphabetically, per-learnerKSwitch, "Mark all present" toggle withKModalconfirmation - Change tracking — compares current
attendanceMapagainstoriginalAttendanceMaploaded from the session; Save button is disabled whenchangeCount === 0 - Save confirmation
KModal— shows the number of changes and a present/absent summary before committing BottomAppBar— live present/absent count, Cancel and Save buttons- Save — calls
updateSession, redirects toATTENDANCE_HISTORYwith a success snackbar; shows error snackbar on failure - Unsaved changes guard —
beforeRouteLeaveprompts with aKModalif the coach navigates away with unsaved changes
Design Spec
| Description | Screen |
|---|---|
| Save confirmation modal with present/absent summary | |
| Mark all present confirmation modal |
Out of Scope
- Creating a new session (separate issue —
AttendanceNewPage) - Attendance history list (separate issue —
AttendanceHistoryPage)
Acceptance Criteria
General
- [ ] Session is fetched on mount and learner toggles are pre-populated from existing records
- [ ] Session date/time is displayed in the page H1;
KCircularLoaderis shown while loading - [ ] Learners are sorted alphabetically and paginated at 50 per page
- [ ] Learner list is filterable by name via a search box
- [ ] Each learner row has a
KSwitchreflecting the saved state; whentrue, the row shows a "Present" label and a$themePalette.blue.v_100background - [ ] A "Mark all learners present"
KSwitchat the top of the table triggers aKModalconfirmation before applying - [ ] Save button is disabled when no changes have been made
- [ ] Saving triggers a confirmation
KModalshowing the number of changes and a present/absent summary - [ ] Confirmed save calls
updateSessionand redirects toATTENDANCE_HISTORYwith a success snackbar - [ ] On error, the user remains on the page and an error snackbar is shown
- [ ] Navigating away with unsaved changes prompts a
KModalconfirmation
Styling
- [ ] Present row background uses
$themePalette.blue.v_100, not a hardcoded colour - [ ] Absent count in the save confirmation modal uses
$themeTokens.errorcolour
Accessibility and i18n
- [ ] Table headers are present in the DOM but visually hidden
- [ ] Each
KSwitchhas anaria-labelledbyreferencing a visually hidden label - [ ] All user-visible strings are internationalised
- [ ] Page is keyboard navigable
Testing
- [ ] Session loads and pre-populates learner toggles correctly
- [ ] Change count is tracked correctly against the original state
- [ ] Save button is disabled when
changeCount === 0 - [ ] Save confirmation modal shows correct change count and present/absent summary
- [ ] Successful save redirects to history with snackbar
- [ ] Failed save shows error snackbar and stays on page
- [ ] Unsaved changes guard fires on navigation away
References
- Issue #14236 — stub page being fleshed out
- Issue #14242 —
AttendanceNewPage, shares the same learner table pattern - Issue #14244 —
AttendanceHistoryPage, linked from "View Sessions" - Issue #14022 — original feature spec with design references
🤖 This issue was written with AI assistance, under supervision, review and final edits by [@akolson] 🤖
Implementation Plan for AttendanceEditPage
Overview
Implement AttendanceEditPage — loads an existing attendance session, pre-populates learner toggles, tracks changes against the original state, and prompts for confirmation before saving.
Architecture
The page mirrors AttendanceNewPage structurally (same learner table, pagination/search, mark-all modal, unsaved changes guard). Key differences:
- Fetches existing session via
fetchSession(attendanceId)on mount, showsKCircularLoaderwhile loading - Tracks changes against an
originalAttendanceMapsnapshot — Save button disabled whenchangeCount === 0 - Save opens a confirmation
KModalshowing change count + present/absent summary - Calls
updateSessioninstead ofcreateSession
Files Changed
| Action | File |
|---|---|
| Modify | packages/kolibri-common/strings/attendanceStrings.js — 4 new i18n strings |
| Rewrite | kolibri/plugins/coach/frontend/views/attendance/AttendanceEditPage.vue — full implementation |
| Modify | kolibri/plugins/coach/frontend/views/attendance/__tests__/AttendancePages.spec.js — full test suite |
Phases
- Add i18n strings —
editPageHeading,saveConfirmationTitle,saveConfirmationDescription,updateSuccessMessage - Write failing tests — 9 test cases covering: session loading, pre-population, change tracking, save button disable, save confirmation modal, success/error save, unsaved changes guard
- Implement component — full
AttendanceEditPage.vuereplacing the stub - Verification — run tests, lint, walk through acceptance criteria
New i18n Strings
editPageHeading: "Edit attendance: {date} ({time})"saveConfirmationTitle: "Save {count} change(s)?"saveConfirmationDescription: "{presentCount} present, {absentCount} absent"updateSuccessMessage: "Attendance updated"
Test Coverage
- Session loads and pre-populates toggles correctly
- Loader shown while loading
- Session date/time in heading
- Change count tracked against original state
- Save button disabled when changeCount === 0
- Save confirmation modal shows change count + summary
- Successful save redirects with snackbar
- Failed save shows error snackbar
- Unsaved changes guard on navigation
Implementation Progress: AttendanceEditPage
All four phases are complete. Branch: issue-14242-a8a461
Changes
| File | Action |
|---|---|
packages/kolibri-common/strings/attendanceStrings.js |
Added 4 i18n strings: editPageHeading, saveConfirmationTitle, saveConfirmationDescription, updateSuccessMessage |
kolibri/plugins/coach/frontend/views/attendance/AttendanceEditPage.vue |
Full implementation replacing stub |
kolibri/plugins/coach/frontend/views/attendance/__tests__/AttendancePages.spec.js |
9 new tests for edit page |
Test Evidence
PASS kolibri/plugins/coach/frontend/views/attendance/__tests__/AttendancePages.spec.js
Test Suites: 1 passed, 1 total
Tests: 21 passed, 21 total (12 existing + 9 new)
New tests cover:
- Session fetched on mount, toggles pre-populated from records
- KCircularLoader shown while loading
- Session date/time in heading
- Change count tracked against original state
- Save button disabled when changeCount === 0
- Save confirmation modal with change count + present/absent summary
- Successful save calls updateSession, redirects with snackbar
- Failed save shows error snackbar, stays on page
- Unsaved changes guard blocks navigation
Lint
All pre-commit checks pass on all 3 changed files.
Visual Verification
Dev server could not be started due to a Django/silk compatibility issue in the environment (unrelated to these changes). The implementation follows the design spec structurally:
- Save confirmation modal shows change count in title and present/absent summary in body
- Absent count uses
$themeTokens.errorcolor per spec - Mark all present modal matches AttendanceNewPage pattern
Acceptance Criteria Checklist
All criteria verified via tests and code inspection — see phase-4-verification.md for the full mapping.
Self-review completed for AttendanceEditPage implementation.
All acceptance criteria verified and met. All 21 tests pass.
Findings:
- suggestion (fixed): Removed unused
saveConfirmationDescriptioni18n string fromattendanceStrings.js— the save confirmation modal was composing present/absent counts inline using separate strings instead of this combined one. - nitpick: The loader test in
AttendancePages.spec.jsduplicates setup from themakeEditPageWrapperhelper — could be simplified but low priority. - praise: Clean change-tracking implementation and consistent patterns with
AttendanceNewPage.
Implemented in #14382