Index: lams_central/web/includes/javascript/orgGroup.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/orgGroup.js,v diff -u -r1.7 -r1.8 --- lams_central/web/includes/javascript/orgGroup.js 6 Aug 2014 09:02:42 -0000 1.7 +++ lams_central/web/includes/javascript/orgGroup.js 25 Aug 2014 10:00:23 -0000 1.8 @@ -96,13 +96,18 @@ var createOnServer = lessonMode && !skipAssigningWhenCreatingGroup && container.attr('id') != 'unassignedUserCell'; if (users) { + var userDivs = [], + userIds = []; // create user DIVs $.each(users, function(index, userJSON) { var userDiv = $('
').attr('userId', userJSON.id) .addClass('draggableUser') .text(userJSON.firstName + ' ' + userJSON.lastName + ' (' + userJSON.login + ')' ); + // for later use + userDivs.push(userDiv); + userIds.push(userJSON.id); // if teacher can not edit, then no drag&drop is available if (canEdit) { @@ -162,19 +167,21 @@ }); } - if (createOnServer) { - // copy course groups as lesson groups, creating new instances - if (assignUsersToGroup([userJSON.id], container)) { - $('.userContainer', container).append(userDiv); - } else { - // if it fails, put them in unassigned list - $('#unassignedUserCell .userContainer').append(userDiv); - } - } else { + if (!createOnServer) { $('.userContainer', container).append(userDiv); } }); + if (createOnServer) { + // copy course groups as lesson groups, creating new instances + if (assignUsersToGroup(userIds, container)) { + $('.userContainer', container).append(userDivs); + } else { + // if it fails, put them in unassigned list + $('#unassignedUserCell .userContainer').append(userDivs); + } + } + sortUsers(container); } else if (createOnServer) { // just createa an empty group