From f43d3cf50fd3071c0ea695900c97a232afb5ca8c Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 2 Aug 2012 19:49:28 +1200 Subject: [PATCH] MDL-33942 Grading method: Marking Guide - check for $cm before using - may not exist if the course is being deleted. --- grade/grading/form/guide/lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grade/grading/form/guide/lib.php b/grade/grading/form/guide/lib.php index 5672202d6b9..1990064071d 100644 --- a/grade/grading/form/guide/lib.php +++ b/grade/grading/form/guide/lib.php @@ -339,7 +339,9 @@ class gradingform_guide_controller extends gradingform_controller { $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)); + } } } }