From 7d5efd643cc3bada2c52fc8fec6e64af47d865e8 Mon Sep 17 00:00:00 2001 From: Nick Phillips Date: Tue, 17 Oct 2017 11:46:11 +1300 Subject: [PATCH] MDL-56688 grade: fix ordering of grade items in grade_seq::flatten --- grade/lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grade/lib.php b/grade/lib.php index 575353b2cbd..5cf9c57246c 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -2127,7 +2127,12 @@ class grade_seq extends grade_structure { } unset($element['children']); - if ($category_grade_last and count($children) > 1) { + if ($category_grade_last and count($children) > 1 and + ( + $children[0]['type'] === 'courseitem' or + $children[0]['type'] === 'categoryitem' + ) + ) { $cat_item = array_shift($children); array_push($children, $cat_item); }