Source:
public String getQuestionResultStatisticsCsv( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) { if (responses.isEmpty()) { return ""; } StringBuilder fragments = new StringBuilder(); List<String> options = constSumOptions; Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses); DecimalFormat df = new DecimalFormat("#.##"); Map<String, List<Integer>> sortedOptionPoints = new TreeMap<String, List<Integer>>(); Map<String, String> identifierMap = new HashMap<String, String>(); for (Entry<String, List<Integer>> entry : optionPoints.entrySet()) { if (distributeToRecipients) { String participantIdentifier = entry.getKey(); String name = bundle.getNameForEmail(participantIdentifier); String nameEmail = name + participantIdentifier; identifierMap.put(nameEmail, participantIdentifier); sortedOptionPoints.put(nameEmail, entry.getValue()); } else { String option = options.get(Integer.parseInt(entry.getKey())); identifierMap.put(option, entry.getKey()); sortedOptionPoints.put(option, entry.getValue()); } } for (Entry<String, List<Integer>> entry : sortedOptionPoints.entrySet()) { String option; if (distributeToRecipients) { String teamName = bundle.getTeamNameForEmail(identifierMap.get(entry.getKey())); String recipientName = bundle.getNameForEmail(identifierMap.get(entry.getKey())); option = Sanitizer.sanitizeForCsv(teamName) + "," + Sanitizer.sanitizeForCsv(recipientName); } else { option = Sanitizer.sanitizeForCsv(entry.getKey()); } List<Integer> points = entry.getValue(); double average = computeAverage(points); fragments.append(option).append(',').append(df.format(average)).append(Const.EOL); } return (distributeToRecipients ? "Team, Recipient" : "Option") + ", Average Points" + Const.EOL + fragments + Const.EOL; }

Target:
public String getQuestionResultStatisticsCsv( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) { if (responses.isEmpty()) { return ""; } StringBuilder fragments = new StringBuilder(); List<String> options = constSumOptions; Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses); DecimalFormat df = new DecimalFormat("#.##"); Map<String, List<Integer>> sortedOptionPoints = new TreeMap<String, List<Integer>>(); Map<String, String> identifierMap = new HashMap<String, String>(); if (distributeToRecipients) { putRecipientsInSortedMap(optionPoints, identifierMap, sortedOptionPoints, bundle); } else { putOptionsInSortedMap(optionPoints, options, sortedOptionPoints); } for (Entry<String, List<Integer>> entry : sortedOptionPoints.entrySet()) { String option; if (distributeToRecipients) { String participantIdentifier = identifierMap.get(entry.getKey()); String teamName = bundle.getTeamNameForEmail(participantIdentifier); String recipientName = bundle.getNameForEmail(participantIdentifier); option = Sanitizer.sanitizeForCsv(teamName) + "," + Sanitizer.sanitizeForCsv(recipientName); } else { option = Sanitizer.sanitizeForCsv(entry.getKey()); } List<Integer> points = entry.getValue(); double average = computeAverage(points); fragments.append(option).append(',').append(df.format(average)).append(Const.EOL); } return (distributeToRecipients ? "Team, Recipient" : "Option") + ", Average Points" + Const.EOL + fragments + Const.EOL; }