Merge branch 'MDL-68757' of https://github.com/timhunt/moodle
authorAdrian Greeve <abgreeve@gmail.com>
Tue, 26 May 2020 02:33:03 +0000 (10:33 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Tue, 26 May 2020 02:33:03 +0000 (10:33 +0800)
1  2 
course/classes/category.php
course/lib.php
lib/moodlelib.php
lib/questionlib.php

@@@ -2021,11 -1993,7 +2021,11 @@@ class core_course_category implements r
  
          // 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');
              }
diff --cc course/lib.php
Simple merge
Simple merge
Simple merge