Source:
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(); Map<String, Integer> answerFrequency = new LinkedHashMap<String, Integer>(); for (String option : mcqChoices) { answerFrequency.put(option, 0); } if (otherEnabled) { answerFrequency.put("Other", 0); } for (FeedbackResponseAttributes response : responses) { String answerString = response.getResponseDetails().getAnswerString(); Boolean isOtherOptionAnswer = ((FeedbackMcqResponseDetails) (response.getResponseDetails())).isOtherOptionAnswer(); if (isOtherOptionAnswer) { if (!answerFrequency.containsKey("Other")) { answerFrequency.put("Other", 0); } answerFrequency.put("Other", answerFrequency.get("Other") + 1); } else { if (!answerFrequency.containsKey(answerString)) { answerFrequency.put(answerString, 0); } answerFrequency.put(answerString, answerFrequency.get(answerString) + 1); } } DecimalFormat df = new DecimalFormat("#.##"); for (Entry<String, Integer> entry : answerFrequency.entrySet()) { fragments.append(Templates.populateTemplate(FormTemplates.MCQ_RESULT_STATS_OPTIONFRAGMENT, Slots.MCQ_CHOICE_VALUE, Sanitizer.sanitizeForHtml(entry.getKey()), "${count}", entry.getValue().toString(), "${percentage}", df.format(100 * (double) entry.getValue() / responses.size()))); } return Templates.populateTemplate(FormTemplates.MCQ_RESULT_STATS, "${fragments}", fragments.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(); Map<String, Integer> answerFrequency = new LinkedHashMap<String, Integer>(); for (String option : mcqChoices) { answerFrequency.put(option, 0); } if (otherEnabled) { answerFrequency.put("Other", 0); } for (FeedbackResponseAttributes response : responses) { String answerString = response.getResponseDetails().getAnswerString(); Boolean isOtherOptionAnswer = ((FeedbackMcqResponseDetails) (response.getResponseDetails())).isOtherOptionAnswer(); if (isOtherOptionAnswer) { if (!answerFrequency.containsKey("Other")) { answerFrequency.put("Other", 0); } answerFrequency.put("Other", answerFrequency.get("Other") + 1); } else { if (!answerFrequency.containsKey(answerString)) { answerFrequency.put(answerString, 0); } answerFrequency.put(answerString, answerFrequency.get(answerString) + 1); } } DecimalFormat df = new DecimalFormat("#.##"); for (Entry<String, Integer> entry : answerFrequency.entrySet()) { fragments.append(Templates.populateTemplate(FormTemplates.MCQ_RESULT_STATS_OPTIONFRAGMENT, Slots.MCQ_CHOICE_VALUE, Sanitizer.sanitizeForHtml(entry.getKey()), Slots.COUNT, entry.getValue().toString(), Slots.PERCENTAGE, df.format(100 * (double) entry.getValue() / responses.size()))); } return Templates.populateTemplate(FormTemplates.MCQ_RESULT_STATS, Slots.FRAGMENTS, fragments.toString()); }