Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java =================================================================== diff -u -ra92e6d07a437f70d76d3927293986933ccce3fbe -rce676682974b313c309212050dfad64cb41e60f6 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java (.../LearningController.java) (revision a92e6d07a437f70d76d3927293986933ccce3fbe) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java (.../LearningController.java) (revision ce676682974b313c309212050dfad64cb41e60f6) @@ -1048,7 +1048,8 @@ List> pagedQuestionDtos = (List>) sessionMap .get(AssessmentConstants.ATTR_PAGED_QUESTION_DTOS); Assessment assessment = (Assessment) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT); - Long userId = ((AssessmentUser) sessionMap.get(AssessmentConstants.ATTR_USER)).getUserId(); + AssessmentUser user = (AssessmentUser) sessionMap.get(AssessmentConstants.ATTR_USER); + Long userId = user.getUserId(); int dbResultCount = service.getAssessmentResultCount(assessment.getUid(), userId); if (dbResultCount > 0) { @@ -1133,11 +1134,40 @@ // such entities should not go into session map, but as request attributes instead SortedSet sessions = new TreeSet<>(new AssessmentSessionComparator()); sessions.addAll(service.getSessionsByContentId(assessment.getContentId())); - request.setAttribute("sessions", sessions); + Long userSessionId = user.getSession().getSessionId(); + Integer userSessionIndex = null; + int sessionIndex = 0; + // find user session in order to put it first + List sessionList = new ArrayList<>(); + for (AssessmentSession session : sessions) { + if (userSessionId.equals(session.getSessionId())) { + userSessionIndex = sessionIndex; + } else { + sessionList.add(session); + } + sessionIndex++; + } + + request.setAttribute("sessions", sessionList); + Map questionSummaries = service.getQuestionSummaryForExport(assessment); request.setAttribute("questionSummaries", questionSummaries); + // question summaries need to be in the same order as sessions, i.e. user group first + if (userSessionIndex != null) { + sessionList.add(0, user.getSession()); + for (QuestionSummary summary : questionSummaries.values()) { + List> questionResultsPerSession = summary + .getQuestionResultsPerSession(); + if (questionResultsPerSession != null) { + List questionResults = questionResultsPerSession + .remove((int) userSessionIndex); + questionResultsPerSession.add(0, questionResults); + } + } + } + // Assessment currently supports only one place for ratings. // It is rating other groups' answers on results page. // Criterion gets automatically created and there must be only one. @@ -1160,7 +1190,7 @@ } else { criterion = (ToolActivityRatingCriteria) criteria.get(0); } - + // Item IDs are AssessmentQuestionResults UIDs, i.e. a user answer for a particular question // Get all item IDs no matter which session they belong to. Set itemIds = questionSummaries.values().stream()