Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -r746369b4989a3ccae7c71d6a07bbb79ab4f47689 -r8ea1e40c1667699690a4f1047e31dfaa0f372c76 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 746369b4989a3ccae7c71d6a07bbb79ab4f47689) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 8ea1e40c1667699690a4f1047e31dfaa0f372c76) @@ -1447,120 +1447,114 @@ } @Override - public List exportSummary(Assessment assessment, List sessionDtos, - boolean showUserNames) { + public List exportSummary(Assessment assessment, List sessionDtos) { List sheets = new LinkedList(); // -------------- First tab: Summary ---------------------------------------------------- - if (showUserNames) { - ExcelSheet summarySheet = new ExcelSheet(getMessage("label.export.summary")); - sheets.add(summarySheet); + ExcelSheet summarySheet = new ExcelSheet(getMessage("label.export.summary")); + sheets.add(summarySheet); - if (sessionDtos != null) { - for (SessionDTO sessionDTO : sessionDtos) { - Long sessionId = sessionDTO.getSessionId(); + if (sessionDtos != null) { + for (SessionDTO sessionDTO : sessionDtos) { + Long sessionId = sessionDTO.getSessionId(); - summarySheet.addEmptyRow(); + summarySheet.addEmptyRow(); - ExcelRow sessionTitleRow = summarySheet.initRow(); - sessionTitleRow.addCell(sessionDTO.getSessionName(), true); + ExcelRow sessionTitleRow = summarySheet.initRow(); + sessionTitleRow.addCell(sessionDTO.getSessionName(), true); - List userDtos = new ArrayList<>(); - // in case of UseSelectLeaderToolOuput - display only one user - if (assessment.isUseSelectLeaderToolOuput()) { + List userDtos = new ArrayList<>(); + // in case of UseSelectLeaderToolOuput - display only one user + if (assessment.isUseSelectLeaderToolOuput()) { - AssessmentSession session = getSessionBySessionId(sessionId); - AssessmentUser groupLeader = session.getGroupLeader(); + AssessmentSession session = getSessionBySessionId(sessionId); + AssessmentUser groupLeader = session.getGroupLeader(); - if (groupLeader != null) { + if (groupLeader != null) { - float assessmentResult = getLastTotalScoreByUser(assessment.getUid(), - groupLeader.getUserId()); + float assessmentResult = getLastTotalScoreByUser(assessment.getUid(), groupLeader.getUserId()); - AssessmentUserDTO userDto = new AssessmentUserDTO(); - userDto.setFirstName(groupLeader.getFirstName()); - userDto.setLastName(groupLeader.getLastName()); - userDto.setGrade(assessmentResult); - userDtos.add(userDto); - } + AssessmentUserDTO userDto = new AssessmentUserDTO(); + userDto.setFirstName(groupLeader.getFirstName()); + userDto.setLastName(groupLeader.getLastName()); + userDto.setGrade(assessmentResult); + userDtos.add(userDto); + } - } else { - int countSessionUsers = sessionDTO.getNumberLearners(); + } else { + int countSessionUsers = sessionDTO.getNumberLearners(); - // Get the user list from the db - userDtos = getPagedUsersBySession(sessionId, 0, countSessionUsers, "userName", "ASC", ""); - } + // Get the user list from the db + userDtos = getPagedUsersBySession(sessionId, 0, countSessionUsers, "userName", "ASC", ""); + } - float minGrade = -9999999; - float maxGrade = 0; - for (AssessmentUserDTO userDto : userDtos) { - float grade = userDto.getGrade(); - if (grade < minGrade || minGrade == -9999999) { - minGrade = grade; - } - if (grade > maxGrade) { - maxGrade = grade; - } + float minGrade = -9999999; + float maxGrade = 0; + for (AssessmentUserDTO userDto : userDtos) { + float grade = userDto.getGrade(); + if (grade < minGrade || minGrade == -9999999) { + minGrade = grade; } - if (minGrade == -9999999) { - minGrade = 0; + if (grade > maxGrade) { + maxGrade = grade; } + } + if (minGrade == -9999999) { + minGrade = 0; + } - LinkedHashMap markSummary = getMarksSummaryForSession(userDtos, minGrade, maxGrade, - 10); - // work out total marks so we can do percentages. need as float for the correct divisions - int totalNumEntries = 0; - for (Map.Entry entry : markSummary.entrySet()) { - totalNumEntries += entry.getValue(); - } + LinkedHashMap markSummary = getMarksSummaryForSession(userDtos, minGrade, maxGrade, + 10); + // work out total marks so we can do percentages. need as float for the correct divisions + int totalNumEntries = 0; + for (Map.Entry entry : markSummary.entrySet()) { + totalNumEntries += entry.getValue(); + } - // Mark Summary Min, Max + Grouped Percentages - summarySheet.addEmptyRow(); - ExcelRow minMaxRow = summarySheet.initRow(); - minMaxRow.addCell(getMessage("label.number.learners"), true); - minMaxRow.addCell(totalNumEntries); - - minMaxRow = summarySheet.initRow(); - minMaxRow.addCell(getMessage("label.lowest.mark"), true); - minMaxRow.addCell((double) minGrade); - - minMaxRow = summarySheet.initRow(); - minMaxRow.addCell(getMessage("label.highest.mark"), true); - minMaxRow.addCell((double) maxGrade); - summarySheet.addEmptyRow(); - - ExcelRow binSummaryRow = summarySheet.initRow(); - binSummaryRow.addCell(getMessage("label.authoring.basic.list.header.mark"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - binSummaryRow.addCell(getMessage("label.number.learners"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - binSummaryRow.addCell(getMessage("label.percentage"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - float totalNumEntriesAsFloat = totalNumEntries; - for (Map.Entry entry : markSummary.entrySet()) { - binSummaryRow = summarySheet.initRow(); - binSummaryRow.addCell(entry.getKey()); - binSummaryRow.addCell(entry.getValue()); - binSummaryRow.addCell(Math.round(entry.getValue() / totalNumEntriesAsFloat * 100)); - } - summarySheet.addEmptyRow(); - summarySheet.addEmptyRow(); + // Mark Summary Min, Max + Grouped Percentages + summarySheet.addEmptyRow(); + ExcelRow minMaxRow = summarySheet.initRow(); + minMaxRow.addCell(getMessage("label.number.learners"), true); + minMaxRow.addCell(totalNumEntries); - ExcelRow summaryTitleRow = summarySheet.initRow(); - summaryTitleRow.addCell(getMessage("label.export.user.id"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - summaryTitleRow.addCell(getMessage("label.monitoring.summary.user.name"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - summaryTitleRow.addCell(getMessage("label.monitoring.summary.total"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); + minMaxRow = summarySheet.initRow(); + minMaxRow.addCell(getMessage("label.lowest.mark"), true); + minMaxRow.addCell((double) minGrade); - for (AssessmentUserDTO userDto : userDtos) { - ExcelRow userResultRow = summarySheet.initRow(); - userResultRow.addCell(userDto.getLogin()); - userResultRow.addCell(userDto.getFirstName() + " " + userDto.getLastName()); - userResultRow.addCell(userDto.getGrade()); - } - summarySheet.addEmptyRow(); + minMaxRow = summarySheet.initRow(); + minMaxRow.addCell(getMessage("label.highest.mark"), true); + minMaxRow.addCell((double) maxGrade); + summarySheet.addEmptyRow(); + + ExcelRow binSummaryRow = summarySheet.initRow(); + binSummaryRow.addCell(getMessage("label.authoring.basic.list.header.mark"), true, + ExcelCell.BORDER_STYLE_BOTTOM_THIN); + binSummaryRow.addCell(getMessage("label.number.learners"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + binSummaryRow.addCell(getMessage("label.percentage"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + float totalNumEntriesAsFloat = totalNumEntries; + for (Map.Entry entry : markSummary.entrySet()) { + binSummaryRow = summarySheet.initRow(); + binSummaryRow.addCell(entry.getKey()); + binSummaryRow.addCell(entry.getValue()); + binSummaryRow.addCell(Math.round(entry.getValue() / totalNumEntriesAsFloat * 100)); } + summarySheet.addEmptyRow(); + summarySheet.addEmptyRow(); + + ExcelRow summaryTitleRow = summarySheet.initRow(); + summaryTitleRow.addCell(getMessage("label.export.user.id"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + summaryTitleRow.addCell(getMessage("label.monitoring.summary.user.name"), true, + ExcelCell.BORDER_STYLE_BOTTOM_THIN); + summaryTitleRow.addCell(getMessage("label.monitoring.summary.total"), true, + ExcelCell.BORDER_STYLE_BOTTOM_THIN); + + for (AssessmentUserDTO userDto : userDtos) { + ExcelRow userResultRow = summarySheet.initRow(); + userResultRow.addCell(userDto.getLogin()); + userResultRow.addCell(userDto.getFirstName() + " " + userDto.getLastName()); + userResultRow.addCell(userDto.getGrade()); + } + summarySheet.addEmptyRow(); } } @@ -1587,24 +1581,19 @@ ExcelCell.BORDER_STYLE_BOTTOM_THIN); questionTitleRow.addCell(getMessage("label.authoring.basic.penalty.factor"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - questionTitleRow.addCell(getMessage("label.monitoring.question.summary.default.mark"), - true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - questionTitleRow.addCell(getMessage("label.export.user.id"), true, + questionTitleRow.addCell(getMessage("label.monitoring.question.summary.default.mark"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - if (showUserNames) { - questionTitleRow.addCell(getMessage("label.monitoring.user.summary.user.name"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - } + questionTitleRow.addCell(getMessage("label.export.user.id"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + questionTitleRow.addCell(getMessage("label.monitoring.user.summary.user.name"), true, + ExcelCell.BORDER_STYLE_BOTTOM_THIN); questionTitleRow.addCell(getMessage("label.export.date.attempted"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); questionTitleRow.addCell(getMessage("label.export.time.attempted"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); questionTitleRow.addCell(getMessage("label.authoring.basic.option.answer"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); - questionTitleRow.addCell(getMessage("label.export.time.taken"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); - questionTitleRow.addCell(getMessage("label.export.mark"), true, - ExcelCell.BORDER_STYLE_BOTTOM_THIN); + questionTitleRow.addCell(getMessage("label.export.time.taken"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + questionTitleRow.addCell(getMessage("label.export.mark"), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); int questionNumber = 1; @@ -1636,24 +1625,17 @@ Set options = question.getOptions(); // question row title ExcelRow hedgeQuestionTitleRow = new ExcelRow(); - hedgeQuestionTitleRow.addCell( - getMessage("label.monitoring.question.summary.question"), true); - hedgeQuestionTitleRow.addCell(getMessage("label.authoring.basic.list.header.type"), - true); - hedgeQuestionTitleRow.addCell(getMessage("label.authoring.basic.penalty.factor"), - true); - hedgeQuestionTitleRow.addCell( - getMessage("label.monitoring.question.summary.default.mark"), true); + hedgeQuestionTitleRow.addCell(getMessage("label.monitoring.question.summary.question"), true); + hedgeQuestionTitleRow.addCell(getMessage("label.authoring.basic.list.header.type"), true); + hedgeQuestionTitleRow.addCell(getMessage("label.authoring.basic.penalty.factor"), true); + hedgeQuestionTitleRow.addCell(getMessage("label.monitoring.question.summary.default.mark"), true); hedgeQuestionTitleRow.addCell(getMessage("label.export.user.id"), true); - if (showUserNames) { - hedgeQuestionTitleRow.addCell( - getMessage("label.monitoring.user.summary.user.name"), true); - } + hedgeQuestionTitleRow.addCell(getMessage("label.monitoring.user.summary.user.name"), true); hedgeQuestionTitleRow.addCell(getMessage("label.export.date.attempted"), true); hedgeQuestionTitleRow.addCell(getMessage("label.export.time.attempted"), true); for (AssessmentQuestionOption option : options) { - ExcelCell cell = hedgeQuestionTitleRow.addCell( - option.getOptionString().replaceAll("\\<.*?\\>", ""), true); + ExcelCell cell = hedgeQuestionTitleRow + .addCell(option.getOptionString().replaceAll("\\<.*?\\>", ""), true); if (option.isCorrect()) { cell.setColor(IndexedColors.GREEN); } @@ -1679,18 +1661,13 @@ userResultRow.addCell(questionResult.getAssessmentQuestion().getTitle()); userResultRow.addCell( getQuestionTypeLanguageLabel(questionResult.getAssessmentQuestion().getType())); - userResultRow.addCell( - Float.valueOf(questionResult.getAssessmentQuestion().getPenaltyFactor())); + userResultRow.addCell(Float.valueOf(questionResult.getAssessmentQuestion().getPenaltyFactor())); Float maxMark = (questionResult.getMaxMark() == null) ? 0 : Float.valueOf(questionResult.getMaxMark()); userResultRow.addCell(maxMark); - if (showUserNames) { - userResultRow.addCell(questionResult.getUser().getLoginName()); - userResultRow.addCell(questionResult.getUser().getFullName()); - } else { - userResultRow.addCell(questionResult.getUser().getUserId()); - } - + userResultRow.addCell(questionResult.getUser().getLoginName()); + userResultRow.addCell(questionResult.getUser().getFullName()); + //date and time ExcelCell dateCell = userResultRow.addCell(questionResult.getFinishDate()); dateCell.setDataFormat(ExcelCell.CELL_FORMAT_DATE); @@ -1751,7 +1728,7 @@ // Calculating the averages ExcelRow averageRow = questionSummarySheet.initRow(); - averageRow.addEmptyCells(showUserNames ? 8 : 7); + averageRow.addEmptyCells(8); averageRow.addCell(getMessage("label.export.average"), true); if (timeTakenTotal > 0) { averageRow.addCell(Long.valueOf(timeTakenTotal / timeTakenCount)); @@ -1857,39 +1834,22 @@ Set assessmentUsers = assessmentSession.getAssessmentUsers(); if (assessmentUsers != null) { for (AssessmentUser assessmentUser : assessmentUsers) { - if (showUserNames) { - ExcelRow userTitleRow = userSummarySheet.initRow(); - userTitleRow.addCell(getMessage("label.export.user.id"), true); - userTitleRow.addCell(getMessage("label.monitoring.user.summary.user.name"), - true); - userTitleRow.addCell(getMessage("label.export.date.attempted"), true); - userTitleRow.addCell(getMessage("label.monitoring.question.summary.question"), - true); - userTitleRow.addCell(getMessage("label.authoring.basic.option.answer"), true); - userTitleRow.addCell(getMessage("label.export.mark"), true); + ExcelRow userTitleRow = userSummarySheet.initRow(); + userTitleRow.addCell(getMessage("label.export.user.id"), true); + userTitleRow.addCell(getMessage("label.monitoring.user.summary.user.name"), true); + userTitleRow.addCell(getMessage("label.export.date.attempted"), true); + userTitleRow.addCell(getMessage("label.monitoring.question.summary.question"), true); + userTitleRow.addCell(getMessage("label.authoring.basic.option.answer"), true); + userTitleRow.addCell(getMessage("label.export.mark"), true); - } else { - ExcelRow userTitleRow = userSummarySheet.initRow(); - userTitleRow.addCell(getMessage("label.export.user.id"), true); - userTitleRow.addCell(getMessage("label.export.date.attempted"), true); - userTitleRow.addCell(getMessage("label.monitoring.question.summary.question"), - true); - userTitleRow.addCell(getMessage("label.authoring.basic.option.answer"), true); - userTitleRow.addCell(getMessage("label.export.mark"), true); - } - AssessmentResult assessmentResult = userUidToResultMap.get(assessmentUser.getUid()); if (assessmentResult != null) { Set questionResults = assessmentResult.getQuestionResults(); if (questionResults != null) { for (AssessmentQuestionResult questionResult : questionResults) { ExcelRow userResultRow = userSummarySheet.initRow(); - if (showUserNames) { - userResultRow.addCell(assessmentUser.getLoginName()); - userResultRow.addCell(assessmentUser.getFullName()); - } else { - userResultRow.addCell(assessmentUser.getUserId()); - } + userResultRow.addCell(assessmentUser.getLoginName()); + userResultRow.addCell(assessmentUser.getFullName()); userResultRow.addCell(assessmentResult.getStartDate()); userResultRow.addCell(questionResult.getAssessmentQuestion().getTitle()); userResultRow.addCell( @@ -1899,7 +1859,7 @@ } ExcelRow userTotalRow = userSummarySheet.initRow(); - userTotalRow.addEmptyCells(showUserNames ? 4 : 3); + userTotalRow.addEmptyCells(4); userTotalRow.addCell(getMessage("label.monitoring.summary.total"), true); userTotalRow.addCell(assessmentResult.getGrade()); userSummarySheet.addEmptyRow(); Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java =================================================================== diff -u -r20aa6cbca9fc96d341080e6ad39f82593443f792 -r8ea1e40c1667699690a4f1047e31dfaa0f372c76 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision 20aa6cbca9fc96d341080e6ad39f82593443f792) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision 8ea1e40c1667699690a4f1047e31dfaa0f372c76) @@ -444,11 +444,9 @@ * * @param assessment * @param sessionDtos - * @param showUserNames * @return */ - List exportSummary(Assessment assessment, List sessionDtos, - boolean showUserNames); + List exportSummary(Assessment assessment, List sessionDtos); /** * Gets the basic statistics for the grades for the Leaders when an Assessment is done using Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java =================================================================== diff -u -rbac8a1d9f2b37ca6e26f275886b9e6603a6c0fb7 -r8ea1e40c1667699690a4f1047e31dfaa0f372c76 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision bac8a1d9f2b37ca6e26f275886b9e6603a6c0fb7) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 8ea1e40c1667699690a4f1047e31dfaa0f372c76) @@ -503,7 +503,6 @@ public void exportSummary(HttpServletRequest request, HttpServletResponse response) throws IOException { String sessionMapID = request.getParameter(AssessmentConstants.ATTR_SESSION_MAP_ID); String fileName = null; - boolean showUserNames = true; Long contentId = null; List sessionDtos; @@ -512,13 +511,11 @@ .getAttribute(sessionMapID); request.setAttribute(AssessmentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); contentId = (Long) sessionMap.get(AssessmentConstants.ATTR_TOOL_CONTENT_ID); - showUserNames = true; sessionDtos = (List) sessionMap.get("sessionDtos"); } else { contentId = WebUtil.readLongParam(request, "toolContentID"); fileName = WebUtil.readStrParam(request, "fileName"); - showUserNames = false; sessionDtos = service.getSessionDtos(contentId, true); } @@ -527,7 +524,7 @@ return; } - List sheets = service.exportSummary(assessment, sessionDtos, showUserNames); + List sheets = service.exportSummary(assessment, sessionDtos); // Setting the filename if it wasn't passed in the request if (fileName == null) {