Skip to content

Simplify class links by removing special cases for teachers & owners - #1003

Merged
zetter-rpf merged 2 commits into
mainfrom
remove-joinable-as-teacher
Sep 8, 2026
Merged

Simplify class links by removing special cases for teachers & owners#1003
zetter-rpf merged 2 commits into
mainfrom
remove-joinable-as-teacher

Conversation

@zetter-rpf

@zetter-rpf zetter-rpf commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Status

What's changed?

We had started implementing the ability for class codes to be used by teachers and owners, but this functionality wasn't fully working in the frontend. We're also not sure if teachers should be able to join classes they are not already members of.

  • Remove special casing of teachers and owners, and treat them as 'not a member'
  • Remove unused and confusing redirect_url response param

See https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1780 for re-introducing.

Note this is safe to deploy before https://github.com/RaspberryPiFoundation/editor-standalone/pull/1012
as no one is using join codes on production yet/

@cla-bot cla-bot Bot added the cla-signed label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Test coverage

93.57% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/34212765348

@zetter-rpf
zetter-rpf force-pushed the remove-joinable-as-teacher branch from 66dff8c to 189175f Compare September 8, 2026 09:09
@zetter-rpf zetter-rpf changed the title Simplify Simplify class join codes by removing special cases for teachers and owners Sep 8, 2026
@zetter-rpf zetter-rpf changed the title Simplify class join codes by removing special cases for teachers and owners Simplify class links by removing special cases for teachers and owners Sep 8, 2026
@zetter-rpf zetter-rpf changed the title Simplify class links by removing special cases for teachers and owners Simplify class links by removing special cases for teachers & owners Sep 8, 2026
@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-remove-joi-rkdtku September 8, 2026 09:14 Inactive
@zetter-rpf
zetter-rpf marked this pull request as ready for review September 8, 2026 09:17
Copilot AI lite review requested due to automatic review settings September 8, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

It introduces an undocumented API response change (removal of redirect_url) and leaves now-dead status/controller branches that should be cleaned up for clarity and contract consistency.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR simplifies the join-code flow so that only students can join classes via join codes, removing the previously introduced special cases for teachers and owners.

Changes:

  • Updated JoinStatusService so only student membership/roles produce joinable statuses; teacher/owner users now yield :not_a_student.
  • Updated Api::JoinController#create to remove teacher/owner join behaviors and to return an empty JSON object on success.
  • Updated request/service specs to match the new status and authorization behavior.
File summaries
File Description
app/services/join_status_service.rb Removes role-based special cases and tightens status computation around student eligibility.
app/controllers/api/join_controller.rb Aligns POST join behavior to forbid non-students and simplifies successful responses.
spec/services/join_status_service_spec.rb Updates expectations for teacher/owner scenarios to :not_a_student.
spec/requests/join_controller_spec.rb Updates request specs for teacher/owner flows and simplifies successful POST assertions.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/controllers/api/join_controller.rb Outdated
Comment thread app/controllers/api/join_controller.rb Outdated
Comment thread app/services/join_status_service.rb Outdated
Comment thread spec/requests/join_controller_spec.rb
Comment thread spec/requests/join_controller_spec.rb
@zetter-rpf
zetter-rpf force-pushed the remove-joinable-as-teacher branch from 189175f to 51a9ebf Compare September 8, 2026 09:31
@zetter-rpf
zetter-rpf temporarily deployed to editor-api-p-remove-joi-rkdtku September 8, 2026 09:31 Inactive
@jamiebenstead
jamiebenstead requested a balanced review from Copilot September 8, 2026 09:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The response-contract and teacher non-enrollment behavior need explicit regression coverage, and obsolete teacher-join code remains.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

spec/requests/join_controller_spec.rb:241

  • The example pre-creates the teacher's school role and only checks the status, so it does not verify the newly intended behavior that posting a class code cannot create a ClassTeacher. Assert no class-teacher row is added and name the example after that behavior.
      it 'does not add the teacher to the school' do
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread spec/requests/join_controller_spec.rb
Comment thread app/controllers/api/join_controller.rb
When taking to Jason, he was unsure if it was safe for teachers to be able to use the same join codes as students. I've decided to remove it handling teachers adds more complexity to the frontend. Instead all non-student accounts will be a shown a link to get to the class which they can use if they are already a teacher or owner.

This also removes the owner status. Now all non-students are treated the same.

We may think this is a useful feature in the future so could add it back in if we want.

fixup
This is not a URL, it's not even full root-relative path as the locale needs to be added. The frontend knows all that it needs to construct the URL from the other params in the get response so this can be removed.
@zetter-rpf
zetter-rpf force-pushed the remove-joinable-as-teacher branch from 51a9ebf to 13b5eec Compare September 8, 2026 09:56
@zetter-rpf
zetter-rpf temporarily deployed to editor-api-p-remove-joi-rkdtku September 8, 2026 09:56 Inactive
when :joinable
add_student_to_school_and_class
render json: { redirect_url: class_redirect_path }, status: :ok
render json: {}, status: :ok

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this and :already_member both return {}
can we reduce this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The behaviour is different as there's a call to add_student_to_school_and_class in the joinable case- combining the case statements would move the condition elsewhere.

@zetter-rpf
zetter-rpf merged commit 50d958e into main Sep 8, 2026
8 checks passed
@zetter-rpf
zetter-rpf deleted the remove-joinable-as-teacher branch September 8, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants