From 7ed127cfbba159976103121a74d7440b0a1686dd 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 5f130362bb4..6ad742947df 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3420,6 +3420,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 843e909b7f4b41dbff03dad085fab2e8ba192d0e 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 6ad742947df..d0cb0b39a93 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3420,10 +3420,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()) {