Merge branch 'MDL-61615-master' of git://github.com/rezaies/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2018-03-20 10:20:11 +01:00
commit f61c5f8a95

View File

@ -464,13 +464,16 @@ function question_delete_course_category($category, $newcategory, $feedback=true
if (!$newcontext = context_coursecat::instance($newcategory->id)) {
return false;
}
$topcategory = question_get_top_category($context->id, true);
$newtopcategory = question_get_top_category($newcontext->id, true);
question_move_category_to_context($topcategory->id, $context->id, $newcontext->id);
$DB->set_field('question_categories', 'parent', $newtopcategory->id, array('parent' => $topcategory->id));
// Now delete the top category.
$DB->delete_records('question_categories', array('id' => $topcategory->id));
// Only move question categories if there is any question category at all!
if ($topcategory = question_get_top_category($context->id)) {
$newtopcategory = question_get_top_category($newcontext->id, true);
question_move_category_to_context($topcategory->id, $context->id, $newcontext->id);
$DB->set_field('question_categories', 'parent', $newtopcategory->id, array('parent' => $topcategory->id));
// Now delete the top category.
$DB->delete_records('question_categories', array('id' => $topcategory->id));
}
if ($feedback) {
$a = new stdClass();