Skip to content

Conversation

marikola
Copy link
Member

No description provided.

sindrelm

This comment was marked as resolved.

@marikola marikola requested a review from sindrelm April 23, 2026 14:08
@johanaam johanaam self-requested a review April 24, 2026 12:08
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.

Two codex findings:
Setting profile.currentClassroom during joinClassroom changes the pupil's default classroom before the teacher has approved the membership. CurrentUserResolver.getClassroomByUser() now trusts that field, so a pupil with membershipStatus = PENDING can immediately reach classroom-scoped endpoints such as notebook and medals, and /api/v1/users/me will also switch their XP/level context to the unapproved classroom. Before this patch, a join request did not grant that classroom context.

Once this branch writes currentClassroom on every successful join, removePupil also needs to null it out when the removed pupil's active classroom is the one being deleted. As written, the membership row is removed but the profile still points at the old classroom, and CurrentUserResolver.getClassroomByUser() will keep resolving that classroom for notebook/medal requests even though the pupil is no longer a member.

@marikola
Copy link
Member Author

marikola commented Apr 24, 2026 •

Two codex findings: Setting profile.currentClassroom during joinClassroom changes the pupil's default classroom before the teacher has approved the membership. CurrentUserResolver.getClassroomByUser() now trusts that field, so a pupil with membershipStatus = PENDING can immediately reach classroom-scoped endpoints such as notebook and medals, and /api/v1/users/me will also switch their XP/level context to the unapproved classroom. Before this patch, a join request did not grant that classroom context.

Once this branch writes currentClassroom on every successful join, removePupil also needs to null it out when the removed pupil's active classroom is the one being deleted. As written, the membership row is removed but the profile still points at the old classroom, and CurrentUserResolver.getClassroomByUser() will keep resolving that classroom for notebook/medal requests even though the pupil is no longer a member.

I can fix these issues on the classroom control update, which i am working on and will be making a couple of backend updates to anyway. This commit is mainly meant to make the classroom creation and joining function correctly. Since you cant approve pupils or delete a classroom yet, i dont think these concerns need to be addressed in this specific update.
I have also already fixed the remove pupil thing on the classroom-control branch :)

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.

lgtm. some new conflicts now

marikola and others added 5 commits April 27, 2026 09:24
…fixes

# Conflicts:
#	src/main/kotlin/edu/ntnu/idi/idatt/backend/classroom/application/ClassroomService.kt
#	src/test/kotlin/edu/ntnu/idi/idatt/backend/classroom/ClassroomServiceTest.kt
Copy link
Member

@sindrelm sindrelm left a comment

Choose a reason for hiding this comment

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

lgtm!

@sindrelm sindrelm merged commit a7dfbe2 into main Apr 27, 2026
1 check passed
@sindrelm sindrelm deleted the classroom-fixes branch April 27, 2026 08:27
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants