Index: lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java =================================================================== diff -u -rdddec00b716f2a13e76beca0a915d406672c4de0 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java (.../OrganisationGroupAction.java) (revision dddec00b716f2a13e76beca0a915d406672c4de0) +++ lams_central/src/java/org/lamsfoundation/lams/web/OrganisationGroupAction.java (.../OrganisationGroupAction.java) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -455,7 +455,6 @@ /** * Fetches course and branching so they can get matched by user. */ - @SuppressWarnings("unchecked") public ActionForward getGroupsForMapping(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, JSONException { Long orgGroupingId = WebUtil.readLongParam(request, "groupingId"); @@ -471,11 +470,10 @@ groupJSON.put("name", group.getName()); groupsJSON.put(groupJSON); } + Activity branchingActivity = (Activity) getUserManagementService().findById(Activity.class, activityID); + Grouping grouping = branchingActivity.getGrouping(); - GroupingActivity branchingGrouping = (GroupingActivity) getUserManagementService().findById(Activity.class, - activityID); JSONArray branchesJSON = new JSONArray(); - Grouping grouping = branchingGrouping.getCreateGrouping(); SortedSet groups = new TreeSet(grouping.getGroups()); for (Group group : groups) { JSONObject groupJSON = new JSONObject(); @@ -593,7 +591,6 @@ /** * Checks if lesson-level groups exist for the given activity. */ - @SuppressWarnings("unchecked") private Grouping getLessonGrouping(HttpServletRequest request, Long activityID, boolean allowDefault) { if (activityID != null) { // we need to fetch real objects instead of stubs/proxies @@ -608,7 +605,6 @@ boolean isUsedForBranching = grouping.isUsedForBranching(); request.setAttribute(GroupingAJAXAction.PARAM_USED_FOR_BRANCHING, isUsedForBranching); - // check if it is immutable (for branching) or default groups are allowed return !groups.isEmpty() && (allowDefault || !isDefaultChosenGrouping(grouping)) ? grouping : null; } } @@ -620,18 +616,17 @@ * Check if the given groups are default for chosen grouping. There is actually no good way to detect this, but even * if a custom grouping is mistaken for the default one, it should bring little harm. */ - @SuppressWarnings("unchecked") private boolean isDefaultChosenGrouping(Grouping grouping) { Set groups = grouping.getGroups(); - if ((groups == null) || (grouping.getMaxNumberOfGroups() == null) - || !grouping.getMaxNumberOfGroups().equals(groups.size())) { - return false; - } for (Group group : groups) { if (!group.getUsers().isEmpty()) { return false; } } + if (groups == null || (grouping.getMaxNumberOfGroups() != null + && !grouping.getMaxNumberOfGroups().equals(groups.size()))) { + return false; + } return true; } Index: lams_central/web/css/authoring.css =================================================================== diff -u -rcaf0b925fc9dc4ec29fa3c462afceac023b0b552 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/css/authoring.css (.../authoring.css) (revision caf0b925fc9dc4ec29fa3c462afceac023b0b552) +++ lams_central/web/css/authoring.css (.../authoring.css) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -236,7 +236,7 @@ width: 100%; height: 98%; table-layout: fixed; - border-collapse: collapse;outputConditionsDialogContents + border-collapse: collapse; } div.branchMappingDialog td { Index: lams_central/web/css/orgGroup.css =================================================================== diff -u -r970546106e9b05a4d1a507b26be2ce96130b4f01 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/css/orgGroup.css (.../orgGroup.css) (revision 970546106e9b05a4d1a507b26be2ce96130b4f01) +++ lams_central/web/css/orgGroup.css (.../orgGroup.css) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -78,7 +78,7 @@ .userContainer { overflow: auto; - height: 123px; + height: 109px; margin-top: 5px; } Index: lams_central/web/css/orgGrouping.css =================================================================== diff -u -r3ead910e766fb518a08fc2d2cf53382431313cbf -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/css/orgGrouping.css (.../orgGrouping.css) (revision 3ead910e766fb518a08fc2d2cf53382431313cbf) +++ lams_central/web/css/orgGrouping.css (.../orgGrouping.css) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -38,4 +38,48 @@ .groupCount { font-size: 12px; padding-left: 10px; +} + + +#gtbDialog > table { + width: 100%; + height: 98%; + table-layout: fixed; + border-collapse: collapse; +} + +#gtbDialog td { + text-align: center; + vertical-align: top; +} + +#gtbDialog td.branchMappingLabelCell { + height: 15px; + font-weight: bold; +} + +#gtbDialog td.branchMappingListCell { + border: thin black solid; + padding: 3px; +} + +#gtbDialog td.branchMappingListCell .selected { + background-color: #5c9ccc; + color: white; +} + +#gtbDialog .branchMappingButton { + display: block; + margin: auto; + margin-top: 10px; + margin-bottom: 10px; +} + +#gtbDialog #branchMappingOKButton { + margin-top: 5px; +} + +#gtbDialog td.branchMappingListCell div { + text-align: left; + cursor: pointer; } \ No newline at end of file Index: lams_central/web/includes/javascript/addLesson.js =================================================================== diff -u -r0e6643a46feeb0445c332f4bcc39eca01519de62 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 0e6643a46feeb0445c332f4bcc39eca01519de62) +++ lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -5,7 +5,7 @@ generatingLearningDesign = false; submitInProgress = false, originalThumbnailWidth = 0, - originalThumbnailHeight = 0, + originalThumbnailHeight = 0; /** Index: lams_central/web/includes/javascript/main.js =================================================================== diff -u -r158d458bc2a6d92107a65202f6781379ac0b5767 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/includes/javascript/main.js (.../main.js) (revision 158d458bc2a6d92107a65202f6781379ac0b5767) +++ lams_central/web/includes/javascript/main.js (.../main.js) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -387,39 +387,6 @@ }, true); } -function saveOrgGroups() { - var groupsSaved = saveGroups(); - if (groupsSaved) { - showOrgGroupDialogContents(null, 460, 460, - LAMS_URL + 'OrganisationGroup.do?method=viewGroupings&organisationID=' - + $('#dialogOrgGroup').data('orgID')); - } -} - -function showOrgGroupDialogContents(title, width, height, url) { - var id = "dialogOrgGroup", - dialog = $('#' + id), - exists = dialog.length > 0, - orgID = null; - if (exists) { - if (!title) { - title = $('.modal-title', dialog).text(); - } - orgID = dialog.data('orgID'); - } - showDialog(id, { - 'data' : { - 'orgID' : orgID - }, - 'height' : height, - 'width' : width, - 'title' : title, - 'open' : function() { - $('iframe', this).attr('src', url); - } - }, true, exists); -} - function showAddSingleActivityLessonDialog(orgID, toolID, learningLibraryID) { showDialog("dialogAddSingleActivityLesson", { 'data' : { Index: lams_central/web/includes/javascript/orgGroup.js =================================================================== diff -u -r970546106e9b05a4d1a507b26be2ce96130b4f01 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/includes/javascript/orgGroup.js (.../orgGroup.js) (revision 970546106e9b05a4d1a507b26be2ce96130b4f01) +++ lams_central/web/includes/javascript/orgGroup.js (.../orgGroup.js) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -20,9 +20,7 @@ skipAssigningWhenCreatingGroup = false; // initialisation based on mode - if (lessonMode) { - toggleBackButton(); - } else { + if (!lessonMode) { $('#groupingName').val(grouping.name); } @@ -336,7 +334,6 @@ if (executeDelete) { $('#unassignedUserCell .userContainer').append($('.userContainer div.draggableUser', container)); container.remove(); - toggleBackButton(); } } } @@ -470,21 +467,13 @@ markGroupLocked($('div[userId="' + userIds[0] + '"]').parents('.groupContainer')); alert(LABELS.GROUP_LOCK_LABEL); } - toggleBackButton(); } }); return result; } /** - * If there are any existing (not new) groups, forbid going back to grouping list. - */ -function toggleBackButton() { - $('#backButton').prop('disabled', $('.groupContainer[groupId]').length == 0); -} - -/** * Makes a group almost immutable as server does not allow changed. */ function markGroupLocked(container) { Index: lams_central/web/includes/javascript/orgGrouping.js =================================================================== diff -u -r970546106e9b05a4d1a507b26be2ce96130b4f01 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/includes/javascript/orgGrouping.js (.../orgGrouping.js) (revision 970546106e9b05a4d1a507b26be2ce96130b4f01) +++ lams_central/web/includes/javascript/orgGrouping.js (.../orgGrouping.js) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -41,133 +41,115 @@ * 1) it was taken from Authoring dialog for groups-to-branches mapping * 2) two types of groups: course and branching could easily get mixed */ - if (!gtbDialog) { - // create the dialog - gtbDialog = $('#groupMappingDialog') - .dialog({ - 'autoOpen' : false, - 'modal' : true, - 'show' : 'fold', - 'hide' : 'fold', - 'width' : 650, - 'height' : 400, - 'title' : LABELS.COURSE_GROUPS_TO_BRANCHES_MATCH_DIALOG_TITLE, - 'buttons' : [ - { - 'text' : LABELS.OK_BUTTON, - 'click' : function() { - var dialog = $(this), - groupsToBranches = []; + + var groupMappingDialogContents = $('#groupMappingDialogContents').clone().attr('id', null); + $('#branchMappingOKButton', groupMappingDialogContents).click(function(){ + var dialog = $(this).closest('.modal'), + groupsToBranches = []; + + // fill JSON with group pairs + $('.branchMappingBoundItemCell div, .branchMappingFreeItemCell div', dialog).each(function(){ + var groupID = $(this).attr('id'), + boundItem = $(this).data('boundItem'), + branchID = boundItem ? boundItem.attr('id') : null; - // fill JSON with group pairs - $('.branchMappingBoundItemCell div, .branchMappingFreeItemCell div', dialog) - .each(function(){ - var groupID = $(this).attr('id'), - boundItem = $(this).data('boundItem'), - branchID = boundItem ? boundItem.attr('id') : null; - - // add the mapping - if (branchID) { - groupsToBranches.push({ - 'groupID' : groupID, - 'branchID' : branchID - }); - } - }); - - // save the mapping - $.ajax({ - url : LAMS_URL + 'OrganisationGroup.do', - data : { - 'method' : 'saveGroupMappings', - 'mapping' : JSON.stringify(groupsToBranches) - }, - success : function(response) { - // LAMS can reply 200 even if there is an error, so we need OK response - if (response == 'OK') { - // go straight to branching groups for final check - viewGroups(groupingId, true); - } - } - }); - } - } - ], - 'open' : function(){ - var dialog = $(this), - groupsCell = $('.branchMappingFreeItemCell', dialog), - branchesCell = $('.branchMappingFreeBranchCell', dialog), - groupCell = $('.branchMappingBoundItemCell', dialog), - branchCell = $('.branchMappingBoundBranchCell', dialog); - - // clear out previous entries - $('.branchMappingListCell', dialog).empty(); - - // fetch course and branching groups - $.ajax({ - url : LAMS_URL + 'OrganisationGroup.do', - data : { - 'method' : 'getGroupsForMapping', - 'groupingId' : groupingId, - 'activityID' : groupingActivityId - }, - dataType : 'json', - success : function(response) { - // fill table with course and branching groups - $.each(response.groups, function(){ - var group = this, - groupElem = $('
').click(selectGroupMappingListItem) - .text(group.name).attr('id', group.id); - - $.each(response.branches, function() { - // check if a branching group alread exists with the same name as a course group - if (this.name == group.name) { - var branchElem = $('
').click(selectGroupMappingListItem) - .appendTo(branchCell) - .text(this.name) - .attr('id', this.id) - .data('boundItem', groupElem); - groupElem.appendTo(groupCell).data('boundItem', branchElem); - groupElem = null; - return false; - } - }); - - if (groupElem) { - // no existing mapping was found, make the group available for mapping - groupElem.appendTo(groupsCell); - } - }); - // fill in branch groups - $.each(response.branches, function(){ - $('
').click(selectGroupMappingListItem).appendTo(branchesCell) - .text(this.name).attr('id', this.id); - }); - } - }); - } + // add the mapping + if (branchID) { + groupsToBranches.push({ + 'groupID' : groupID, + 'branchID' : branchID + }); + } }); - - // initialise buttons and labels - $('.branchMappingAddButton', gtbDialog).button({ - 'icons' : { - 'primary' : 'ui-icon-seek-next' + + // save the mapping + $.ajax({ + url : LAMS_URL + 'OrganisationGroup.do', + data : { + 'method' : 'saveGroupMappings', + 'mapping' : JSON.stringify(groupsToBranches) }, - 'text' : false - }).click(function(){ - addGroupMapping(); + success : function(response) { + // LAMS can reply 200 even if there is an error, so we need OK response + if (response == 'OK') { + // go straight to branching groups for final check + viewGroups(groupingId, true); + } + } }); - $('.branchMappingRemoveButton', gtbDialog).button({ - 'icons' : { - 'primary' : 'ui-icon-seek-prev' - }, - 'text' : false - }).click(function(){ - removeGroupMapping(); - }); - } + }); - gtbDialog.dialog('open'); + // initialise the dialog buttons + $('.branchMappingAddButton', groupMappingDialogContents).click(function(){ + addGroupMapping(); + }); + $('.branchMappingRemoveButton', groupMappingDialogContents).click(function(){ + removeGroupMapping(); + }); + + // initialise dialog for matching groups to branches in branching activities + gtbDialog = showDialog('gtbDialog',{ + 'autoOpen' : false, + 'modal' : true, + 'width' : 800, + 'title' : LABELS.COURSE_GROUPS_TO_BRANCHES_MATCH_DIALOG_TITLE, + 'open' : function(){ + var dialog = $(this), + groupsCell = $('.branchMappingFreeItemCell', dialog), + branchesCell = $('.branchMappingFreeBranchCell', dialog), + groupCell = $('.branchMappingBoundItemCell', dialog), + branchCell = $('.branchMappingBoundBranchCell', dialog); + + // clear out previous entries + $('.branchMappingListCell', dialog).empty(); + + // fetch course and branching groups + $.ajax({ + url : LAMS_URL + 'OrganisationGroup.do', + data : { + 'method' : 'getGroupsForMapping', + 'groupingId' : groupingId, + 'activityID' : groupingActivityId + }, + dataType : 'json', + success : function(response) { + // fill table with course and branching groups + $.each(response.groups, function(){ + var group = this, + groupElem = $('
').click(selectGroupMappingListItem) + .text(group.name).attr('id', group.id); + + $.each(response.branches, function() { + // check if a branching group alread exists with the same name as a course group + if (this.name == group.name) { + var branchElem = $('
').click(selectGroupMappingListItem) + .appendTo(branchCell) + .text(this.name) + .attr('id', this.id) + .data('boundItem', groupElem); + groupElem.appendTo(groupCell).data('boundItem', branchElem); + groupElem = null; + return false; + } + }); + + if (groupElem) { + // no existing mapping was found, make the group available for mapping + groupElem.appendTo(groupsCell); + } + }); + // fill in branch groups + $.each(response.branches, function(){ + $('
').click(selectGroupMappingListItem).appendTo(branchesCell) + .text(this.name).attr('id', this.id); + }); + } + }); + } + }, false); + + $('.modal-body', gtbDialog).empty().append(groupMappingDialogContents.show()); + gtbDialog.modal('show'); }; /** Index: lams_central/web/orgGroup.jsp =================================================================== diff -u -r970546106e9b05a4d1a507b26be2ce96130b4f01 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/orgGroup.jsp (.../orgGroup.jsp) (revision 970546106e9b05a4d1a507b26be2ce96130b4f01) +++ lams_central/web/orgGroup.jsp (.../orgGroup.jsp) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -50,43 +50,33 @@ -
- - - - - - - - - readonly="readonly" - - /> - - - - - - - + +
+ + + readonly="readonly" - - - -
+
+ +
+
Index: lams_central/web/orgGrouping.jsp =================================================================== diff -u -r970546106e9b05a4d1a507b26be2ce96130b4f01 -r2d50303390a6ea1ec157a3a1390ecf3833c0339c --- lams_central/web/orgGrouping.jsp (.../orgGrouping.jsp) (revision 970546106e9b05a4d1a507b26be2ce96130b4f01) +++ lams_central/web/orgGrouping.jsp (.../orgGrouping.jsp) (revision 2d50303390a6ea1ec157a3a1390ecf3833c0339c) @@ -8,59 +8,21 @@ + - + +