diff --git a/lib/moodlelib.php b/lib/moodlelib.php index ee4c4b0fc87..d4c5e583373 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5277,9 +5277,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));