diff --git a/course/editcategory.php b/course/editcategory.php index 1b03cf1c565..00640658944 100644 --- a/course/editcategory.php +++ b/course/editcategory.php @@ -75,6 +75,7 @@ if ($mform->is_cancelled()) { } $newcategory->context = get_context_instance(CONTEXT_COURSECAT, $newcategory->id); mark_context_dirty($newcategory->context->path); + fix_course_sortorder(); // Required to build course_categories.depth and .path. } redirect('category.php?id='.$newcategory->id.'&categoryedit=on'); } diff --git a/course/index.php b/course/index.php index 6ea66f7baf4..0613b082c6f 100644 --- a/course/index.php +++ b/course/index.php @@ -153,6 +153,7 @@ } $tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id); mark_context_dirty('/'.SYSCONTEXTID); + fix_course_sortorder(); // Required to build course_categories.depth and .path. } /// Move a category to a new parent if required diff --git a/lib/datalib.php b/lib/datalib.php index 3a04e29172f..dcc863a7a9a 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1221,6 +1221,7 @@ function get_course_category($catid=0) { // make sure category context exists get_context_instance(CONTEXT_COURSECAT, $catid); mark_context_dirty('/'.SYSCONTEXTID); + fix_course_sortorder(); // Required to build course_categories.depth and .path. $category = $DB->get_record('course_categories', array('id'=>$catid)); } }