From 46bd72dc4f133f1a3342ca0f018d958a3a4e0bd9 Mon Sep 17 00:00:00 2001 From: Andrew Hancox Date: Mon, 15 Oct 2018 14:24:19 +0100 Subject: [PATCH 1/2] MDL-62666 course: Ignore restore_general_groups on activity duplication --- course/lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/course/lib.php b/course/lib.php index 9d3f7233ca6..bcfee641984 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3468,6 +3468,11 @@ function duplicate_module($course, $cm) { $rc = new restore_controller($backupid, $course->id, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, backup::TARGET_CURRENT_ADDING); + // Configure the plan. + $plan = $rc->get_plan(); + $groupsetting = $plan->get_setting('groups'); + $groupsetting->set_value(true); + $cmcontext = context_module::instance($cm->id); if (!$rc->execute_precheck()) { $precheckresults = $rc->get_precheck_results(); From 6a09040e4dd9c4352cb09e9306d7443cdd004196 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Mon, 21 Jan 2019 13:56:23 +0800 Subject: [PATCH 2/2] MDL-62666 course: Only set the groups setting to true when necessary * Plus update the comment to be more descriptive. --- course/lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/course/lib.php b/course/lib.php index bcfee641984..0ef9d2d9d41 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3468,10 +3468,12 @@ function duplicate_module($course, $cm) { $rc = new restore_controller($backupid, $course->id, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, backup::TARGET_CURRENT_ADDING); - // Configure the plan. + // Make sure that the restore_general_groups setting is always enabled when duplicating an activity. $plan = $rc->get_plan(); $groupsetting = $plan->get_setting('groups'); - $groupsetting->set_value(true); + if (empty($groupsetting->get_value())) { + $groupsetting->set_value(true); + } $cmcontext = context_module::instance($cm->id); if (!$rc->execute_precheck()) {