Source:
public String getQuestionResultStatisticsHtml(List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, String studentEmail, FeedbackSessionResultsBundle bundle, String view) { if (view.equals("student")) { return ""; } if (responses.size() == 0) { return ""; } String html = ""; 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", 1); } else { answerFrequency.put("Other", answerFrequency.get("Other") + 1); } } else { if (!answerFrequency.containsKey(answerString)) { answerFrequency.put(answerString, 1); } else { answerFrequency.put(answerString, answerFrequency.get(answerString) + 1); } } } DecimalFormat df = new DecimalFormat("#.##"); for (Entry<String, Integer> entry : answerFrequency.entrySet()) { fragments.append(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.MCQ_RESULT_STATS_OPTIONFRAGMENT, "${mcqChoiceValue}", Sanitizer.sanitizeForHtml(entry.getKey()), "${count}", entry.getValue().toString(), "${percentage}", df.format(100 * (double) entry.getValue() / responses.size()))); } html = FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.MCQ_RESULT_STATS, "${fragments}", fragments.toString()); return html; }

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(FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.MCQ_RESULT_STATS_OPTIONFRAGMENT, "${mcqChoiceValue}", Sanitizer.sanitizeForHtml(entry.getKey()), "${count}", entry.getValue().toString(), "${percentage}", df.format(100 * (double) entry.getValue() / responses.size()))); } return FeedbackQuestionFormTemplates.populateTemplate(FeedbackQuestionFormTemplates.MCQ_RESULT_STATS, "${fragments}", fragments.toString()); }