Browse files

Update course cache when modules are moved up or down

  • Loading branch information...
1 parent 76d6be7 commit 7c0f29842647b8fc285f4cc6f62a542fc8682e2e moodler committed Nov 10, 2002
Showing with 11 additions and 7 deletions.
  1. +1 −5 course/lib.php
  2. +10 −2 course/mod.php
View
6 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");
}
View
12 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;

0 comments on commit 7c0f298

Please sign in to comment.