Source:
public String getQuestionResultStatisticsCsv( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) { if (responses.isEmpty()) { return ""; } Map<String, Integer> answerFrequency = new LinkedHashMap<String, Integer>(); boolean isContainsNonEmptyResponse = false; for (String option : msqChoices) { answerFrequency.put(option, 0); } if (otherEnabled) { answerFrequency.put("Other", 0); } int numChoicesSelected = 0; for (FeedbackResponseAttributes response : responses) { List<String> answerStrings = ((FeedbackMsqResponseDetails) response.getResponseDetails()).getAnswerStrings(); boolean isOtherOptionAnswer = ((FeedbackMsqResponseDetails) (response.getResponseDetails())).isOtherOptionAnswer(); String otherAnswer = ""; if (isOtherOptionAnswer) { if (!answerFrequency.containsKey("Other")) { answerFrequency.put("Other", 0); } answerFrequency.put("Other", answerFrequency.get("Other") + 1); numChoicesSelected++; otherAnswer = answerStrings.get(answerStrings.size() - 1); answerStrings.remove(otherAnswer); } for (String answerString : answerStrings) { if (answerString.isEmpty()) { continue; } isContainsNonEmptyResponse = true; numChoicesSelected++; if (!answerFrequency.containsKey(answerString)) { answerFrequency.put(answerString, 0); } answerFrequency.put(answerString, answerFrequency.get(answerString) + 1); } if (isOtherOptionAnswer) { answerStrings.add(otherAnswer); } } if (!isContainsNonEmptyResponse) { return ""; } DecimalFormat df = new DecimalFormat("#.##"); StringBuilder fragments = new StringBuilder(); for (Entry<String, Integer> entry : answerFrequency.entrySet()) { fragments.append(Sanitizer.sanitizeForCsv(entry.getKey()) + ',' + entry.getValue().toString() + ',' + df.format(100 * (double) entry.getValue() / numChoicesSelected) + Const.EOL); } return "Choice, Response Count, Percentage" + Const.EOL + fragments + Const.EOL; }

Target:
public String getQuestionResultStatisticsCsv( List<FeedbackResponseAttributes> responses, FeedbackQuestionAttributes question, FeedbackSessionResultsBundle bundle) { if (responses.isEmpty()) { return ""; } Map<String, Integer> answerFrequency = new LinkedHashMap<String, Integer>(); boolean isContainsNonEmptyResponse = false; for (String option : msqChoices) { answerFrequency.put(option, 0); } if (otherEnabled) { answerFrequency.put("Other", 0); } int numChoicesSelected = 0; for (FeedbackResponseAttributes response : responses) { List<String> answerStrings = ((FeedbackMsqResponseDetails) response.getResponseDetails()).getAnswerStrings(); boolean isOtherOptionAnswer = ((FeedbackMsqResponseDetails) response.getResponseDetails()).isOtherOptionAnswer(); String otherAnswer = ""; if (isOtherOptionAnswer) { if (!answerFrequency.containsKey("Other")) { answerFrequency.put("Other", 0); } answerFrequency.put("Other", answerFrequency.get("Other") + 1); numChoicesSelected++; otherAnswer = answerStrings.get(answerStrings.size() - 1); answerStrings.remove(otherAnswer); } for (String answerString : answerStrings) { if (answerString.isEmpty()) { continue; } isContainsNonEmptyResponse = true; numChoicesSelected++; if (!answerFrequency.containsKey(answerString)) { answerFrequency.put(answerString, 0); } answerFrequency.put(answerString, answerFrequency.get(answerString) + 1); } if (isOtherOptionAnswer) { answerStrings.add(otherAnswer); } } if (!isContainsNonEmptyResponse) { return ""; } DecimalFormat df = new DecimalFormat("#.##"); StringBuilder fragments = new StringBuilder(); for (Entry<String, Integer> entry : answerFrequency.entrySet()) { fragments.append(Sanitizer.sanitizeForCsv(entry.getKey()) + ',' + entry.getValue().toString() + ',' + df.format(100 * (double) entry.getValue() / numChoicesSelected) + Const.EOL); } return "Choice, Response Count, Percentage" + Const.EOL + fragments + Const.EOL; }