Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…rent section
  • Loading branch information...
commit bb1592c860a027c7d7aaa4de7d7da5a8261802ec 1 parent 1fff1b8
@mackensen mackensen authored danpoltawski committed
Showing with 13 additions and 11 deletions.
  1. +13 −11 course/lib.php
View
24 course/lib.php
@@ -2467,17 +2467,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
Please sign in to comment.
Something went wrong with that request. Please try again.