Source:
public String getQuestionResultStatisticsHtml( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle, String view) { if (view.equals("student") || responses.size() == 0) { return ""; } StringBuilder html = new StringBuilder(); StringBuilder fragments = new StringBuilder(); List<String> options = constSumOptions; Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses); DecimalFormat df = new DecimalFormat("#.##"); for (Entry<String, List<Integer>> entry : optionPoints.entrySet()) { List<Integer> points = entry.getValue(); double average = computeAverage(points); String pointsReceived = getListOfPointsAsString(points); if (distributeToRecipients) { String participantIdentifier = entry.getKey(); String name = bundle.getNameForEmail(participantIdentifier); String teamName = bundle.getTeamNameForEmail(participantIdentifier); fragments.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_STATS_RECIPIENTFRAGMENT, "${constSumOptionValue}", Sanitizer.sanitizeForHtml(name), "${team}", Sanitizer.sanitizeForHtml(teamName), "${pointsReceived}", pointsReceived, "${averagePoints}", df.format(average))); } else { String option = options.get(Integer.parseInt(entry.getKey())); fragments.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_STATS_OPTIONFRAGMENT, "${constSumOptionValue}", Sanitizer.sanitizeForHtml(option), "${pointsReceived}", pointsReceived, "${averagePoints}", df.format(average))); } } if (distributeToRecipients) { html.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_RECIPIENT_STATS, "${optionRecipientDisplayName}", "Recipient", "${fragments}", fragments.toString())); } else { html.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_OPTION_STATS, "${optionRecipientDisplayName}", "Option", "${fragments}", fragments.toString())); } return html.toString(); }

Target:
public String getQuestionResultStatisticsHtml( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle, String view) { if ("student".equals(view) || responses.isEmpty()) { return ""; } StringBuilder fragments = new StringBuilder(); List<String> options = constSumOptions; Map<String, List<Integer>> optionPoints = generateOptionPointsMapping(responses); DecimalFormat df = new DecimalFormat("#.##"); for (Entry<String, List<Integer>> entry : optionPoints.entrySet()) { List<Integer> points = entry.getValue(); double average = computeAverage(points); String pointsReceived = getListOfPointsAsString(points); if (distributeToRecipients) { String participantIdentifier = entry.getKey(); String name = bundle.getNameForEmail(participantIdentifier); String teamName = bundle.getTeamNameForEmail(participantIdentifier); fragments.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_STATS_RECIPIENTFRAGMENT, "${constSumOptionValue}", Sanitizer.sanitizeForHtml(name), "${team}", Sanitizer.sanitizeForHtml(teamName), "${pointsReceived}", pointsReceived, "${averagePoints}", df.format(average))); } else { String option = options.get(Integer.parseInt(entry.getKey())); fragments.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_STATS_OPTIONFRAGMENT, "${constSumOptionValue}", Sanitizer.sanitizeForHtml(option), "${pointsReceived}", pointsReceived, "${averagePoints}", df.format(average))); } } if (distributeToRecipients) { return FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_RECIPIENT_STATS, "${optionRecipientDisplayName}", "Recipient", "${fragments}", fragments.toString()); } else { return FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.CONSTSUM_RESULT_OPTION_STATS, "${optionRecipientDisplayName}", "Option", "${fragments}", fragments.toString()); } }