Browse files

MDL-33942 Grading method: Marking Guide - check for $cm before using …

…- may not exist if the course is being deleted.
  • Loading branch information...
1 parent 470d47f commit f43d3cf50fd3071c0ea695900c97a232afb5ca8c @danmarsden danmarsden committed Aug 2, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 grade/grading/form/guide/lib.php
View
4 grade/grading/form/guide/lib.php
@@ -339,7 +339,9 @@ protected function load_definition() {
$modulename = substr($modulename, 4);
if ($dbman->table_exists($modulename)) {
$cm = get_coursemodule_from_id($modulename, $context->instanceid);
- $this->moduleinstance = $DB->get_record($modulename, array("id"=>$cm->instance));
+ if (!empty($cm)) { // This should only occur when the course is being deleted.
+ $this->moduleinstance = $DB->get_record($modulename, array("id"=>$cm->instance));
+ }
}
}
}

0 comments on commit f43d3cf

Please sign in to comment.