Skip to content

Hide mark attendance button when no learners are enrolled#14419

Merged
rtibbles merged 5 commits intolearningequality:release-v0.19.xfrom
akolson:hid-mark-attendance-button
Mar 19, 2026
Merged

Hide mark attendance button when no learners are enrolled#14419
rtibbles merged 5 commits intolearningequality:release-v0.19.xfrom
akolson:hid-mark-attendance-button

Conversation

@akolson
Copy link
Member

@akolson akolson commented Mar 19, 2026

Summary

Fixes a bug where the "Mark attendance" button was visible on the class home page even when no learners were enrolled in the class. This is inconsistent with the behavior of other blocks on the same page, which hide their action buttons when there's no data to act on.

Changes:

  • Gate the "Mark attendance" button behind a v-if="learners.length" check so it only renders when the class has enrolled learners
  • Show a more helpful empty state message ("No attendance sessions yet. Enroll learners to mark attendance") instead of "No attendance sessions yet" when there are zero learners
State Screenshot
Class with 0 learners (button hidden, helpful message shown) image
Class with learners (button shown as expected) image

References

Fixes #14412

Reviewer guidance

  • Test with a class that has 0 enrolled learners: the "Mark attendance" button should not appear
  • Test with a class that has ≥1 enrolled learners: the "Mark attendance" button should appear as before
  • The empty state message differs between the two states — verify both messages render correctly

AI usage

I used Claude Code to implement this change, guiding it to use the existing learners computed from classSummary/learners in the Vuex store and wrap the button in a v-if conditional. I reviewed the generated code, verified the logic against the issue description, and confirmed the fix works in both the empty-class and populated-class scenarios.

@github-actions github-actions bot added DEV: dev-ops Continuous integration & deployment DEV: backend Python, databases, networking, filesystem... APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: frontend SIZE: very large labels Mar 19, 2026
@akolson akolson changed the base branch from develop to release-v0.19.x March 19, 2026 14:44
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look correct to me - and I have just noticed that the bot implemented the attendance block tests using vue test utils, not vue test library! Will open a follow up issue in develop to rectify this once we've merged down.

@rtibbles rtibbles requested a review from rtibblesbot March 19, 2026 15:15
Copy link
Contributor

@rtibblesbot rtibblesbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Straightforward fix that gates the button behind learners.length — the core logic is correct.

CI passing. Screenshots provided and consistent with code changes.

  • blocking: New translatable string noSessionsEnrollMessage added on release-v0.19.x (non-default branch), and adding strings was not specified in #14412. See inline comment.
  • suggestion: Missing test assertion for button visibility — see inline comment.
  • praise: Clean test setup wiring the Vuex classSummary module with learner data — see inline comment.

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?

Reviewed the pull request diff checking for:

  • Correctness: bugs, edge cases, undocumented behavior, resource leaks, hardcoded values
  • Design: unnecessary complexity, naming, readability, comment accuracy, redundant state
  • Architecture: duplicated concerns, minimal interfaces, composition over inheritance
  • Testing: behavior-based assertions, mocks only at hard boundaries, accurate coverage
  • Completeness: missing dependencies, unupdated usages, i18n, accessibility, security
  • Principles: DRY (same reason to change), SRP, Rule of Three (no premature abstraction)
  • Checked CI status and linked issue acceptance criteria
  • For UI changes: inspected screenshots for layout, visual completeness, and consistency

message: 'No attendance sessions yet. Enroll learners to mark attendance',
context:
'Empty state message when no attendance sessions exist and no learners are enrolled in the class',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking: This PR adds a new translatable string (noSessionsEnrollMessage) but targets release-v0.19.x, not the default branch (develop). New strings on release branches can disrupt the i18n/translation pipeline since string extraction and Crowdin syncs typically run against the default branch.

The linked issue (#14412) doesn't call for a new message — its expected behavior is: "the 'Attendance' section to be present with just the text 'No attendance sessions yet'." Consider dropping this new string and reusing the existing noSessionsMessage for both cases (matching the issue's stated expectation). If the distinct message is desired, it should land on develop first and be cherry-picked after translations are in place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, this feature is gated to English only, so untranslated strings will not appear.

const { wrapper } = makeWrapper({ sessions: [], learners: [] });
await global.flushPromises();
expect(wrapper.text()).toContain('No attendance sessions yet');
expect(wrapper.text()).toContain('Enroll learners to mark attendance');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: The primary acceptance criterion from #14412 is that the "Mark attendance" button is hidden when no learners are enrolled, but no test asserts this. Consider adding an assertion that the KRouterLink stub is absent when learners is empty, e.g.:

expect(wrapper.findComponent({ name: 'KRouterLink' }).exists()).toBe(false);

And conversely, that it's present when learners exist.

learners.forEach(l => {
learnerMap[l.id] = l;
});
testStore.state.classSummary.learnerMap = learnerMap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Good job wiring up the classSummary module and learnerMap in the test store — this ensures the component's computed(() => store.getters['classSummary/learners']) works correctly in tests without over-mocking.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

@radinamatic
Copy link
Member

Looking good in Firefox and Chrome on Ubuntu.

Firefox Chrome
Ubuntu22 04 (start)  Running  - Oracle VirtualBox_009 Ubuntu22 04 (start)  Running  - Oracle VirtualBox_010

0 learners, no button, 1+ learner button appears 🙂 👏🏽

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bot does not have access to the full facts.

@rtibbles rtibbles dismissed rtibblesbot’s stale review March 19, 2026 21:15

English language gated feature.

@rtibbles rtibbles merged commit 923177c into learningequality:release-v0.19.x Mar 19, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) APP: Facility Re: Facility App (user/class management, facility settings, csv import/export, etc.) DEV: backend Python, databases, networking, filesystem... DEV: dev-ops Continuous integration & deployment DEV: frontend SIZE: small SIZE: very large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attendance Tracking - The 'Mark attendance' button should be hidden when there are no learners in a class

4 participants