From: moodler Date: Sun, 10 Nov 2002 14:45:11 +0000 (+0000) Subject: Update course cache when modules are moved up or down X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=7c0f29842647b8fc285f4cc6f62a542fc8682e2e;p=moodle.git Update course cache when modules are moved up or down --- diff --git a/course/lib.php b/course/lib.php index a3ed29db8a..7d85456909 100644 --- a/course/lib.php +++ b/course/lib.php @@ -722,17 +722,13 @@ function delete_mod_from_section($mod, $section) { } -function move_module($id, $move) { +function move_module($cm, $move) { GLOBAL $db; if (!$move) { return true; } - if (! $cm = get_record("course_modules", "id", $id)) { - error("This course module doesn't exist"); - } - if (! $thissection = get_record("course_sections", "id", $cm->section)) { error("This course section doesn't exist"); } diff --git a/course/mod.php b/course/mod.php index 77908b7ac8..638fa16868 100644 --- a/course/mod.php +++ b/course/mod.php @@ -87,7 +87,6 @@ } $modinfo = serialize(get_array_of_activities($mod->course)); - if (!set_field("course", "modinfo", $modinfo, "id", $mod->course)) { error("Could not cache module information!"); } @@ -108,7 +107,16 @@ require_variable($id); - move_module($id, $move); + if (! $cm = get_record("course_modules", "id", $id)) { + error("This course module doesn't exist"); + } + + move_module($cm, $move); + + $modinfo = serialize(get_array_of_activities($cm->course)); + if (!set_field("course", "modinfo", $modinfo, "id", $cm->course)) { + error("Could not cache module information!"); + } redirect($HTTP_REFERER); exit;