'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
array($courseid));
+ // Delete course blocks - they may depend on modules so delete them first
+ blocks_delete_all_for_context($context->id);
+
// Delete every instance of every module
if ($allmods = $DB->get_records('modules') ) {
foreach ($allmods as $mod) {
}
if ($cm) {
// delete cm and its context in correct order
+ delete_context(CONTEXT_MODULE, $cm->id); // some callbacks may try to fetch context, better delete first
$DB->delete_records('course_modules', array('id'=>$cm->id));
- delete_context(CONTEXT_MODULE, $cm->id);
}
}
}
} else {
+ //note: we should probably delete these anyway
echo $OUTPUT->notification('Function '.$moddelete.'() doesn\'t exist!');
}
}
}
- // Delete course blocks
- blocks_delete_all_for_context($context->id);
-
// Delete any groups, removing members and grouping/course links first.
groups_delete_groupings($course->id, $showfeedback);
groups_delete_groups($course->id, $showfeedback);