When updating we don't always want to change visibility and groupmode bug 2561

This commit is contained in:
moodler 2005-02-16 03:11:52 +00:00
parent 1c66bf597d
commit 9df665e7bf

View file

@ -51,9 +51,11 @@
switch ($mod->mode) { switch ($mod->mode) {
case "update": case "update":
if (isset($mod->name)) {
if (trim($mod->name) == '') { if (trim($mod->name) == '') {
unset($mod->name); unset($mod->name);
} }
}
$return = $updateinstancefunction($mod); $return = $updateinstancefunction($mod);
if (!$return) { if (!$return) {
@ -64,23 +66,19 @@
} }
error("Could not update the $mod->modulename", "view.php?id=$course->id"); error("Could not update the $mod->modulename", "view.php?id=$course->id");
} }
if (isset($mod->visible)) {
set_coursemodule_visible($mod->coursemodule, $mod->visible);
}
if (isset($mod->groupmode)) {
set_coursemodule_groupmode($mod->coursemodule, $mod->groupmode);
}
if (is_string($return)) { if (is_string($return)) {
error($return, "view.php?id=$course->id"); error($return, "view.php?id=$course->id");
} }
// to deal with pre-1.5 modules
if (!isset($mod->visible)) {
//We get the section's visible field status
$mod->visible = get_field("course_sections","visible","id",$sectionid);
}
if (!isset($mod->groupmode)) {
$cm = get_record('course_modules', 'id', $mod->coursemodule);
$mod->groupmode = groupmode($course, $cm);
}
set_coursemodule_visible($mod->coursemodule, $mod->visible);
set_coursemodule_groupmode($mod->coursemodule, $mod->groupmode);
if (isset($mod->redirect)) { if (isset($mod->redirect)) {
$SESSION->returnpage = $mod->redirecturl; $SESSION->returnpage = $mod->redirecturl;
} else { } else {
@ -134,9 +132,7 @@
error("Could not update the course module with the correct section"); error("Could not update the course module with the correct section");
} }
// to deal with pre-1.5 modules if (!isset($mod->visible)) { // We get the section's visible field status
if (!isset($mod->visible)) {
//We get the section's visible field status
$mod->visible = get_field("course_sections","visible","id",$sectionid); $mod->visible = get_field("course_sections","visible","id",$sectionid);
} }
// make sure visibility is set correctly (in particular in calendar) // make sure visibility is set correctly (in particular in calendar)