MDL-69687 Course: Improve removal of completion data on MySQL

This commit is contained in:
sam marshall
2020-10-16 18:22:51 +01:00
parent 39eb58c754
commit 3576eb4835
+2 -3
View File
@@ -5327,9 +5327,8 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
// Remove all data from availability and completion tables that is associated
// with course-modules belonging to this course. Note this is done even if the
// features are not enabled now, in case they were enabled previously.
$DB->delete_records_select('course_modules_completion',
'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
array($courseid));
$DB->delete_records_subquery('course_modules_completion', 'coursemoduleid', 'id',
'SELECT id from {course_modules} WHERE course = ?', [$courseid]);
// Remove course-module data that has not been removed in modules' _delete_instance callbacks.
$cms = $DB->get_records('course_modules', array('course' => $course->id));