Skip to content

Prevent copying assignments - #2918

Open
cqnykamp wants to merge 6 commits into
mainfrom
claude/modest-franklin-e19MO
Open

Prevent copying assignments#2918
cqnykamp wants to merge 6 commits into
mainfrom
claude/modest-franklin-e19MO

Conversation

@cqnykamp

@cqnykamp cqnykamp commented May 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2614

  • Backend: copyContent now throws InvalidRequestError("Cannot copy an assignment") when any of the requested content IDs is an assignment root (isAssignmentRoot = true). Previously, copying an assignment was silently allowed, producing a regular activity without assignment data.
  • Frontend: The "Make a copy" button in the Activities page action bar is now disabled whenever any selected item is an assignment (has assignmentInfo set).
  • Tests: Two new API unit tests in copy_move.test.ts verify that copying a sequence-based assignment and a singleDoc assignment both throw the expected error.

Test plan

  • Select a non-assignment activity and verify "Make a copy" is still enabled and works
  • Select an assignment and verify "Make a copy" button is disabled
  • API test: cannot copy an assignment passes in CI
  • API test: cannot copy an assignment (singleDoc) passes in CI

https://claude.ai/code/session_019HTqQkPWkZ35RM1x1HRQ2W


Generated by Claude Code

claude and others added 2 commits May 24, 2026 09:10
- Backend: throw InvalidRequestError when attempting to copy an assignment root
- Frontend: disable "Make a copy" action bar button when any selected item is an assignment
- Tests: add two tests covering attempt to copy singleDoc and sequence assignment roots

https://claude.ai/code/session_019HTqQkPWkZ35RM1x1HRQ2W
@cqnykamp

Copy link
Copy Markdown
Contributor Author

What happens when a folder that contains an assignment is copied? Is this behavior checked by a test?

Copying a folder is still allowed; its assignment descendants come out as
plain, unassigned activities. Pin that behavior down with a test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V2N6YBQjEJv7xnxnusELub
@cqnykamp

Copy link
Copy Markdown
Contributor Author

Copying a folder that contains an assignment still succeeds — only the ids passed directly to copyContent are checked for isAssignmentRoot. The copy of the nested assignment comes out as a plain, unassigned activity: copySingleContent omits isAssignmentRoot, assignmentOpenOn, assignmentClosedOn, and classCode, so the new row has no assignment data (and no class code / student responses). The original assignment is untouched.

That matches the frontend, where the "Make a copy" button is only disabled when a selected item itself has assignmentInfo — a folder doesn't.

It wasn't covered by a test, so I added one in 760eb48: copying a folder containing an assignment drops the assignment data. It asserts the folder copy succeeds, the copied child has assignmentInfo === undefined, and the original is still assigned.

I couldn't run the API tests locally (no DB reachable from this sandbox); it typechecks, and CI will exercise it.

cqnykamp and others added 3 commits August 24, 2026 15:54
getContent rejects folders, so list the copied folder's children with
getMyContent instead. Also pass includeAssignInfo so the assignmentInfo
assertions are actually meaningful.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V2N6YBQjEJv7xnxnusELub
DateTime.now() as closedOn makes the assignment "Closed" by the time the
assertion runs.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V2N6YBQjEJv7xnxnusELub
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.

Make a copy of assignment

2 participants