Index: lams_central/src/java/org/lamsfoundation/lams/web/GroupingController.java =================================================================== diff -u -ra778e45c1bc4216c14c4c0f3f7485da58049940f -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_central/src/java/org/lamsfoundation/lams/web/GroupingController.java (.../GroupingController.java) (revision a778e45c1bc4216c14c4c0f3f7485da58049940f) +++ lams_central/src/java/org/lamsfoundation/lams/web/GroupingController.java (.../GroupingController.java) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -133,7 +133,7 @@ // check if user is allowed to view and edit groupings if (!securityService.hasOrgRole(organisationId, userId, new String[] { Role.GROUP_MANAGER, Role.MONITOR, Role.AUTHOR }, "view organisation groupings")) { - response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a participant in the organisation"); + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a super user in the organisation"); return null; } @@ -176,9 +176,6 @@ return "extGroups"; } - boolean isGroupSuperuser = userManagementService.isUserInRole(userId, organisationId, Role.GROUP_MANAGER); - request.setAttribute("canEdit", isGroupSuperuser || (activityID != null)); - Set orgGroupingDTOs = new TreeSet<>(); for (OrganisationGrouping orgGrouping : orgGroupings) { orgGroupingDTOs.add(new OrganisationGroupingDTO(orgGrouping)); @@ -214,8 +211,6 @@ return null; } - boolean isGroupSuperuser = userManagementService.isUserInRole(userId, organisationId, Role.GROUP_MANAGER); - if (targetOrganisationId == null) { targetOrganisationId = organisationId; } @@ -225,13 +220,10 @@ } Long activityId = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID, true); - if (activityId == null) { - request.setAttribute("canEdit", isGroupSuperuser); - } else { + if (activityId != null) { Activity activity = (Activity) userManagementService.findById(Activity.class, activityId); request.setAttribute(AttributeNames.PARAM_TITLE, activity.getTitle()); request.setAttribute("description", activity.getDescription()); - request.setAttribute("canEdit", true); } ObjectNode orgGroupingJSON = JsonNodeFactory.instance.objectNode(); @@ -376,9 +368,9 @@ Integer userId = getUserDTO().getUserID(); int organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); // check if user is allowed to save grouping - if (!securityService.hasOrgRole(organisationId, userId, new String[] { Role.GROUP_MANAGER }, - "save organisation grouping")) { - response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a manager or admin in the organisation"); + if (!securityService.hasOrgRole(organisationId, userId, + new String[] { Role.GROUP_MANAGER, Role.MONITOR, Role.AUTHOR }, "save organisation grouping")) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a super user in the organisation"); } if (log.isDebugEnabled()) { @@ -445,9 +437,9 @@ // check if user is allowed to edit groups Integer userId = getUserDTO().getUserID(); int organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); - if (!securityService.hasOrgRole(organisationId, userId, new String[] { Role.GROUP_MANAGER }, - "remove organisation grouping")) { - response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a manager or admin in the organisation"); + if (!securityService.hasOrgRole(organisationId, userId, + new String[] { Role.GROUP_MANAGER, Role.MONITOR, Role.AUTHOR }, "remove organisation grouping")) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a super user in the organisation"); return null; } Index: lams_central/web/groups.jsp =================================================================== diff -u -r1ba563378355d4a7e3b284cd645460f396989272 -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_central/web/groups.jsp (.../groups.jsp) (revision 1ba563378355d4a7e3b284cd645460f396989272) +++ lams_central/web/groups.jsp (.../groups.jsp) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -33,7 +33,6 @@ var grouping = ${grouping}, organisationId = grouping.organisationId, unassignedUsers = ${unassignedUsers}, - canEdit = ${canEdit}, groupingActivityId = '${param.activityID}', lessonId = '${lessonID}', lessonMode = ${lessonMode}, @@ -133,29 +132,21 @@
+ readonly="readonly" /> - - - +
- - - - - - - - + +
- +
@@ -205,50 +196,44 @@
- -
-

- -

