MDL-40081 completion: clean up criteria records for deleted courses.

This commit is contained in:
Paul Holden
2020-04-06 12:22:03 +01:00
parent 08a62243c5
commit c96e66a40a
4 changed files with 60 additions and 2 deletions
+10 -1
View File
@@ -498,7 +498,16 @@ class completion_info {
*/
public function clear_criteria() {
global $DB;
$DB->delete_records('course_completion_criteria', array('course' => $this->course_id));
// Remove completion criteria records for the course itself, and any records that refer to the course.
$select = 'course = :course OR (criteriatype = :type AND courseinstance = :courseinstance)';
$params = [
'course' => $this->course_id,
'type' => COMPLETION_CRITERIA_TYPE_COURSE,
'courseinstance' => $this->course_id,
];
$DB->delete_records_select('course_completion_criteria', $select, $params);
$DB->delete_records('course_completion_aggr_methd', array('course' => $this->course_id));
$this->delete_course_completion_data();