Group classes: only one student per account can be enrolled, then the card switches to Withdraw #170

Closed
opened 2026-08-11 20:30:58 +00:00 by thatguygriff · 0 comments
Owner

Reported from use: enrolling multiple students in a group class is impossible. The first enrolment goes through, the class card then reads "You are enrolled in this class." with a Withdraw button, and there is no way to enrol a second child in the same class.

Cause

The server has always been per-student — EnrollmentEndpoint::enroll() checks hasActiveEnrollment( $offeringId, $studentId ), and GET /enrollments returns the guardian's whole household. The class page is what collapses them: assets/js/group-classes.js built its enrolment lookup as Map<offering_id, enrollment_id>, so any one household member's enrolment marked the class as "yours" for the entire account:

new Map(enrollments
    .filter((e) => e.status === 'active')
    .map((e) => [Number(e.offering_id), e.id]))

student_id never entered the key. The Enrol button was then rendered only when the map had no entry for the class, so it disappeared for every remaining student in the household.

Expected

  • Each enrolled student gets their own line on the card, named, with their own Withdraw button.
  • The Enrol button stays until everyone the account may enrol is in the class.
  • The "Who is this for?" picker offers only students not already enrolled.

Notes

No data is wrong — seats were always recorded per student, so existing enrolments need no repair. Purely a front-end fix.

Reported from use: enrolling multiple students in a group class is impossible. The first enrolment goes through, the class card then reads "You are enrolled in this class." with a **Withdraw** button, and there is no way to enrol a second child in the same class. ## Cause The server has always been per-student — `EnrollmentEndpoint::enroll()` checks `hasActiveEnrollment( $offeringId, $studentId )`, and `GET /enrollments` returns the guardian's whole household. The class page is what collapses them: `assets/js/group-classes.js` built its enrolment lookup as `Map<offering_id, enrollment_id>`, so any one household member's enrolment marked the class as "yours" for the entire account: ```js new Map(enrollments .filter((e) => e.status === 'active') .map((e) => [Number(e.offering_id), e.id])) ``` `student_id` never entered the key. The Enrol button was then rendered only when the map had no entry for the class, so it disappeared for every remaining student in the household. ## Expected - Each enrolled student gets their own line on the card, named, with their own Withdraw button. - The Enrol button stays until everyone the account may enrol is in the class. - The "Who is this for?" picker offers only students not already enrolled. ## Notes No data is wrong — seats were always recorded per student, so existing enrolments need no repair. Purely a front-end fix.
thatguygriff added the bug label 2026-08-11 20:30:58 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Unsupervised/unsupervised-scheduler#170