Skip to content

feat: classroom control #52

Merged
merged 34 commits into from
Apr 30, 2026
Merged

feat: classroom control #52

merged 34 commits into from
Apr 30, 2026

Conversation

marikola
Copy link
Member

@marikola marikola commented Apr 24, 2026

Backend for classroom control, should be merged at the same time as feat: classroom control #69 on frontend to avoid issues for pupils not yet in classroom.

@marikola marikola marked this pull request as draft April 24, 2026 12:34
@johanaam johanaam changed the title Classroom control feat: classroom control Apr 24, 2026
@johanaam johanaam linked an issue Apr 27, 2026 that may be closed by this pull request
@marikola marikola marked this pull request as ready for review April 28, 2026 15:20
Copy link
Member

@johanaam johanaam left a comment

Choose a reason for hiding this comment

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

A few things:

  • The rule that a pupil can only join a new classroom when they are not active in another classroom is not enforced in the backend. joinClassroom only checks whether the pupil is already a member of the target classroom. If this is an important product invariant, the service should guard it explicitly.
  • PupilProfile.currentClassroom and classroom_pupils.status now act as two related sources of truth. The code manually keeps them in sync during approval/removal, which is easy to break later. We should either make the relationship very explicit in the service or derive one from the other where possible.
  • CurrentUserProfileService.findMembership() returns the first active membership anywhere, otherwise the first pending membership anywhere. That means membershipStatus may not describe the same classroom as currentClassroomId, which makes the API response ambiguous.
  • ClassroomController still fetches pupil profiles directly when building classroom details. That lookup belongs in the service layer so the controller stays thin.
  • Some updated tests pre-seed currentClassroom, which makes it harder to verify that join/approval behavior is actually doing the right thing. It would be better to assert the intended pending and approved states directly.

I got help from Codex finding these.

@johanaam johanaam linked an issue Apr 29, 2026 that may be closed by this pull request
@marikola
Copy link
Member Author

A few things:

  • The rule that a pupil can only join a new classroom when they are not active in another classroom is not enforced in the backend. joinClassroom only checks whether the pupil is already a member of the target classroom. If this is an important product invariant, the service should guard it explicitly.
  • PupilProfile.currentClassroom and classroom_pupils.status now act as two related sources of truth. The code manually keeps them in sync during approval/removal, which is easy to break later. We should either make the relationship very explicit in the service or derive one from the other where possible.
  • CurrentUserProfileService.findMembership() returns the first active membership anywhere, otherwise the first pending membership anywhere. That means membershipStatus may not describe the same classroom as currentClassroomId, which makes the API response ambiguous.
  • ClassroomController still fetches pupil profiles directly when building classroom details. That lookup belongs in the service layer so the controller stays thin.
  • Some updated tests pre-seed currentClassroom, which makes it harder to verify that join/approval behavior is actually doing the right thing. It would be better to assert the intended pending and approved states directly.

I got help from Codex finding these.

Ok, I have updated the join classroom to check whether the pupil has any memberships already, and the findMembership method in CurrentUserProfileService to throw if it finds more than one membership, so there should not be any issues of mismatches between status and classroom, or any pupil joining more than one classroom. I´m not sure which tests you're referring to? If you specify I could update some :)

@marikola marikola requested a review from johanaam April 30, 2026 12:25
@marikola marikola merged commit 2b39beb into main Apr 30, 2026
1 check passed
@marikola marikola deleted the classroom-control branch April 30, 2026 13:12
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Classroom control
3 participants