MDL-68526 core_contentbank: Delete content when a course is deleted

Or when a course category is moved/deleted
This commit is contained in:
Amaia Anabitarte
2020-05-18 16:05:04 +02:00
parent d85118369d
commit f2a9bb6edb
6 changed files with 130 additions and 6 deletions
+7
View File
@@ -5335,6 +5335,13 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
echo $OUTPUT->notification($strdeleted.get_string('questions', 'question'), 'notifysuccess');
}
// Delete content bank contents.
$cb = new \core_contentbank\contentbank();
$cbdeleted = $cb->delete_contents($coursecontext);
if ($showfeedback && $cbdeleted) {
echo $OUTPUT->notification($strdeleted.get_string('contentbank', 'contentbank'), 'notifysuccess');
}
// Make sure there are no subcontexts left - all valid blocks and modules should be already gone.
$childcontexts = $coursecontext->get_child_contexts(); // Returns all subcontexts since 2.2.
foreach ($childcontexts as $childcontext) {