Index: lams_gradebook/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r668f1ed8de162a63b6d97ed22b86fa6e1bdd8cb1 -r4a0fbb2ddb1262c8a0bb6257ad76aa4e0d7222b8 --- lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 668f1ed8de162a63b6d97ed22b86fa6e1bdd8cb1) +++ lams_gradebook/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4a0fbb2ddb1262c8a0bb6257ad76aa4e0d7222b8) @@ -37,6 +37,7 @@ gradebook.columntitle.learnerName =Name gradebook.columntitle.attempt =Attempt # gradebook.columntitle.lesson.mark =Lesson mark +gradebook.columntitle.attempts =Previous attempts gradebook.function.window.showColumns =Show/Hide columns gradebook.function.error.enterNumber =Please enter a number value gradebook.function.search.title =Search grid Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== diff -u -r668f1ed8de162a63b6d97ed22b86fa6e1bdd8cb1 -r4a0fbb2ddb1262c8a0bb6257ad76aa4e0d7222b8 --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 668f1ed8de162a63b6d97ed22b86fa6e1bdd8cb1) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 4a0fbb2ddb1262c8a0bb6257ad76aa4e0d7222b8) @@ -1019,7 +1019,6 @@ public LinkedHashMap exportLessonGradebook(Lesson lesson) { boolean isWeighted = toolService.isWeightedMarks(lesson.getLearningDesign()); - ; LinkedHashMap dataToExport = new LinkedHashMap(); @@ -1239,6 +1238,8 @@ titleRow[4] = new ExcelCell(getMessage("gradebook.columntitle.mark"), true); rowList.add(titleRow); + Map activityIdToName = new HashMap(); + for (ToolActivity activity : activityToUserDTOMap.keySet()) { //find userDto corresponding to the user @@ -1265,6 +1266,7 @@ String activityRowName = (groupName != null && groupId != null) ? activity.getTitle() + " (" + groupName + ")" : activity.getTitle(); + activityIdToName.put(activity.getActivityId(), activityRowName); String startDate = (userDto.getStartDate() == null) ? "" : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(userDto.getStartDate()); @@ -1281,6 +1283,68 @@ } } + // check if learner has restarted the lesson and has archived marks + boolean hasArchivedMarks = gradebookDAO.hasArchivedMarks(lesson.getLessonId(), learner.getUserId()); + if (hasArchivedMarks) { + // "Previous attempts" row + ExcelCell[] attemptsRow = new ExcelCell[1]; + attemptsRow[0] = new ExcelCell(getMessage("gradebook.columntitle.attempts"), true); + rowList.add(attemptsRow); + + List lessonArchives = gradebookDAO + .getArchivedLessonMarks(lesson.getLessonId(), learner.getUserId()); + int attemptOrder = lessonArchives.size(); + // go through each lesson attempt + for (GradebookUserLessonArchive lessonArchive : lessonArchives) { + // lesson attempt header + ExcelCell[] attemptRow = new ExcelCell[4]; + attemptRow[0] = new ExcelCell(getMessage("gradebook.columntitle.attempt"), true); + attemptRow[1] = new ExcelCell(attemptOrder, true); + attemptRow[1].setAlignment(ExcelCell.ALIGN_LEFT); + attemptRow[2] = new ExcelCell(getMessage("gradebook.columntitle.lesson.mark"), true); + attemptRow[3] = new ExcelCell(lessonArchive.getMark(), false); + rowList.add(attemptRow); + + // go throuch each activity and see if there is an archived mark for it + for (ToolActivity activity : activityToUserDTOMap.keySet()) { + ExcelCell[] activityDataRow = null; + List activityArchives = gradebookDAO + .getArchivedActivityMarks(activity.getActivityId(), learner.getUserId()); + Date archiveDate = lessonArchive.getArchiveDate(); + for (GradebookUserActivityArchive activityArchive : activityArchives) { + // if it matches, we found an archived mark for this activity and this attempt + if (archiveDate.equals(activityArchive.getArchiveDate())) { + LearnerProgressArchive learnerProgress = learnerProgressDAO.getLearnerProgressArchive( + lesson.getLessonId(), learner.getUserId(), lessonArchive.getArchiveDate()); + activityDataRow = new ExcelCell[5]; + activityDataRow[0] = new ExcelCell(activityIdToName.get(activity.getActivityId()), + false); + Date startDate = getActivityStartDate(learnerProgress, activity, null); + activityDataRow[1] = new ExcelCell( + startDate == null ? "" + : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(startDate), + false); + Date finishDate = getActivityFinishDate(learnerProgress, activity, null); + activityDataRow[2] = new ExcelCell( + finishDate == null ? "" + : FileUtil.EXPORT_TO_SPREADSHEET_TITLE_DATE_FORMAT.format(finishDate), + false); + activityDataRow[3] = new ExcelCell( + getActivityDuration(learnerProgress, activity) / 1000, false); + activityDataRow[4] = new ExcelCell(activityArchive.getMark(), false); + break; + } + } + if (activityDataRow == null) { + activityDataRow = new ExcelCell[1]; + activityDataRow[0] = new ExcelCell(activityIdToName.get(activity.getActivityId()), false); + } + rowList.add(activityDataRow); + } + attemptOrder--; + } + } + rowList.add(GradebookService.EMPTY_ROW); }