Index: lams_tool_preview/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -ra798c78f93d73291229a97c9e750619e7f28f036 -r0c9629a1f72086f6b042733e881fdf05f38494e9 --- lams_tool_preview/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision a798c78f93d73291229a97c9e750619e7f28f036) +++ lams_tool_preview/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 0c9629a1f72086f6b042733e881fdf05f38494e9) @@ -195,6 +195,7 @@ outcome.authoring.remove.confirm =Are you sure you want to remove this learning outcome? outcome.authoring.create.new =[create new] label.sapa.factor =SAPA factor +label.sa = SA +label.pa = PA - #======= End labels: Exported 189 labels for en AU ===== Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java =================================================================== diff -u -r4c502519e6f13a1a76792fde1bfcf11df23facb4 -r0c9629a1f72086f6b042733e881fdf05f38494e9 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java (.../SpreadsheetBuilder.java) (revision 4c502519e6f13a1a76792fde1bfcf11df23facb4) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/util/SpreadsheetBuilder.java (.../SpreadsheetBuilder.java) (revision 0c9629a1f72086f6b042733e881fdf05f38494e9) @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; @@ -87,6 +88,10 @@ } } titleRow.addCell(service.getLocalisedMessage("label.average", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + if (peerreview.isSelfReview()) { + titleRow.addCell(service.getLocalisedMessage("label.sa", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); + } + titleRow.addCell(service.getLocalisedMessage("label.pa", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); titleRow.addCell(service.getLocalisedMessage("label.spa.factor", null), true, ExcelCell.BORDER_STYLE_BOTTOM_THIN); if (peerreview.isSelfReview()) { @@ -168,17 +173,12 @@ : 0D; avgRow.addCell(finalGroupAverage, true); - Map> ratings = null; - if (peerreview.isSelfReview()) { - // prepare for SAPA calculation - // the map is: itemId (who was rated) -> userId (who rated) -> sum of ratings from all categories - ratings = ((List) ratingService.getRatingsByCriteriasAndItems(criteriaIndexMap.keySet(), - userNames.keySet())) - .stream().filter(rating -> rating.getRating() != null) - .collect(Collectors.groupingBy(Rating::getItemId, - Collectors.groupingBy(rating -> rating.getLearner().getUserId().longValue(), - Collectors.summingDouble(Rating::getRating)))); - } + // the map is: itemId (who was rated) -> userId (who rated) -> rating from all categories + Map>> ratings = ((List) ratingService + .getRatingsByCriteriasAndItems(criteriaIndexMap.keySet(), userNames.keySet())).stream() + .filter(rating -> rating.getRating() != null) + .collect(Collectors.groupingBy(Rating::getItemId, Collectors.groupingBy( + rating -> rating.getLearner().getUserId().longValue(), Collectors.toSet()))); // Combine rated rows with rows with users not yet rated, to make up complete list, and write out to rowList. for (PeerreviewUser user : users) { @@ -190,33 +190,53 @@ } else { Double learnerAverage = (Double) userRow.getCell(userRow.getCells().size() - 1); Double spa = countNonCommentCriteria > 0 ? roundTo2Places(learnerAverage / finalGroupAverage) : 0D; - userRow.addCell(spa, true); + Double sa = null; + Double pa = null; + Double sapa = null; - if (peerreview.isSelfReview()) { - if (ratings.containsKey(user.getUserId())) { - // calculate SAPA factor - double sumSelfRatings = 0; - double sumPeerRatings = 0; - int peerRatingCount = 0; + if (ratings.containsKey(user.getUserId())) { + // calculate SAPA factor + double sumSelfRatings = 0; + double sumPeerRatings = 0; + int selfRatingCriteriaCount = 0; + int peerRatingCriteriaCount = 0; + int peerRatingCount = 0; - for (Entry ratingEntry : ratings.get(user.getUserId()).entrySet()) { - if (ratingEntry.getKey().equals(user.getUserId())) { - sumSelfRatings = ratingEntry.getValue(); - } else { - sumPeerRatings += ratingEntry.getValue(); - peerRatingCount++; - } + for (Entry> ratingEntry : ratings.get(user.getUserId()).entrySet()) { + double sumRatingFromAllCategories = ratingEntry.getValue().stream() + .collect(Collectors.summingDouble(Rating::getRating)); + int countRatingFromAllCategories = ratingEntry.getValue().size(); + if (ratingEntry.getKey().equals(user.getUserId())) { + sumSelfRatings = sumRatingFromAllCategories; + selfRatingCriteriaCount = countRatingFromAllCategories; + } else { + sumPeerRatings += sumRatingFromAllCategories; + peerRatingCriteriaCount += countRatingFromAllCategories; + peerRatingCount++; } + } - double sapa = sumPeerRatings > 0 + pa = peerRatingCriteriaCount == 0 ? null : roundTo2Places(sumPeerRatings / peerRatingCriteriaCount); + if (peerreview.isSelfReview()) { + sa = selfRatingCriteriaCount == 0 ? null + : roundTo2Places(sumSelfRatings / selfRatingCriteriaCount); + sapa = sumPeerRatings > 0 ? roundTo2Places(Math.sqrt(sumSelfRatings / (sumPeerRatings / peerRatingCount))) - : 0d; - userRow.addCell(sapa, true); - } else { - userRow.addCell("", false); + : 0; } } + if (peerreview.isSelfReview()) { + userRow.addCell(sa, true); + } + userRow.addCell(pa, true); + + userRow.addCell(spa, true); + + if (peerreview.isSelfReview()) { + userRow.addCell(sapa, true); + } + userRow.addCell("", IndexedColors.YELLOW); userRow.addCell("", IndexedColors.GREEN);