-
-
- - + +
+
+ + +
+ + + + - - - - - - -
+
- +
- + - - readonly="readonly" - - /> +
Index: lams_central/web/includes/javascript/groups.js =================================================================== diff -u -r2b3f2b89c7ae1770e508ca941b7c5c0574e656e8 -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_central/web/includes/javascript/groups.js (.../groups.js) (revision 2b3f2b89c7ae1770e508ca941b7c5c0574e656e8) +++ lams_central/web/includes/javascript/groups.js (.../groups.js) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -34,13 +34,11 @@ }); } - if (canEdit) { - // allow adding new groups - $('#newGroupPlaceholder').click(function(){ - // the label is "Group X" where X is the top group number - addGroup(null, LABELS.GROUP_PREFIX_LABEL + ' ' + $('#groupsCell .groupContainer').length, null); - }); - } + // allow adding new groups + $('#newGroupPlaceholder').click(function(){ + // the label is "Group X" where X is the top group number + addGroup(null, LABELS.GROUP_PREFIX_LABEL + ' ' + $('#groupsCell .groupContainer').length, null); + }); }); @@ -134,65 +132,62 @@ userDivs.push(userDiv); userIds.push(userJSON.id); - // if teacher can not edit, then no drag&drop is available - if (canEdit) { - userDiv.draggable({ - 'appendTo' : 'body', - 'containment' : '#groupsTable', - 'revert' : 'invalid', - 'distance' : 20, - 'scroll' : true, - 'scrollSensitivity' : 120, - 'scrollSpeed' : 100, - 'cursor' : 'move', - 'helper' : function(event){ - // include the user from which dragging started - $(this).addClass('draggableSelected'); - - // copy selected users - var helperContainer = $('
'); - $(this).siblings('.draggableSelected').addBack().each(function(){ - $(this).clone().appendTo(helperContainer); - }); - return helperContainer; - } - }) - - .click(function(event){ - var wasSelected = $(this).hasClass('draggableSelected'); - var parentId = $(this).parent().parent().attr('id'); - // this is needed for shift+click - var lastSelectedUser = lastSelectedUsers[parentId]; + userDiv.draggable({ + 'appendTo' : 'body', + 'containment' : '#groupsTable', + 'revert' : 'invalid', + 'distance' : 20, + 'scroll' : true, + 'scrollSensitivity' : 120, + 'scrollSpeed' : 100, + 'cursor' : 'move', + 'helper' : function(event){ + // include the user from which dragging started + $(this).addClass('draggableSelected'); + + // copy selected users + var helperContainer = $('
'); + $(this).siblings('.draggableSelected').addBack().each(function(){ + $(this).clone().appendTo(helperContainer); + }); + return helperContainer; + } + }) + + .click(function(event){ + var wasSelected = $(this).hasClass('draggableSelected'); + var parentId = $(this).parent().parent().attr('id'); + // this is needed for shift+click + var lastSelectedUser = lastSelectedUsers[parentId]; + + if (event.shiftKey && lastSelectedUser && lastSelectedUser != this) { + // clear current selection + $(this).siblings().addBack().removeClass('draggableSelected'); - if (event.shiftKey && lastSelectedUser && lastSelectedUser != this) { - // clear current selection + // find range of users to select + var lastSelectedIndex = $(lastSelectedUser).index(); + var index = $(this).index(); + + var startingElem = lastSelectedIndex > index ? this : lastSelectedUser; + var endingElem = lastSelectedIndex > index ? lastSelectedUser : this; + + $(startingElem).nextUntil(endingElem).addBack().add(endingElem) + .addClass('draggableSelected'); + } else { + if (!event.ctrlKey) { + // clear current sleection $(this).siblings().addBack().removeClass('draggableSelected'); - - // find range of users to select - var lastSelectedIndex = $(lastSelectedUser).index(); - var index = $(this).index(); - - var startingElem = lastSelectedIndex > index ? this : lastSelectedUser; - var endingElem = lastSelectedIndex > index ? lastSelectedUser : this; - - $(startingElem).nextUntil(endingElem).addBack().add(endingElem) - .addClass('draggableSelected'); + } + + if (wasSelected && !event.shiftKey){ + $(this).removeClass('draggableSelected'); + lastSelectedUsers[parentId] = null; } else { - if (!event.ctrlKey) { - // clear current sleection - $(this).siblings().addBack().removeClass('draggableSelected'); - } - - if (wasSelected && !event.shiftKey){ - $(this).removeClass('draggableSelected'); - lastSelectedUsers[parentId] = null; - } else { - $(this).addClass('draggableSelected'); - lastSelectedUsers[parentId] = this; - } + $(this).addClass('draggableSelected'); + lastSelectedUsers[parentId] = this; } - }); - } + } + }); if (!createOnServer) { $('.userContainer', container).append(userDiv); @@ -219,48 +214,46 @@ sortUsers(container); }); - if (canEdit) { - $(container).droppable({ - 'activeClass' : 'droppableHighlight', - 'tolerance' : 'pointer', - 'drop' : function (event, ui) { - var draggableUserContainer = $(ui.draggable).parent(); - var thisUserContainer = $('.userContainer', this); - // do not do anything if it is the same container - // using "accept" feature breaks the layout - if (draggableUserContainer[0] != thisUserContainer[0]) { - var executeDrop = !lessonMode; - if (!executeDrop) { - var transferToLocked = $(this).hasClass('locked'); - // make sure user wants to transfer learners to a group which is already in use - executeDrop = !transferToLocked || confirm(LABELS.TRANSFER_LOCKED_LABEL); - if (executeDrop) { - var userIds = []; - $('div.draggableSelected', draggableUserContainer).each(function(){ - userIds.push($(this).attr('userId')); - }); - // execute transfer on server side - executeDrop = assignUsersToGroup(userIds, $(this)); - } - } - + $(container).droppable({ + 'activeClass' : 'droppableHighlight', + 'tolerance' : 'pointer', + 'drop' : function (event, ui) { + var draggableUserContainer = $(ui.draggable).parent(); + var thisUserContainer = $('.userContainer', this); + // do not do anything if it is the same container + // using "accept" feature breaks the layout + if (draggableUserContainer[0] != thisUserContainer[0]) { + var executeDrop = !lessonMode; + if (!executeDrop) { + var transferToLocked = $(this).hasClass('locked'); + // make sure user wants to transfer learners to a group which is already in use + executeDrop = !transferToLocked || confirm(LABELS.TRANSFER_LOCKED_LABEL); if (executeDrop) { - transferUsers(draggableUserContainer, thisUserContainer); + var userIds = []; + $('div.draggableSelected', draggableUserContainer).each(function(){ + userIds.push($(this).attr('userId')); + }); + // execute transfer on server side + executeDrop = assignUsersToGroup(userIds, $(this)); } - } - } - }); + } + + if (executeDrop) { + transferUsers(draggableUserContainer, thisUserContainer); + } + } + } + }); + - - $('.removeGroupButton', container).click(function(){ - removeGroup(container); + $('.removeGroupButton', container).click(function(){ + removeGroup(container); + }); + + if (lessonMode) { + $('input', container).blur(function(){ + renameGroup(container); }); - - if (lessonMode) { - $('input', container).blur(function(){ - renameGroup(container); - }); - } } } @@ -387,7 +380,7 @@ * Save a course grouping. */ function saveGroups(){ - if (!canEdit || lessonMode) { + if (lessonMode) { return false; } $('.errorMessage').hide(); @@ -567,10 +560,6 @@ } function importGroupsFromSpreadsheet() { - if (!canEdit) { - return false; - } - disableButtons(); var file = getValidateSpreadsheetFile(); if ( file != null && ( !warnBeforeUpload || confirm(LABELS.WARNING_REPLACE_GROUPS_LABEL) ) ) { Index: lams_central/web/orgGrouping.jsp =================================================================== diff -u -ra778e45c1bc4216c14c4c0f3f7485da58049940f -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_central/web/orgGrouping.jsp (.../orgGrouping.jsp) (revision a778e45c1bc4216c14c4c0f3f7485da58049940f) +++ lams_central/web/orgGrouping.jsp (.../orgGrouping.jsp) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -86,7 +86,7 @@
- + @@ -98,15 +98,15 @@
- -
-
-
- - -
+ +
+
+
+ +
- +
+ Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -r616c7119289412164b78e0f420725a865e60c933 -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 616c7119289412164b78e0f420725a865e60c933) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -286,6 +286,7 @@ if (grouper != null) { try { grouper.removeAllLearnersFromGrouping(grouping); + grouping.getGroups().clear(); } catch (GroupingException e) { throw new LessonServiceException(e); } Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadController.java =================================================================== diff -u -rb28b1e41d273fdce6c086a72a4e6a9f2e1a8a946 -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadController.java (.../GroupingUploadController.java) (revision b28b1e41d273fdce6c086a72a4e6a9f2e1a8a946) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/GroupingUploadController.java (.../GroupingUploadController.java) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -280,7 +280,7 @@ if (!securityService.hasOrgRole(organisationId, userId, new String[] { Role.GROUP_MANAGER, Role.MONITOR, Role.AUTHOR }, "save organisation grouping from spreadsheet")) { - response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a manager or admin in the organisation"); + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a super user in the organisation"); return null; } Index: lams_monitoring/web/WEB-INF/web.xml =================================================================== diff -u -r3f3f34c22194aeaf302e1fd332925dffd35019aa -r0132ac7723f6060a3a656d216ac93a1540634c7f --- lams_monitoring/web/WEB-INF/web.xml (.../web.xml) (revision 3f3f34c22194aeaf302e1fd332925dffd35019aa) +++ lams_monitoring/web/WEB-INF/web.xml (.../web.xml) (revision 0132ac7723f6060a3a656d216ac93a1540634c7f) @@ -201,9 +201,23 @@ POST - MONITOR GROUP MANAGER + SYSADMIN + + + + + Grouping upload + /groupingUpload/* + GET + POST + + + + AUTHOR + MONITOR + GROUP MANAGER APPADMIN