Merge branch 'MDL-51694-37' of https://github.com/MartinGauk/moodle into MOODLE_37_STABLE
This commit is contained in:
@@ -285,6 +285,9 @@ class grade_category extends grade_object {
|
||||
* @return bool success
|
||||
*/
|
||||
public function delete($source=null) {
|
||||
global $DB;
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$grade_item = $this->load_grade_item();
|
||||
|
||||
if ($this->is_course_category()) {
|
||||
@@ -334,7 +337,10 @@ class grade_category extends grade_object {
|
||||
$grade_item->delete($source);
|
||||
|
||||
// delete category itself
|
||||
return parent::delete($source);
|
||||
$success = parent::delete($source);
|
||||
|
||||
$transaction->allow_commit();
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1111,6 +1111,9 @@ class grade_grade extends grade_object {
|
||||
* @return bool Returns true if the deletion was successful, false otherwise.
|
||||
*/
|
||||
public function delete($source = null) {
|
||||
global $DB;
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$success = parent::delete($source);
|
||||
|
||||
// If the grade was deleted successfully trigger a grade_deleted event.
|
||||
@@ -1119,6 +1122,7 @@ class grade_grade extends grade_object {
|
||||
\core\event\grade_deleted::create_from_grade($this)->trigger();
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
||||
@@ -400,8 +400,13 @@ class grade_item extends grade_object {
|
||||
* @return bool success
|
||||
*/
|
||||
public function delete($source=null) {
|
||||
global $DB;
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
$this->delete_all_grades($source);
|
||||
return parent::delete($source);
|
||||
$success = parent::delete($source);
|
||||
$transaction->allow_commit();
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,6 +416,10 @@ class grade_item extends grade_object {
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_all_grades($source=null) {
|
||||
global $DB;
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
|
||||
if (!$this->is_course_item()) {
|
||||
$this->force_regrading();
|
||||
}
|
||||
@@ -428,6 +437,8 @@ class grade_item extends grade_object {
|
||||
$fs->delete_area_files($this->get_context()->id, GRADE_FILE_COMPONENT, GRADE_HISTORY_FEEDBACK_FILEAREA);
|
||||
}
|
||||
|
||||
$transaction->allow_commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user