Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml =================================================================== diff -u -r501ddb69e1c739b90388262f41b4927356cb0449 -r138a8368bb147b0fb478c02a5a9f4a6fb326b51b --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (.../QaUsrResp.hbm.xml) (revision 501ddb69e1c739b90388262f41b4927356cb0449) +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaUsrResp.hbm.xml (.../QaUsrResp.hbm.xml) (revision 138a8368bb147b0fb478c02a5a9f4a6fb326b51b) @@ -26,6 +26,14 @@ + + + mapAnswers = (Map) sessionMap.get(MAP_ALL_RESULTS_KEY); + Map mapAnswers = (Map) sessionMap.get(MAP_ALL_RESULTS_KEY); if (mapAnswers == null) { mapAnswers = new TreeMap(new QaComparator()); @@ -111,7 +111,15 @@ for (QaQueContent question : qaContent.getQaQueContents()) { Long questionUid = question.getUid(); QaUsrResp response = qaService.getResponseByUserAndQuestion(user.getQueUsrId(), questionUid); - String answer = (response == null) ? null : response.getAnswer(); + + String answer; + if (response == null) { + answer = null; + } else if (!user.isResponseFinalized() && response.getAnswerAutosaved() != null) { + answer = response.getAnswerAutosaved(); + } else { + answer = response.getAnswer(); + } mapAnswersFromDb.put(String.valueOf(question.getDisplayOrder()), answer); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== diff -u -r596674554dfa059875f580b481de92dfce9e1828 -r138a8368bb147b0fb478c02a5a9f4a6fb326b51b --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 596674554dfa059875f580b481de92dfce9e1828) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 138a8368bb147b0fb478c02a5a9f4a6fb326b51b) @@ -164,7 +164,7 @@ // store if (errors.isEmpty()) { QaLearningAction.qaService.updateResponseWithNewAnswer(answer, toolSessionID, new Long( - questionIndex)); + questionIndex), false); } } @@ -267,7 +267,7 @@ for (int questionIndex = QaAppConstants.INITIAL_QUESTION_COUNT.intValue(); questionIndex <= intTotalQuestionCount; questionIndex++) { String newAnswer = request.getParameter("answer" + questionIndex); QaLearningAction.qaService.updateResponseWithNewAnswer(newAnswer, toolSessionID, - new Long(questionIndex)); + new Long(questionIndex), true); } } else { @@ -279,7 +279,7 @@ boolean isRequiredQuestionMissed = currentQuestion.isRequired() && isEmpty(newAnswer); if (!isRequiredQuestionMissed) { QaLearningAction.qaService.updateResponseWithNewAnswer(newAnswer, toolSessionID, new Long( - currentQuestionIndex)); + currentQuestionIndex), true); } } return null; @@ -326,15 +326,15 @@ generalLearnerFlowDTO.setRemainingQuestionCount(new Integer(mapQuestions.size()).toString()); qaLearningForm.setTotalQuestionCount(new Integer(mapQuestions.size()).toString()); - // populate answers + //in order to track whether redo button is pressed store this info QaQueUsr qaQueUsr = getCurrentUser(toolSessionID); + qaQueUsr.setResponseFinalized(false); + QaLearningAction.qaService.updateUser(qaQueUsr); + + // populate answers LearningUtil.populateAnswers(sessionMap, qaContent, qaQueUsr, mapQuestions, generalLearnerFlowDTO, QaLearningAction.qaService); - //in order to track whether redo button is pressed store this info - qaQueUsr.setResponseFinalized(false); - QaLearningAction.qaService.updateUser(qaQueUsr); - request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); qaLearningForm.resetAll(); return (mapping.findForward(QaAppConstants.LOAD_LEARNER)); @@ -577,11 +577,11 @@ Map mapAnswers = (Map) sessionMap.get(QaAppConstants.MAP_ALL_RESULTS_KEY); if (mapAnswers == null) { - mapAnswers = new TreeMap(new QaComparator()); + mapAnswers = new TreeMap(new QaComparator()); } String newAnswer = qaLearningForm.getAnswer(); - Map mapSequentialAnswers = (Map) sessionMap.get(QaAppConstants.MAP_SEQUENTIAL_ANSWERS_KEY); + Map mapSequentialAnswers = (Map) sessionMap.get(QaAppConstants.MAP_SEQUENTIAL_ANSWERS_KEY); if (mapSequentialAnswers.size() >= new Integer(currentQuestionIndex).intValue()) { mapSequentialAnswers.remove(new Long(currentQuestionIndex).toString()); } @@ -599,18 +599,12 @@ // store if (errors.isEmpty()) { QaLearningAction.qaService.updateResponseWithNewAnswer(newAnswer, qaLearningForm.getToolSessionID(), - new Long(currentQuestionIndex)); + new Long(currentQuestionIndex), false); } else { saveErrors(request, errors); nextQuestionOffset = 0; } - sessionMap.put(QaAppConstants.MAP_ALL_RESULTS_KEY, mapAnswers); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); - generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); - request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - int intCurrentQuestionIndex = new Integer(currentQuestionIndex).intValue() + nextQuestionOffset; String currentAnswer = ""; if (mapAnswers.size() >= intCurrentQuestionIndex) { @@ -631,11 +625,11 @@ userFeedback = "End of the questions."; } generalLearnerFlowDTO.setUserFeedback(userFeedback); - generalLearnerFlowDTO.setRemainingQuestionCount("" + remainingQuestionCount); qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */ + sessionMap.put(QaAppConstants.MAP_ALL_RESULTS_KEY, mapAnswers); sessionMap.put(QaAppConstants.MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); qaLearningForm.setHttpSessionID(sessionMap.getSessionID());