MDL-62666 course: Only set the groups setting to true when necessary

* Plus update the comment to be more descriptive.
This commit is contained in:
Jun Pataleta
2019-01-21 14:43:01 +08:00
parent 7ed127cfbb
commit 843e909b7f
+4 -2
View File
@@ -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()) {