diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 888182e714..669d2636dd 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -5984,7 +5984,8 @@ class CourseManager $result[] = array( 'disabled' => $user_disabled, 'value' => "GROUP:".$this_group['id'], - 'content' => "G: ".$this_group['name']." - ".$this_group['userNb']." ".$user_label + // The space before "G" is needed in order to advmultiselect.php js puts groups first + 'content' => " G: ".$this_group['name']." - ".$this_group['userNb']." ".$user_label ); } } diff --git a/main/inc/lib/javascript/pear/qfamsHandler.js b/main/inc/lib/javascript/pear/qfamsHandler.js index 4c264dfaef..9e579eab54 100755 --- a/main/inc/lib/javascript/pear/qfamsHandler.js +++ b/main/inc/lib/javascript/pear/qfamsHandler.js @@ -270,6 +270,25 @@ QFAMS.moveSelection = function (qfamsName, selectLeft, selectRight, selectHidden // Set the appropriate items as 'selected in the hidden select. // These are the values that will actually be posted with the form. QFAMS.updateHidden(selectHidden, selectRight); + + // Order alphabetically + + //var sourceId = $(source).attr('id'); + var targetId = $(target).attr('id'); + var options = $('#' + targetId +' option'); + + var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value }; }).get(); + arr.sort(function (o1, o2) { + //return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 : 0; + // Ignore case + var t1 = o1.t.toLowerCase(), t2 = o2.t.toLowerCase(); + return t1 > t2 ? 1 : t1 < t2 ? -1 : 0; + }); + + options.each(function(i, o) { + o.value = arr[i].v; + $(o).text(arr[i].t); + }); }; /**