Skip to content

Add ExCS projects - #982

Open
cocomarine wants to merge 10 commits into
mainfrom
1724-add-ExCS-projects
Open

Add ExCS projects#982
cocomarine wants to merge 10 commits into
mainfrom
1724-add-ExCS-projects

Conversation

@cocomarine

@cocomarine cocomarine commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Status

What's changed?

  • Teachers can create a lesson from an existing Experience CS project (RpfProject)
  • POST /api/lessons accepts a new param: lesson[source_project_identifier].
  • Lesson::Create builds the lesson with a copy of the source project if it's provided.
  • Refactored project copying into a module lib/concepts/project/copying.rb
    • Now used by Lesson::Create, Lesson::CreateCopy, Project::CreateRemix.

Follow-ups (not in this PR)

  • Decide whether the remixed_from_id is used to track the source project or, use another field for it.
  • Adding projects in bulk (using the UnitClassroomAssigner)
  • ❓ Before this PR, CreateCopy was only copying images only, not video/audio. Is that OK?

@cla-bot cla-bot Bot added the cla-signed label Aug 25, 2026
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

Test coverage

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

@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-1724-add-e-2dslla August 25, 2026 15:18 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 07:55 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 07:57 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 10:36 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 14:45 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 14:46 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 26, 2026 15:30 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 27, 2026 07:35 Inactive
@cocomarine
cocomarine temporarily deployed to editor-api-p-1724-add-e-2dslla August 27, 2026 07:58 Inactive
@cocomarine
cocomarine marked this pull request as ready for review August 27, 2026 11:32
Copilot AI lite review requested due to automatic review settings August 27, 2026 11:32

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.

Pull request overview

Enables teachers to create lessons by remixing from a shared Experience CS “code editor scratch” project (via a new lesson[source_project_identifier] param), and centralizes project-copying/media-copying logic into a reusable Project::Copying helper under lib/concepts.

Changes:

  • Add lesson[source_project_identifier] handling in POST /api/lessons, including loading via ProjectLoader, authorization, and Scratch gating based on the resolved source project.
  • Update Lesson::Create to optionally build the lesson’s project by copying from a source project (including media), rather than always creating a stub.
  • Refactor media/component/scratch-component copying into Project::Copying and reuse it from lesson/project operations.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/features/lesson/creating_a_lesson_spec.rb Adds feature coverage for creating lessons from an ExCS source project and Scratch gating behavior.
spec/concepts/lesson/create_spec.rb Adds unit coverage for Lesson::Create when a source project is provided (locale selection, instructions/content copying, etc.).
lib/concepts/project/operations/create_remix.rb Replaces inline media-copy loops with Project::Copying.copy_media.
lib/concepts/project/copying.rb Introduces shared copying utilities for projects, components, scratch component, and media attachments.
lib/concepts/lesson/operations/create.rb Adds optional source_project: flow to build the lesson project from a copy/remix-like template.
lib/concepts/lesson/operations/create_copy.rb Refactors lesson-copy project duplication to use Project::Copying.copy_project.
app/controllers/concerns/lesson_creation.rb Extends Scratch enablement gate to consider the resolved source_project.
app/controllers/api/lessons_controller.rb Adds source_project_identifier handling, loads/validates the source project, authorizes it, and passes it into Lesson::Create.

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

Comment on lines +40 to +48
def remix_attributes(source_project, project_params)
{
locale: nil,
name: project_params[:name].presence || source_project.name,
user_id: project_params[:user_id],
school_id: project_params[:school_id],
lesson_id: project_params[:lesson_id]
}
end

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.

This will be worked on a separate issue as this is not as simple as just adding those attributes and more thoughts are required in terms of teacher project logic and ability.

Comment thread lib/concepts/lesson/operations/create.rb Outdated

@zetter-rpf zetter-rpf 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.

Nice one, just left a suggestion about switching between calling this a remix vs a copy

Comment thread lib/concepts/lesson/operations/create.rb Outdated
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.

4 participants