diff --git a/course/lib.php b/course/lib.php index c8c6b469f69..f31e2e28c65 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2416,7 +2416,10 @@ function update_course($data, $editoroptions = NULL) { context_moved($context, $newparent); } - fix_course_sortorder(); + if ($movecat || (isset($data->sortorder) && $oldcourse->sortorder != $data->sortorder)) { + fix_course_sortorder(); + } + // purge appropriate caches in case fix_course_sortorder() did not change anything cache_helper::purge_by_event('changesincourse'); if ($changesincoursecat) {