Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java,v diff -u -r1.27 -r1.28 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java 10 Feb 2016 03:41:10 -0000 1.27 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java 10 Feb 2016 12:38:16 -0000 1.28 @@ -217,6 +217,7 @@ //return user list according to the given sessionID ISurveyService service = getSurveyService(); + SurveyQuestion question = service.getQuestion(questionUid); List users = service.getQuestionAnswersForTablesorter(sessionId, questionUid, page, size, sorting, searchString); JSONArray rows = new JSONArray(); @@ -234,7 +235,19 @@ responseRow.put("choices", SurveyWebUtils.getChoiceList((String)userAndAnswers[1])); } if ( userAndAnswers.length > 2 && userAndAnswers[2] != null) { - responseRow.put("answerText", (String)userAndAnswers[2]); // was escaped before storing in database + // Data is handled differently in learner depending on whether it is an extra text added + // to a multiple choice, or a free text entry. So need to handle the output differently. + // See learner/result.jsp and its handling of question.type == 3 vs question.appendText + String answer; + if ( question.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY ) { + // don't escape as it was escaped & BR'd before saving + answer = (String)userAndAnswers[2]; + } else { + // need to escape it, as it isn't escaped in the database + answer = StringEscapeUtils.escapeHtml((String)userAndAnswers[2]); + answer.replaceAll("\n", "
"); + } + responseRow.put("answerText", answer); } rows.put(responseRow); }