// Now delete anything that may depend on course category context.
grade_course_category_delete($this->id, 0, $showfeedback);
- if (!question_delete_course_category($this, 0, $showfeedback)) {
+ $cb = new \core_contentbank\contentbank();
+ if (!$cb->delete_contents($this->get_context())) {
+ throw new moodle_exception('errordeletingcontentfromcategory', 'contentbank', '', $this->get_formatted_name());
+ }
+ if (!question_delete_course_category($this, null)) {
throw new moodle_exception('cannotdeletecategoryquestions', '', '', $this->get_formatted_name());
}
// Now delete anything that may depend on course category context.
grade_course_category_delete($this->id, $newparentid, $showfeedback);
- if (!question_delete_course_category($this, $newparentcat, $showfeedback)) {
+ $cb = new \core_contentbank\contentbank();
+ $newparentcontext = context_coursecat::instance($newparentid);
+ $result = $cb->move_contents($context, $newparentcontext);
+ if ($showfeedback) {
+ if ($result) {
+ echo $OUTPUT->notification(get_string('contentsmoved', 'contentbank', $catname), 'notifysuccess');
+ } else {
+ echo $OUTPUT->notification(
+ get_string('errordeletingcontentbankfromcategory', 'contentbank', $catname),
+ 'notifysuccess'
+ );
+ }
+ }
+ if (!question_delete_course_category($this, $newparentcat)) {
if ($showfeedback) {
echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $catname), 'notifysuccess');
}