Skip to content

Enable copying the concept graph from another course as a background job - #99

Draft
pconrad with Copilot wants to merge 7 commits into
mainfrom
copilot/enable-copy-concept-graph-job
Draft

Enable copying the concept graph from another course as a background job#99
pconrad with Copilot wants to merge 7 commits into
mainfrom
copilot/enable-copy-concept-graph-job

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Copying a course's concept graph previously required a manual YAML export/import round-trip. This adds a one-click "Copy Concept Graph" action backed by an async job, with permission checks on both the source and destination course.

Backend

  • CopyConceptGraphJob: new job taking userId, fromCourseId, toCourseId. Verifies both courses exist and the user has admin/instructor/staff access to both; logs an error and terminates otherwise. Performs the copy in-memory via ConceptYamlService (serialize from course to YAML, then import into to course) rather than reimplementing the copy logic, so bugs/fixes only need to happen in one place.
  • JobsController: new POST /api/jobs/launch/copyConceptGraph?fromCourseId=&toCourseId= endpoint, @PreAuthorize-guarded to require manage permissions on both courses.
@PreAuthorize(
    "@CourseSecurity.hasManagePermissions(#root, #fromCourseId) and "
        + "@CourseSecurity.hasManagePermissions(#root, #toCourseId)")
@PostMapping("/launch/copyConceptGraph")
public ResponseEntity<String> launchCopyConceptGraphJob(
    @RequestParam Long fromCourseId, @RequestParam Long toCourseId)

Frontend

  • ScaffoldTabComponent: new "Copy Concept Graph from Another Course" section with a course selector grouped by Instructor/Staff/Student access, plus an "Admin" group listing every course in the system for admin users (current course excluded from the list).
  • CopyConceptGraphModal: confirmation dialog warning that the action replaces all concept graph content and user state, with "Yes, replace all content" / "No, keep current content" options.
  • On confirmation, launches the job via useBackendMutation and surfaces the job number in a toast, pointing the user to the Jobs tab to monitor progress.

Copilot AI linked an issue Jul 13, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add job to enable copying concept graph between courses Enable copying the concept graph from another course as a background job Jul 13, 2026
Copilot AI requested a review from pconrad July 13, 2026 21:58
@pconrad

pconrad commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@copilot Please use the github api to monitor the status of the CI/CD failures, and when you see that one has failed, please take action to get it to pass. In the current case, pitest is failing, meaning we need more test coverage for some backend code that passed tests even after being mutated.

Please inspect the pitest results, add more tests as needed.

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please use the github api to monitor the status of the CI/CD failures, and when you see that one has failed, please take action to get it to pass. In the current case, pitest is failing, mean...

Fixed in 36892cc. The pitest report (https://ucsb-cs156.github.io/proj-scaffold/prs/99/pitest/edu.ucsb.cs.scaffold.jobs/CopyConceptGraphJob.java.html) showed 1 surviving mutant: a BooleanTrueReturnValsMutator on the staff-email lambda in hasManagePermissions (19/20 mutations killed). Existing tests never exercised the case of a course having a non-empty courseStaff list where none of the staff emails match the user — so mutating that lambda to always return true still passed all tests.

Added terminates_when_user_is_not_a_matching_staff_member_on_from_course, which uses a from-course with an unrelated staff member and asserts the job still throws the permission error. Verified locally: CopyConceptGraphJob now scores 20/20 (100%) mutation coverage, and both 14-backend-pitest and 13-backend-incremental-pitest CI checks are green, along with all other checks.

@pconrad

pconrad commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@copilot You have still not resolved the merge conflicts.

Please resolve the merge conflicts.

And then, please use the github api to monitor the status of the CI/CD failures, and when you see that one has failed, please take action to get it to pass.

…oncept-graph-job

# Conflicts:
#	frontend/src/tests/components/Courses/TabComponent/ScaffoldTabComponent.test.jsx
#	src/main/java/edu/ucsb/cs/scaffold/controller/JobsController.java
#	src/test/java/edu/ucsb/cs/scaffold/controller/JobsControllerJobsTests.java

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@copilot You have still not resolved the merge conflicts.

Please resolve the merge conflicts.
...

Resolved in c16cebb: merged origin/main and fixed conflicts in JobsController.java, JobsControllerJobsTests.java, and ScaffoldTabComponent.test.jsx (kept both CopyConceptGraphJob and the incoming ReadPLColorsJob additions). Verified backend (809 tests) and frontend (671 tests) still pass locally, and monitored CI via the GitHub API — all 18 checks on the PR are now green, including call-backend-pitest and enforce.

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.

Enable "copy concept graph from another course"

2 participants