Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java =================================================================== diff -u -r5e13c8960b7613b39cb531455f6f2f7f5f239ec5 -re8cd25c0973abcdc239863c4314aab7dd1d9777f --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision 5e13c8960b7613b39cb531455f6f2f7f5f239ec5) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision e8cd25c0973abcdc239863c4314aab7dd1d9777f) @@ -550,13 +550,15 @@ private void validateAnswers(HttpServletRequest request, AnswerDTO question, ActionErrors errors, SurveyAnswer answer) { + boolean isAnswerEmpty = (answer.getChoices() == null && StringUtils.isBlank(answer.getAnswerText())); + // for mandatory questions, answer can not be null. - if (!question.isOptional() && answer == null) { + if (!question.isOptional() && isAnswerEmpty) { errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(), new ActionMessage( SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); } if (question.getType() == SurveyConstants.QUESTION_TYPE_SINGLE_CHOICE && question.isAppendText() - && answer != null) { + && !isAnswerEmpty) { // for single choice, user only can choose one option or open text (if it has) if (!StringUtils.isBlank(answer.getAnswerChoices()) && !StringUtils.isBlank(answer.getAnswerText())) { errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(), new ActionMessage( @@ -569,9 +571,6 @@ String[] choiceList = request.getParameterValues(SurveyConstants.PREFIX_QUESTION_CHOICE + question.getUid()); String textEntry = request.getParameter(SurveyConstants.PREFIX_QUESTION_TEXT + question.getUid()); - if (choiceList == null && StringUtils.isBlank(textEntry)) { - return null; - } SurveyAnswer answer = question.getAnswer(); if (answer == null) {