Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java =================================================================== diff -u -r03551a8e9a6846cc84e9b3627b8c7b118f1f4504 -r262aeb03fd125991274edab2ce2f6dcb2b1b4714 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 03551a8e9a6846cc84e9b3627b8c7b118f1f4504) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 262aeb03fd125991274edab2ce2f6dcb2b1b4714) @@ -375,7 +375,7 @@ request.setAttribute(AssessmentConstants.ATTR_CODE_STYLES, codeStyles); } } - + return "pages/monitoring/parts/usersummary"; } @@ -877,25 +877,27 @@ * @throws IOException */ @RequestMapping(path = "/discloseCorrectAnswers", method = RequestMethod.POST) - public void discloseCorrectAnswers(HttpServletRequest request, HttpServletResponse response) throws IOException { - Long questionUid = WebUtil.readLongParam(request, "questionUid"); - Long toolContentId = WebUtil.readLongParam(request, AssessmentConstants.PARAM_TOOL_CONTENT_ID); + public void discloseCorrectAnswers(@RequestParam long questionUid, @RequestParam long toolContentID, + @RequestParam(required = false) boolean skipLearnersNotification, HttpServletResponse response) + throws IOException { AssessmentQuestion question = service.getAssessmentQuestionByUid(questionUid); if (question.isCorrectAnswersDisclosed()) { log.warn( "Trying to disclose correct answers when they are already disclosed for Assessment tool content ID " - + toolContentId + " and question UID: " + questionUid); + + toolContentID + " and question UID: " + questionUid); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } question.setCorrectAnswersDisclosed(true); service.updateAssessmentQuestion(question); - service.notifyLearnersOnAnswerDisclose(toolContentId); + if (!skipLearnersNotification) { + service.notifyLearnersOnAnswerDisclose(toolContentID); + } if (log.isDebugEnabled()) { - log.debug("Disclosed correct answers for Assessment tool content ID " + toolContentId + " and question ID " + log.debug("Disclosed correct answers for Assessment tool content ID " + toolContentID + " and question ID " + questionUid); } } @@ -906,25 +908,27 @@ * @throws IOException */ @RequestMapping(path = "/discloseGroupsAnswers", method = RequestMethod.POST) - public void discloseGroupsAnswers(HttpServletRequest request, HttpServletResponse response) throws IOException { - Long questionUid = WebUtil.readLongParam(request, "questionUid"); - Long toolContentId = WebUtil.readLongParam(request, AssessmentConstants.PARAM_TOOL_CONTENT_ID); + public void discloseGroupsAnswers(@RequestParam long questionUid, @RequestParam long toolContentID, + @RequestParam(required = false) boolean skipLearnersNotification, HttpServletResponse response) + throws IOException { AssessmentQuestion question = service.getAssessmentQuestionByUid(questionUid); if (question.isGroupsAnswersDisclosed()) { log.warn("Trying to disclose group answers when they are already disclosed for Assessment tool content ID " - + toolContentId + " and question UID: " + questionUid); + + toolContentID + " and question UID: " + questionUid); response.sendError(HttpServletResponse.SC_BAD_REQUEST); return; } question.setGroupsAnswersDisclosed(true); service.updateAssessmentQuestion(question); - service.notifyLearnersOnAnswerDisclose(toolContentId); + if (!skipLearnersNotification) { + service.notifyLearnersOnAnswerDisclose(toolContentID); + } if (log.isDebugEnabled()) { - log.debug("Disclosed other groups' answers for Assessment tool content ID " + toolContentId + log.debug("Disclosed other groups' answers for Assessment tool content ID " + toolContentID + " and question ID " + questionUid); } } Index: lams_tool_assessment/web/pages/monitoring/summary.jsp =================================================================== diff -u -rdcb841b4b4a04f726fe9f4581e2864c243e18724 -r262aeb03fd125991274edab2ce2f6dcb2b1b4714 --- lams_tool_assessment/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision dcb841b4b4a04f726fe9f4581e2864c243e18724) +++ lams_tool_assessment/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 262aeb03fd125991274edab2ce2f6dcb2b1b4714) @@ -256,16 +256,22 @@ if (!confirm("")) { return; }; - - $('option[correctDisclosed="false"]', questionUidSelect).each(function(){ + + let nonDisclosedQuestions = $('option[correctDisclosed="false"]', questionUidSelect), + lastQuestionUid = nonDisclosedQuestions.last().val(); + nonDisclosedQuestions.each(function(index){ var option = $(this), - questionUid = option.val(); + questionUid = option.val(), + // we notify learners only once, by the last question + isLast = questionUid == lastQuestionUid; + $.ajax({ type: 'POST', 'url' : 'monitoring/discloseCorrectAnswers.do?', 'data' : { 'questionUid' : questionUid, - 'toolContentID' : '${sessionMap.assessment.contentId}' + 'toolContentID' : '${sessionMap.assessment.contentId}', + 'skipLearnersNotification' : !isLast } }).done(function(){ option.attr('correctDisclosed', 'true'); @@ -282,15 +288,21 @@ return; }; - $('option[groupsDisclosed="false"]', questionUidSelect).each(function(){ + let nonDisclosedQuestions = $('option[groupsDisclosed="false"]', questionUidSelect), + lastQuestionUid = nonDisclosedQuestions.last().val(); + nonDisclosedQuestions.each(function(){ var option = $(this), - questionUid = option.val(); + questionUid = option.val(), + // we notify learners only once, by the last question + isLast = questionUid == lastQuestionUid; + $.ajax({ type: 'POST', 'url' : 'monitoring/discloseGroupsAnswers.do?', 'data' : { 'questionUid' : questionUid, - 'toolContentID' : '${sessionMap.assessment.contentId}' + 'toolContentID' : '${sessionMap.assessment.contentId}', + 'skipLearnersNotification' : !isLast } }).done(function(){ option.attr('groupsDisclosed', 'true');