Skip to content
Browse files

MDL-29538 core_condition: moved the deletion of the course_modules_av…

…ailability information above the deletion of the course modules
  • Loading branch information...
1 parent 33f30de commit d2170cb542805a4e4ef905877320cf1cd976fcff @markn86 markn86 committed May 15, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/moodlelib.php
View
13 lib/moodlelib.php
@@ -4515,6 +4515,19 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
echo $OUTPUT->notification($strdeleted.get_string('completion', 'completion'), 'notifysuccess');
}
+ // 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_select('course_modules_availability',
+ 'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
+ array($courseid));
+ $DB->delete_records_select('course_modules_avail_fields',
+ 'coursemoduleid IN (SELECT id from {course_modules} WHERE course = ?)',
+ array($courseid));
+
// Remove all data from gradebook - this needs to be done before course modules
// because while deleting this information, the system may need to reference
// the course modules that own the grades.

0 comments on commit d2170cb

Please sign in to comment.
Something went wrong with that request. Please try again.