Index: lams_central/web/includes/javascript/orgGrouping.js =================================================================== diff -u -ra778e45c1bc4216c14c4c0f3f7485da58049940f -re0dbd6beaeea905447bd9a87cd23272c4cfee853 --- lams_central/web/includes/javascript/orgGrouping.js (.../orgGrouping.js) (revision a778e45c1bc4216c14c4c0f3f7485da58049940f) +++ lams_central/web/includes/javascript/orgGrouping.js (.../orgGrouping.js) (revision e0dbd6beaeea905447bd9a87cd23272c4cfee853) @@ -2,33 +2,33 @@ if (!lessonMode && confirm(LABELS.REMOVE_GROUPING_CONFIRM_LABEL)) { //dynamically create a form and submit it var form = $('
'); - - var hiddenField = $(''); - form.append(hiddenField); - - hiddenField = $(''); - form.append(hiddenField); - hiddenField = $(''); - form.append(hiddenField); + var hiddenField = $(''); + form.append(hiddenField); - // The form needs to be a part of the document in order to be submitted - $(document.body).append(form); - form.submit(); + hiddenField = $(''); + form.append(hiddenField); + + hiddenField = $(''); + form.append(hiddenField); + + // The form needs to be a part of the document in order to be submitted + $(document.body).append(form); + form.submit(); } } function viewGroups(groupingId, force) { var url = LAMS_URL + 'grouping/viewGroups.do?organisationID=' + organisationId - + '&targetOrganisationID=' + targetOrganisationId; + + '&targetOrganisationID=' + targetOrganisationId; if (lessonId) { url += '&lessonID=' + lessonId; } // no grouping ID means we open a brand new grouping if (groupingId) { url += '&groupingId=' + groupingId; } - + if (lessonMode) { var executeShow = true; if (groupingId && !force) { @@ -38,7 +38,8 @@ } if (executeShow) { // load to current iframe - document.location.href = url + '&activityID=' + groupingActivityId; + url += '&activityID=' + groupingActivityId; + document.location.href = url; } } else { document.location.href = url; @@ -52,18 +53,18 @@ * 1) it was taken from Authoring dialog for groups-to-branches mapping * 2) two types of groups: course and branching could easily get mixed */ - + let gtbDialog = $('#groupMappingDialogContents').clone().attr('id', 'groupMappingDialog'); $('#branchMappingOKButton', gtbDialog).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; - + // add the mapping if (branchID) { groupsToBranches.push({ @@ -72,12 +73,12 @@ }); } }); - + var data = { 'mapping' : JSON.stringify(groupsToBranches) }; data[csrfTokenName] = csrfTokenValue; - + // save the mapping $.ajax({ url : LAMS_URL + 'grouping/saveGroupMappings.do', @@ -92,7 +93,7 @@ } }); }); - + // initialise the dialog buttons $('.branchMappingAddButton', gtbDialog).click(function(){ addGroupMapping(); @@ -105,10 +106,10 @@ branchesCell = $('.branchMappingFreeBranchCell', gtbDialog), groupCell = $('.branchMappingBoundItemCell', gtbDialog), branchCell = $('.branchMappingBoundBranchCell', gtbDialog); - + // clear out previous entries $('.branchMappingListCell', gtbDialog).empty(); - + // fetch course and branching groups $.ajax({ url : LAMS_URL + 'grouping/getGroupsForMapping.do', @@ -122,22 +123,22 @@ $.each(response.groups, function(){ var group = this, groupElem = $('
').click(selectGroupMappingListItem) - .text(group.name).attr('id', group.id); - + .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); + .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); @@ -146,12 +147,12 @@ // fill in branch groups $.each(response.branches, function(){ $('
').click(selectGroupMappingListItem).appendTo(branchesCell) - .text(this.name).attr('id', this.id); + .text(this.name).attr('id', this.id); }); } }); - - + + gtbDialog.modal('show'); }; @@ -162,11 +163,11 @@ var dialog = $('#groupMappingDialog'), selectedItem = $('.branchMappingFreeItemCell .selected', dialog), selectedBranch = $('.branchMappingFreeBranchCell .selected', dialog); - + if (selectedItem.length != 1 || selectedBranch.length != 1) { return; } - + // original branch stays in its list selectedBranch = selectedBranch.clone().click(selectGroupMappingListItem); // add info about the pair for later reference @@ -189,7 +190,7 @@ if (selectedItem.length != 1 || selectedBranch.length != 1) { return; } - + selectedItem.removeData('boundItem'); selectedBranch.remove(); $('.branchMappingFreeItemCell', dialog).append(selectedItem); @@ -201,10 +202,10 @@ function selectGroupMappingListItem(){ var item = $(this), boundItem = item.data('boundItem'); - + item.siblings().removeClass('selected'); item.addClass('selected'); - + if (boundItem) { boundItem.siblings().removeClass('selected'); boundItem.addClass('selected');