From ea5be527737d33d3b9f7784d05b83e62f86615a4 Mon Sep 17 00:00:00 2001 From: Huseyin Ergin Date: Mon, 30 Mar 2026 15:15:19 +0000 Subject: [PATCH] Assignments copied between courses now default to unpublished When copying an assignment from one course to another, the copied assignment was automatically published in the new course. This change makes copied assignments default to an unpublished state instead, giving instructors a chance to review the assignment before it becomes available to students. If an assignment's workflow state is explicitly set in the source course, that state is preserved during the copy. Test Plan: - Create a published assignment in a source course - Copy the course to a new course - Verify the copied assignment is unpublished in the new course - Verify that if an unpublished assignment is copied, it remains unpublished --- app/models/importers/assignment_importer.rb | 2 +- .../content_migration/course_copy_assignments_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/importers/assignment_importer.rb b/app/models/importers/assignment_importer.rb index c4c0ea03734b5..875d9bf7b3589 100644 --- a/app/models/importers/assignment_importer.rb +++ b/app/models/importers/assignment_importer.rb @@ -126,7 +126,7 @@ def self.import_from_migration(hash, context, migration, item = nil, quiz = nil) if new_record || item.deleted? || master_migration restore_lti_models(item) if item.deleted? item.workflow_state = if item.can_unpublish? - hash[:workflow_state] || "published" + hash[:workflow_state] || "unpublished" else "published" end diff --git a/spec/models/content_migration/course_copy_assignments_spec.rb b/spec/models/content_migration/course_copy_assignments_spec.rb index 2080c00df7d3a..a6324440a5fd9 100644 --- a/spec/models/content_migration/course_copy_assignments_spec.rb +++ b/spec/models/content_migration/course_copy_assignments_spec.rb @@ -83,6 +83,17 @@ end end + it "copies assignments as unpublished" do + from_assign = @copy_from.assignments.create!(title: "published assignment") + from_assign.publish! + expect(from_assign).to be_published + + run_course_copy + + to_assign = @copy_to.assignments.where(migration_id: mig_id(from_assign)).first! + expect(to_assign).to be_unpublished + end + it "links assignments to account rubrics and outcomes" do account = @copy_from.account lo = create_outcome(account)