From 914624d51d7383f7682ce445489cbf0f7cc17926 Mon Sep 17 00:00:00 2001 From: Charles Fulton Date: Mon, 25 Mar 2013 12:59:50 -0700 Subject: [PATCH] MDL-38700 course: only change visibility if a module moves to a different section --- course/lib.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/course/lib.php b/course/lib.php index db132187873..f03f6450f65 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3163,17 +3163,19 @@ function moveto_module($mod, $section, $beforemod=NULL) { } // if moving to a hidden section then hide module - if (!$section->visible && $mod->visible) { - // Set this in the object because it is sent as a response to ajax calls. - $mod->visible = 0; - set_coursemodule_visible($mod->id, 0); - // Set visibleold to 1 so module will be visible when section is made visible. - $DB->set_field('course_modules', 'visibleold', 1, array('id' => $mod->id)); - } - if ($section->visible && !$mod->visible) { - set_coursemodule_visible($mod->id, $mod->visibleold); - // Set this in the object because it is sent as a response to ajax calls. - $mod->visible = $mod->visibleold; + if ($mod->section != $section->id) { + if (!$section->visible && $mod->visible) { + // Set this in the object because it is sent as a response to ajax calls. + $mod->visible = 0; + set_coursemodule_visible($mod->id, 0); + // Set visibleold to 1 so module will be visible when section is made visible. + $DB->set_field('course_modules', 'visibleold', 1, array('id' => $mod->id)); + } + if ($section->visible && !$mod->visible) { + set_coursemodule_visible($mod->id, $mod->visibleold); + // Set this in the object because it is sent as a response to ajax calls. + $mod->visible = $mod->visibleold; + } } /// Add the module into the new section -- 2.11.4.GIT