From 2e0b3490f057b164a314735da7fe44737785d0d8 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 25 Sep 2014 20:52:40 -0700 Subject: [PATCH] MDL-40697 core_grades: trigger the grade_deleted event --- lib/grade/grade_grade.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index be9ee405b1c..46eea2d1366 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -946,6 +946,24 @@ class grade_grade extends grade_object { return parent::update($source); } + /** + * Deletes the grade_grade instance from the database. + * + * @param string $source The location the deletion occurred (mod/forum, manual, etc.). + * @return bool Returns true if the deletion was successful, false otherwise. + */ + public function delete($source = null) { + $success = parent::delete($source); + + // If the grade was deleted successfully trigger a grade_deleted event. + if ($success) { + $this->load_grade_item(); + \core\event\grade_deleted::create_from_grade($this)->trigger(); + } + + return $success; + } + /** * Used to notify the completion system (if necessary) that a user's grade * has changed, and clear up a possible score cache. -- 2.43.0