Index: lams_tool_assessment/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r57a3aa14acf1aecf9450ab6a8cc473ae470fc6c5 -r550273f1b39b2bd221b2cbf2c858fa93888eabe4 --- lams_tool_assessment/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 57a3aa14acf1aecf9450ab6a8cc473ae470fc6c5) +++ lams_tool_assessment/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 550273f1b39b2bd221b2cbf2c858fa93888eabe4) @@ -201,6 +201,7 @@ label.export.summary.by.user = Summary by learner lable.export.summary.by.question = Summary by question label.export.user.id = User name +label.export.section.mark = Marks per section label.authoring.basic.allow.learners.rich.editor = Allow learners to use rich text editor label.authoring.advance.allow.students.right.answers = Indicate choice(s) that have been answered correctly. label.authoring.advance.allow.students.wrong.answers = Indicate choice(s) that have been answered incorrectly. Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -rdb5bb77b5d15931da025332510f19535146c4333 -r550273f1b39b2bd221b2cbf2c858fa93888eabe4 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision db5bb77b5d15931da025332510f19535146c4333) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 550273f1b39b2bd221b2cbf2c858fa93888eabe4) @@ -2167,11 +2167,24 @@ if (sessionDtos != null && assessment.getQuestionReferences() != null) { // if there are multiple session, then the activity has to be grouped boolean isActivityGrouped = sessionDtos.size() > 1; + int questionLeftPadding = isActivityGrouped ? 3 : 2; + List sections = + assessment.getQuestionsPerPage() == -1 ? new ArrayList<>(assessment.getSections()) : null; + ExcelRow sectionRow = null; + if (sections != null) { + sectionRow = userSummarySheet.initRow(); + sectionRow.addEmptyCells(questionLeftPadding); + sectionRow.addCell(getMessage("label.authoring.advance.sections"), false, + ExcelCell.BORDER_STYLE_LEFT_THIN); + sectionRow = userSummarySheet.initRow(); + sectionRow.addEmptyCells(questionLeftPadding); + } + // Row with just "Questions" header ExcelRow userSummaryTitle = userSummarySheet.initRow(); // if there is no grouping, then we skip "Group" column - int questionLeftPadding = isActivityGrouped ? 3 : 2; + userSummaryTitle.addEmptyCells(questionLeftPadding); userSummaryTitle.addCell(getMessage("label.export.questions"), true, ExcelCell.BORDER_STYLE_LEFT_THIN); @@ -2183,8 +2196,37 @@ questionReferences.addAll(assessment.getQuestionReferences()); int questionCounter = 1; + int sectionCounter = 0; + AssessmentSection currentSection = sections == null ? null : sections.get(sectionCounter); + int sectionQuestionCounter = 0; + Set sectionBreaks = new HashSet<>(); + // print out all question titles for (QuestionReference questionReference : questionReferences) { + if (sections != null) { + int currentSectionQuestionCount = currentSection.getQuestionCount(); + if (currentSection != null && currentSectionQuestionCount != 0 + && questionCounter - sectionQuestionCounter > currentSectionQuestionCount) { + sectionBreaks.add(questionCounter - 1); + + sectionRow.addEmptyCell(); + questionTitlesRow.addEmptyCell(); + questionLeftPadding++; + + sectionQuestionCounter += currentSectionQuestionCount; + sectionCounter++; + currentSection = sectionCounter < sections.size() ? sections.get(sectionCounter) : null; + } + if (currentSection != null) { + String sectionName = currentSection.getName(); + if (StringUtils.isBlank(sectionName)) { + sectionName = getMessage("label.learning.section.default.name", + new Object[] { sectionCounter + 1 }); + } + sectionRow.addCell(sectionName, false, ExcelCell.BORDER_STYLE_LEFT_THIN); + } + } + AssessmentQuestion question = questionReference.getQuestion(); String title = question.getQbQuestion().getName(); // leave pure text of title @@ -2214,7 +2256,13 @@ columnShift++; } questionTitlesRow.addEmptyCells(columnShift); + if (sections != null) { + sectionRow.addEmptyCells(columnShift); + } userSummarySheet.addMergedCells(5, questionLeftPadding, questionLeftPadding + columnShift); + if (sections != null) { + userSummarySheet.addMergedCells(7, questionLeftPadding, questionLeftPadding + columnShift); + } questionLeftPadding += columnShift + 1; } @@ -2228,6 +2276,7 @@ userSummaryUserHeadersRow.addCell(getMessage("label.export.user.id"), true); userSummaryUserHeadersRow.addCell(getMessage("label.monitoring.user.summary.full.name"), true); + questionCounter = 1; for (QuestionReference questionReference : questionReferences) { userSummaryUserHeadersRow.addCell(getMessage("label.export.mark"), ExcelCell.BORDER_STYLE_LEFT_THIN); userSummaryUserHeadersRow.addCell(getMessage("label.authoring.basic.option.answer")); @@ -2246,6 +2295,11 @@ userSummaryUserHeadersRow.addCell(getMessage("label.confidence")); } + if (sections != null && (questionCounter == questionReferences.size() || sectionBreaks.contains( + questionCounter))) { + userSummaryUserHeadersRow.addCell(getMessage("label.export.section.mark"), true); + } + questionCounter++; } // a single column at the end of previous headers @@ -2285,12 +2339,15 @@ Map learnerInteractions = learnerInteractionService.getFirstLearnerInteractions( assessment.getContentId(), assessmentUser.getUserId().intValue()); + questionCounter = 1; + float sectionMark = 0; // follow question reference ordering, to QbToolQuestion's for (QuestionReference questionReference : questionReferences) { AssessmentQuestionResult questionResult = questionResultsMap.get( questionReference.getQuestion().getUid()); // mark userResultRow.addCell(questionResult.getMark(), ExcelCell.BORDER_STYLE_LEFT_THIN); + sectionMark += questionResult.getMark(); // option chosen or full answer AssessmentExcelCell assessmentCell = AssessmentEscapeUtils.addResponseCellForExcelExport( @@ -2343,6 +2400,12 @@ userResultRow.addCell(confidenceLevel); } + if (sections != null && (questionCounter == questionReferences.size() || sectionBreaks.contains( + questionCounter))) { + userResultRow.addCell(sectionMark); + sectionMark = 0; + } + questionCounter++; } userResultRow.addCell(assessmentResult.getGrade(), ExcelCell.BORDER_STYLE_LEFT_THIN); }