Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java =================================================================== diff -u -rfc1a904cdec5fa044954ace5778c84a9a7db35a8 -r10eba877611a9296e5959e3145b626771a844593 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java (.../LearningController.java) (revision fc1a904cdec5fa044954ace5778c84a9a7db35a8) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/controller/LearningController.java (.../LearningController.java) (revision 10eba877611a9296e5959e3145b626771a844593) @@ -1145,6 +1145,19 @@ request.setAttribute("sessions", sessionList); Map questionSummaries = service.getQuestionSummaryForExport(assessment); + + // filter out empty results, when a group has not provided any answers + for (QuestionSummary questionSummary : questionSummaries.values()) { + Iterator> questionResultsIterator = questionSummary + .getQuestionResultsPerSession().iterator(); + while (questionResultsIterator.hasNext()) { + List questionResults = questionResultsIterator.next(); + if (questionResults == null || questionResults.isEmpty() + || questionResults.get(questionResults.size() - 1).getUid() == null) { + questionResultsIterator.remove(); + } + } + } request.setAttribute("questionSummaries", questionSummaries); // Assessment currently supports only one place for ratings. @@ -1173,7 +1186,6 @@ // 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().flatMap(s -> s.getQuestionResultsPerSession().stream()) - .filter(l -> l != null && !l.isEmpty()) .collect(Collectors.mapping(l -> l.get(l.size() - 1).getUid(), Collectors.toSet())); List itemRatingDtos = ratingService.getRatingCriteriaDtos(assessment.getContentId(), null, @@ -1188,36 +1200,37 @@ : user.getSession().getGroupLeader().getUserId(); } - for (QuestionSummary summary : questionSummaries.values()) { + if (userSessionIndex != null) { + for (QuestionSummary summary : questionSummaries.values()) { - List> questionResultsPerSession = summary.getQuestionResultsPerSession(); - if (questionResultsPerSession != null) { - List questionResults = userSessionIndex == null ? null - : questionResultsPerSession.remove((int) userSessionIndex); - // user or his leader should rate all other groups' answers in order to show ratings left for own group - int expectedRatedItemCount = questionResultsPerSession.size(); + List> questionResultsPerSession = summary.getQuestionResultsPerSession(); + if (questionResultsPerSession != null) { + List questionResults = questionResultsPerSession + .remove((int) userSessionIndex); - Set questionItemIds = questionResultsPerSession.stream() - .collect(Collectors.mapping(l -> l.get(l.size() - 1).getUid(), Collectors.toSet())); + // user or his leader should rate all other groups' answers in order to show ratings left for own group + int expectedRatedItemCount = questionResults.size(); - if (questionResults != null) { + Set questionItemIds = questionResultsPerSession.stream() + .collect(Collectors.mapping(l -> l.get(l.size() - 1).getUid(), Collectors.toSet())); + // question results need to be in the same order as sessions, i.e. user group first questionResultsPerSession.add(0, questionResults); - } - // count how many ratings user or his leader left - // maybe exact session ID matching should be used here to make sure - int ratedItemCount = 0; - for (Long questionItemId : questionItemIds) { - ItemRatingDTO itemRatingDTO = itemRatingDtoMap.get(questionItemId); - for (RatingCommentDTO ratingCommentDTO : itemRatingDTO.getCommentDtos()) { - if (ratingCommentDTO.getUserId().equals(ratingUserId)) { - ratedItemCount++; + // count how many ratings user or his leader left + // maybe exact session ID matching should be used here to make sure + int ratedItemCount = 0; + for (Long questionItemId : questionItemIds) { + ItemRatingDTO itemRatingDTO = itemRatingDtoMap.get(questionItemId); + for (RatingCommentDTO ratingCommentDTO : itemRatingDTO.getCommentDtos()) { + if (ratingCommentDTO.getUserId().equals(ratingUserId)) { + ratedItemCount++; + } } } - } - summary.setShowOwnGroupRating(ratedItemCount == expectedRatedItemCount); + summary.setShowOwnGroupRating(ratedItemCount == expectedRatedItemCount); + } } } Index: lams_tool_assessment/web/pages/learning/results/essay.jsp =================================================================== diff -u -r602971735e310c64d603bab37031bcffbd12abca -r10eba877611a9296e5959e3145b626771a844593 --- lams_tool_assessment/web/pages/learning/results/essay.jsp (.../essay.jsp) (revision 602971735e310c64d603bab37031bcffbd12abca) +++ lams_tool_assessment/web/pages/learning/results/essay.jsp (.../essay.jsp) (revision 10eba877611a9296e5959e3145b626771a844593) @@ -34,6 +34,7 @@ <%-- Reset variable value --%> + <%-- Get the needed piece of information from a complicated questionSummaries structure --%> @@ -49,7 +50,7 @@ <%-- Show answers for all other teams, and just rating if someone has already commented on this team's answer --%> - +