Skip to content

Add Course Copy through cartridge export and import - #327

Merged
csev merged 2 commits into
masterfrom
course-copy
Nov 3, 2026
Merged

csev merged 2 commits into
masterfrom
course-copy

Conversation

@csev

@csev csev commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add a Course Copy tab on course Settings, next to Import and Export.
  • Copying exports the chosen course to a temporary Common Cartridge and then runs the existing import, including module selection and the option to delete this course's content first.
  • Sources are the site file-based course, when one is configured, and other manifest courses owned by the current user. The file-based export is the same zip writer /cc/export uses.

Test plan

  • Open Settings on a manifest course and confirm the Course Copy tab sits after Export.
  • Copy from the site course: choose it, then copy all modules into the current course without deleting existing content.
  • Copy selected modules only, and confirm unselected modules are not added.
  • Copy with delete-this-course's-content-first, and confirm the domain, title, and member-count check still blocks a mismatched confirmation.
  • Copy from another manifest course you own, and confirm a course you do not own cannot be selected or posted.
  • Start an Import upload, then open Course Copy, and confirm the two pending cartridges do not replace each other.
  • Download a file-based cartridge from /cc/export and confirm it still matches the previous export.

Summary by CodeRabbit

  • New Features
    • Added a Course Copy tab in settings, where instructors can choose an available course and copy its modules into the current course.
    • Copying supports file-based and manifest-based courses. The current course is excluded from the source list, and confirmation is required before replacing existing content.
  • Improvements
    • Copy operations display copy-specific status and error messages, keeping them separate from regular imports.
    • Failed or canceled copies clean up temporary export files without affecting pending imports.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Adds a course-mounted copy flow for readable file-based lessons and owned manifest courses. The flow exports a cartridge and uses copy-specific pending state for module selection and import processing. The file-based /cc export now uses the extracted LessonsLegacyExport writer.

Changes: Course Copy and Cartridge Export

Layer / File(s) Summary
Reusable file-based lesson export
lib/src/Services/Lessons/LessonsLegacyExport.php, cc/export.php, lib/src/Services/Lessons/LessonsLegacyFiles.php, lib/src/Services/Lessons/LessonsLegacyGift.php, .cursor/rules/lessons-service.mdc
Adds LessonsLegacyExport::writeZip to write file-based lesson cartridges. cc/export.php delegates cartridge generation to this method. The helper documentation describes its file-based export use.
Course source discovery and export
lib/src/Services/Cartridge/CourseCopy.php, lib/tests/Services/Cartridge/CourseCopyTest.php
Adds validation and discovery for readable file-based lessons and owned manifest courses. Exports eligible sources to cartridges and tests source parsing, discovery, and module listings.
Course settings copy flow
lib/src/Controllers/Settings.php, lib/src/Controllers/templates/Settings/copy.inc.php, lib/src/Controllers/templates/Settings/tabs.inc.php, lib/tests/Controllers/SettingsCartridgeUploadTest.php
Adds the Copy tab, source picker, and POST export flow. The settings page displays a pending copy cartridge for module selection.
Copy-specific pending import processing
lib/src/Services/Cartridge/Pending.php, lib/src/Controllers/Settings.php, lib/src/Controllers/templates/Settings/import.inc.php, lib/src/Controllers/templates/Settings/import_pending_js.inc.php, lib/tests/Services/Cartridge/PendingTest.php
Adds keyed pending-cartridge operations and uses a separate session entry for course copies. Import confirmation and module selection are shared, while copy messages and cleanup target the copy entry.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  actor Instructor
  participant Settings
  participant CourseCopy
  participant LessonsLegacyExport
  participant LessonsCartridge
  Instructor->>Settings: Select a source course
  Settings->>CourseCopy: Export the selected source
  alt File-based source
    CourseCopy->>LessonsLegacyExport: Write file-based cartridge
    LessonsLegacyExport-->>CourseCopy: Cartridge written
  else Manifest source
    CourseCopy->>LessonsCartridge: Write manifest cartridge
    LessonsCartridge-->>CourseCopy: Cartridge written
  end
  CourseCopy-->>Settings: Return export result
  Settings-->>Instructor: Show copy import flow
Loading
Merge Risk: Minimal · up to 1ac75

The change has no remaining actionable merge-blocking risk in the supplied evidence.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding Course Copy through cartridge export and import.
Docstring Coverage Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 36 functions across 14 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/rust/security/sql-injection-format-rust.yml

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2d81326 and 1ac7501.

Files selected for processing: 1
  • lib/tests/Services/Cartridge/CourseCopyTest.php

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Fix comments: Fix CodeRabbit comments on this PR

@csev
csev merged commit 5bde1b1 into master Nov 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant