Skip to content
Browse files

MDL-38700 course: only change visibility if a module moves to a diffe…

…rent section
  • Loading branch information...
1 parent 1a5d533 commit ba7c052171322bef3cba5e8e09c8f4412c8e48fd @mackensen mackensen committed with danpoltawski
Showing with 11 additions and 9 deletions.
  1. +11 −9 course/lib.php
View
20 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

0 comments on commit ba7c052

Please sign in to comment.
Something went wrong with that request. Please try again.