Index: lams_gradebook/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r138af39881dedacbd449ef73252b41150e20ecf9 -r0aa9f13e05d384ced6793a22c6a72057c071fc42 --- lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 138af39881dedacbd449ef73252b41150e20ecf9) +++ lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 0aa9f13e05d384ced6793a22c6a72057c071fc42) @@ -35,7 +35,8 @@ gradebook.monitor.releasemarks.check.hide = Are you sure you want to hide marks from learners for this lesson? gradebook.monitor.releasemarks.toggle.panel.tooltip = Shows/hides a panel where learners can get notified of their marks for the this lesson. gradebook.monitor.releasemarks.send.emails = Email learners -gradebook.monitor.releasemarks.send.emails.confirm = Are you sure you want to send emails with lesson results to all learners checked in the list? +gradebook.monitor.releasemarks.send.emails.confirm = Are you sure you want to send emails with lesson results to all [COUNT_PLACEHOLDER] learners checked in the list? +gradebook.monitor.releasemarks.send.emails.no.learners = No learners selected gradebook.monitor.releasemarks.email.preview = Email preview for gradebook.monitor.releasemarks.schedule.button = Schedule release gradebook.monitor.releasemarks.schedule.date = Schedule date Index: lams_gradebook/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rd9ac3091229c48f9c72cf08774e7818edafeb195 -r0aa9f13e05d384ced6793a22c6a72057c071fc42 --- lams_gradebook/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision d9ac3091229c48f9c72cf08774e7818edafeb195) +++ lams_gradebook/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 0aa9f13e05d384ced6793a22c6a72057c071fc42) @@ -35,7 +35,8 @@ gradebook.monitor.releasemarks.check.hide = Are you sure you want to hide marks from learners for this lesson? gradebook.monitor.releasemarks.toggle.panel.tooltip = Shows/hides a panel where learners can get notified of their marks for the this lesson. gradebook.monitor.releasemarks.send.emails = Email learners -gradebook.monitor.releasemarks.send.emails.confirm = Are you sure you want to send emails with lesson results to all learners checked in the list? +gradebook.monitor.releasemarks.send.emails.confirm = Are you sure you want to send emails with lesson results to all [COUNT_PLACEHOLDER] learners checked in the list? +gradebook.monitor.releasemarks.send.emails.no.learners = No learners selected gradebook.monitor.releasemarks.email.preview = Email preview for gradebook.monitor.releasemarks.schedule.button = Schedule release gradebook.monitor.releasemarks.schedule.date = Schedule date Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/controller/GradebookMonitoringController.java =================================================================== diff -u -r8eaff3948232f090f7dee5f7df1a4753b4c4a1e8 -r0aa9f13e05d384ced6793a22c6a72057c071fc42 --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/controller/GradebookMonitoringController.java (.../GradebookMonitoringController.java) (revision 8eaff3948232f090f7dee5f7df1a4753b4c4a1e8) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/controller/GradebookMonitoringController.java (.../GradebookMonitoringController.java) (revision 0aa9f13e05d384ced6793a22c6a72057c071fc42) @@ -298,44 +298,21 @@ return gradebookService.getReleaseMarksEmailContent(lessonID, userID); } - @SuppressWarnings("unchecked") @RequestMapping("/sendReleaseMarksEmails") @ResponseBody public String sendReleaseMarksEmails(@RequestParam long lessonID, - @RequestParam(name = "includedLearners", required = false) String includedLearnersString, - @RequestParam(name = "excludedLearners", required = false) String excludedLearnersString) + @RequestParam(name = "includedLearners") String includedLearnersString) throws JsonProcessingException, IOException { - ArrayNode includedLearners = StringUtils.isBlank(includedLearnersString) ? null - : JsonUtil.readArray(includedLearnersString); - ArrayNode excludedLearners = StringUtils.isBlank(excludedLearnersString) ? null - : JsonUtil.readArray(excludedLearnersString); - if (includedLearners == null && excludedLearners == null) { - throw new IllegalArgumentException( - "neither included nor excluded learners found when sending an email with marks."); - } + if (StringUtils.isBlank(includedLearnersString)) { + return "list of recipients is empty"; + } + ArrayNode includedLearners = JsonUtil.readArray(includedLearnersString); try { Set recipientIDs = new HashSet<>(); - if (excludedLearners == null) { - // we send emails only to selected learners - for (int learnerIndex = 0; learnerIndex < includedLearners.size(); learnerIndex++) { - recipientIDs.add(includedLearners.get(learnerIndex).asInt()); - } - } else { - List learners = lessonService.getActiveLessonLearners(lessonID); - // we send emails to all lesson learners, excluding one who got deselected - for (User learner : learners) { - boolean excludedLearnerFound = false; - for (int learnerIndex = 0; learnerIndex < excludedLearners.size(); learnerIndex++) { - if (learner.getUserId().equals(excludedLearners.get(learnerIndex).asInt())) { - excludedLearnerFound = true; - break; - } - } - if (!excludedLearnerFound) { - recipientIDs.add(learner.getUserId()); - } - } + // we send emails only to selected learners + for (int learnerIndex = 0; learnerIndex < includedLearners.size(); learnerIndex++) { + recipientIDs.add(includedLearners.get(learnerIndex).asInt()); } if (recipientIDs.isEmpty()) { @@ -360,7 +337,7 @@ Date scheduleDate = null; if (StringUtils.isNotBlank(scheduleDateString)) { scheduleDate = RELEASE_MARKS_SCHEDULE_DATE_FORMAT.parse(scheduleDateString); - + // set seconds and miliseconds to 0 Calendar calendarDate = Calendar.getInstance(); calendarDate.setTime(scheduleDate); Index: lams_gradebook/web/releaseLessonMarks.jsp =================================================================== diff -u -rc324f3f77b2534affdb642421d9d9f093640a4de -r0aa9f13e05d384ced6793a22c6a72057c071fc42 --- lams_gradebook/web/releaseLessonMarks.jsp (.../releaseLessonMarks.jsp) (revision c324f3f77b2534affdb642421d9d9f093640a4de) +++ lams_gradebook/web/releaseLessonMarks.jsp (.../releaseLessonMarks.jsp) (revision 0aa9f13e05d384ced6793a22c6a72057c071fc42) @@ -87,7 +87,7 @@ // release/hide marks function toggleMarksRelease() { - if (confirm(marksReleased ? "" : "")) { + if (confirm(marksReleased ? "" : "")) { releaseMarksAlertBox.hide(); $.ajax({ @@ -111,21 +111,33 @@ } function sendReleaseMarksEmails(){ - if (!confirm('')){ + releaseMarksAlertBox.hide(); + + let grid = $("#release-marks-learners-table"), + filteredData = grid.jqGrid('getGridParam', 'lastSelectedData'), + selectedLearners = grid.jqGrid('getGridParam','selarrrow'), + finalList = []; + filteredData.forEach(function(learner){ + if (selectedLearners.indexOf(learner.id) >= 0) { + finalList.push(this.id); + } + }); + + if (finalList.length == 0) { + releaseMarksAlertBox.removeClass('alert-success').addClass('alert-danger') + .text('').show(); return; } - let grid = $("#release-marks-learners-table"), - includedLearners = grid.data('included'), - excludedLearners = grid.data('excluded'); - releaseMarksAlertBox.hide(); + if (!confirm(''.replace('[COUNT_PLACEHOLDER]', finalList.length))){ + return; + } $.ajax({ 'url' : 'gradebook/gradebookMonitoring/sendReleaseMarksEmails.do', 'data' : { 'lessonID' : releaseMarksLessonID, - 'includedLearners' : includedLearners === null ? null : JSON.stringify(includedLearners), - 'excludedLearners' : excludedLearners === null ? null : JSON.stringify(excludedLearners) + 'includedLearners' : JSON.stringify(finalList) }, 'dataType' : 'text', 'cache' : false, @@ -187,88 +199,41 @@ highlightReleaseMarksLearnerRow(row.attr('id')); return false; }, - onSelectRow : function(id, status, event) { - var grid = $(this), - included = grid.data('included'), - excluded = grid.data('excluded'), - selectAllChecked = grid.closest('.ui-jqgrid-view').find('.jqgh_cbox .cbox').prop('checked'); - if (selectAllChecked) { - var index = excluded.indexOf(+id); - // if row is deselected, add it to excluded array - if (index < 0) { - if (!status) { - excluded.push(+id); - } - } else if (status) { - excluded.splice(index, 1); - } - } else { - var index = included.indexOf(+id); - // if row is selected, add it to included array - if (index < 0) { - if (status) { - included.push(+id); - } - } else if (!status) { - included.splice(index, 1); - } - } - }, gridComplete : function(){ let grid = $(this), - rows = grid.jqGrid('getGridParam','data'), - included = grid.data('included'), - // cell containing "(de)select all" button - selectAllCell = grid.closest('.ui-jqgrid-view').find('.jqgh_cbox > div'); + rows = $('[role="row"]:not(.jqgfirstrow)', grid), + mode = grid.data('mode'), + // cell containing "(de)select all" button + selectAllCell = grid.closest('.ui-jqgrid-view').find('.ui-jqgrid-labels .jqgh_cbox > div'); // remove the default button provided by jqGrid $('.cbox', selectAllCell).remove(); // create own button which follows own rules var selectAllCheckbox = $('') - .prop('checked', included === null) + .prop('checked', mode == 'all' || mode == 'start') .prependTo(selectAllCell) .change(function(){ - // start with deselecting everyone on current page + // start with deselecting grid.resetSelection(); + var ids = []; if ($(this).prop('checked')){ - // on select all change mode and select all on current page - grid.data('included', null); - grid.data('excluded', []); - rows.each(function(){ - grid.jqGrid('setSelection', this.id, false); + grid.data('mode', 'all'); + // on select all change mode and select all + grid.jqGrid('getGridParam', 'data').forEach(function(row) { + ids.push(row.id); + // also select on current page as it is too late for selarrrow to be picked up + grid.jqGrid("setSelection", row.id, false); }); } else { - // on deselect all just change mode - grid.data('excluded', null); - grid.data('included', []); + grid.data('mode', 'none'); } + grid.jqGrid("setGridParam", { selarrrow: ids }, true); }); - - grid.resetSelection(); - if (selectAllCheckbox.prop('checked')) { - var excluded = grid.data('excluded'); - // go through each loaded row - $('[role="row"]', grid).each(function(){ - var id = +$(this).attr('id'), - selected = $(this).hasClass('success'); - // if row is not selected and is not excluded, select it - if (!selected && (!excluded || !excluded.includes(id))) { - // select without triggering onSelectRow - grid.jqGrid('setSelection', id, false); - } - }); - } else { - // go through each loaded row - $('[role="row"]', grid).each(function(){ - var id = +$(this).attr('id'), - selected = $(this).hasClass('success'); - // if row is not selected and is included, select it - if (!selected && included.includes(id)) { - // select without triggering onSelectRow - grid.jqGrid('setSelection', id, false); - } - }); + + // initial select all + if (mode == 'start') { + selectAllCheckbox.change(); } - + if (rows.length === 0) { // empty email preview on grid page change $('#release-marks-email-preview').slideUp(function(){ @@ -278,8 +243,12 @@ // highlight first row highlightReleaseMarksLearnerRow(rows[0].id); } - }}).data({'included' : null, - 'excluded' : []}); + }}).data({'mode' : 'start'}) + .jqGrid('filterToolbar', { + stringResult: true, + searchOnEnter: true, + defaultSearch: 'cn' + }); } function highlightReleaseMarksLearnerRow(userID) { Index: lams_monitoring/web/emailnotifications/lessonNotifications.jsp =================================================================== diff -u -r40de3afab4e8d589660daffb6efd6e568e87f8fa -r0aa9f13e05d384ced6793a22c6a72057c071fc42 --- lams_monitoring/web/emailnotifications/lessonNotifications.jsp (.../lessonNotifications.jsp) (revision 40de3afab4e8d589660daffb6efd6e568e87f8fa) +++ lams_monitoring/web/emailnotifications/lessonNotifications.jsp (.../lessonNotifications.jsp) (revision 0aa9f13e05d384ced6793a22c6a72057c071fc42) @@ -52,7 +52,7 @@ {name:'name',index:'name', width:260, firstsortorder:'desc', sorttype: 'text'} ], rowList:[10,20,30,40,50,100], - rowNum:10, + rowNum:2, pager: '#pager3', sortname: 'name', multiselect: true,