From ba7c052171322bef3cba5e8e09c8f4412c8e48fd Mon Sep 17 00:00:00 2001 From: Charles Fulton Date: Mon, 25 Mar 2013 13:35:44 -0700 Subject: [PATCH] MDL-38700 course: only change visibility if a module moves to a different section --- course/lib.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/course/lib.php b/course/lib.php index f7842ee582d..0ac08a81158 100644 --- a/course/lib.php +++ b/course/lib.php @@ -3166,15 +3166,17 @@ function moveto_module($mod, $section, $beforemod=NULL) { /// Update module itself if necessary // 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. - set_coursemodule_visible($mod->id, 0, true); - $mod->visible = 0; - } - if ($section->visible && !$mod->visible) { - set_coursemodule_visible($mod->id, 1, true); - // 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. + set_coursemodule_visible($mod->id, 0, true); + $mod->visible = 0; + } + if ($section->visible && !$mod->visible) { + set_coursemodule_visible($mod->id, 1, true); + // 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