Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/GeneralLearnerFlowDTO.java =================================================================== diff -u -r0120babf4ee377217a385ca28e4f6202b4b4dbf6 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 0120babf4ee377217a385ca28e4f6202b4b4dbf6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -49,6 +49,8 @@ protected String toolSessionID; + protected String httpSessionID; + protected String toolContentID; protected Integer currentQuestionIndex; @@ -304,4 +306,17 @@ public void setMapQuestions(Map mapQuestions) { this.mapQuestions = mapQuestions; } + + /** + * @return Returns the httpSessionID. + */ + public String getHttpSessionID() { + return httpSessionID; + } + /** + * @param httpSessionID The httpSessionID to set. + */ + public void setHttpSessionID(String httpSessionID) { + this.httpSessionID = httpSessionID; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -rfef255c381132c29ddbd1f7a7c37106ba90f2b52 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision fef255c381132c29ddbd1f7a7c37106ba90f2b52) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -54,6 +54,7 @@ public static final String COPY_TOOL_CONTENT ="copyToolContent"; public static final String ERROR_LIST ="errorList"; public static final String ERROR_LIST_LEARNER ="errorListLearner"; + public static final String MAP_SEQUENTIAL_ANSWERS_KEY ="mapSequentialAnswersKey"; public static final String DEFAULT_CONTENT_ID_STR ="defaultContentIdStr"; public static final String DEFAULT_ONLINE_INST ="online instructions"; public static final String DEFAULT_OFFLINE_INST ="offline instructions"; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java =================================================================== diff -u -r0120babf4ee377217a385ca28e4f6202b4b4dbf6 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision 0120babf4ee377217a385ca28e4f6202b4b4dbf6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -26,13 +26,16 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.qa.GeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.qa.QaAppConstants; +import org.lamsfoundation.lams.tool.qa.QaComparator; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; @@ -59,9 +62,62 @@ logger.debug("toolSessionID: " + toolSessionID); qaLearningForm.setToolSessionID(toolSessionID); + String httpSessionID=request.getParameter("httpSessionID"); + logger.debug("httpSessionID: " + httpSessionID); + qaLearningForm.setHttpSessionID(httpSessionID); + + String totalQuestionCount=request.getParameter("totalQuestionCount"); + logger.debug("totalQuestionCount: " + totalQuestionCount); + qaLearningForm.setTotalQuestionCount(totalQuestionCount); + + logger.debug("done saving form request data."); } + + public static GeneralLearnerFlowDTO buildGeneralLearnerFlowDTO(QaContent qaContent) + { + logger.debug("starting buildMcGeneralLearnerFlowDTO: " + qaContent); + GeneralLearnerFlowDTO generalLearnerFlowDTO =new GeneralLearnerFlowDTO(); + generalLearnerFlowDTO.setActivityTitle(qaContent.getTitle()); + generalLearnerFlowDTO.setActivityInstructions(qaContent.getInstructions()); + generalLearnerFlowDTO.setReportTitleLearner(qaContent.getReportTitle()); + //generalLearnerFlowDTO.setLearnerProgress(new Boolean(false).toString()); + + if (qaContent.isQuestionsSequenced()) + generalLearnerFlowDTO.setQuestionListingMode(QUESTION_LISTING_MODE_SEQUENTIAL); + else + generalLearnerFlowDTO.setQuestionListingMode(QUESTION_LISTING_MODE_COMBINED); + + + generalLearnerFlowDTO.setActivityOffline(new Boolean(qaContent.isRunOffline()).toString()); + + logger.debug("continue buildGeneralLearnerFlowDTO: " + qaContent); + generalLearnerFlowDTO.setTotalQuestionCount(new Integer(qaContent.getQaQueContents().size())); + logger.debug("final generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + Map mapQuestions= new TreeMap(new QaComparator()); + + Iterator contentIterator=qaContent.getQaQueContents().iterator(); + while (contentIterator.hasNext()) + { + QaQueContent qaQueContent=(QaQueContent)contentIterator.next(); + if (qaQueContent != null) + { + int displayOrder=qaQueContent.getDisplayOrder(); + if (displayOrder != 0) + { + /* + * add the question to the questions Map in the displayOrder + */ + mapQuestions.put(new Integer(displayOrder).toString(),qaQueContent.getQuestion()); + } + } + } + + generalLearnerFlowDTO.setMapQuestionContentLearner(mapQuestions); + return generalLearnerFlowDTO; + } /** * createUsersAndResponses(Map mapAnswers, HttpServletRequest request) @@ -230,9 +286,8 @@ * @param qaLearningForm * return void */ - protected void feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex) + protected String feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex, String totalQuestionCount) { - String totalQuestionCount=(String)request.getSession().getAttribute(TOTAL_QUESTION_COUNT); logger.debug("totalQuestionCount: " + totalQuestionCount); int remainingQuestionCount=new Long(totalQuestionCount).intValue() - currentQuestionIndex +1; logger.debug("remainingQuestionCount: " + remainingQuestionCount); @@ -242,7 +297,8 @@ else userFeedback= "End of the questions."; - request.getSession().setAttribute(USER_FEEDBACK, userFeedback); + //request.getSession().setAttribute(USER_FEEDBACK, userFeedback); + return userFeedback; } public void setContentInUse(long toolContentId, IQaService qaService) Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== diff -u -re4b11d5f2ee68909df09e749152768bd5006aa88 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision e4b11d5f2ee68909df09e749152768bd5006aa88) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -99,6 +99,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.qa.GeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaSession; @@ -108,6 +109,7 @@ import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; public class QaLearningAction extends LamsDispatchAction implements QaAppConstants @@ -179,7 +181,8 @@ else { logger.debug("populating mapAnswers..."); - mapAnswers=populateAnswersMap(mapping, form, request, response); + GeneralLearnerFlowDTO generalLearnerFlowDTO= new GeneralLearnerFlowDTO(); + mapAnswers=populateAnswersMap(qaLearningForm, request, generalLearnerFlowDTO); logger.debug("mapAnswers: " + mapAnswers); } @@ -287,46 +290,105 @@ throws IOException, ServletException, ToolException { logger.debug("dispatching getNextQuestion..."); - populateAnswersMap(mapping, form, request, response); + QaLearningForm qaLearningForm = (QaLearningForm) form; + IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE); + logger.debug("qaService: " + qaService); + + + String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); + logger.debug("toolSessionID: " + toolSessionID); + qaLearningForm.setToolSessionID(toolSessionID); + + QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(toolSessionID).longValue()); + logger.debug("retrieving qaSession: " + qaSession); + + String toolContentID=qaSession.getQaContent().getQaContentId().toString(); + logger.debug("toolContentID: " + toolContentID); + + QaContent qaContent=qaSession.getQaContent(); + logger.debug("using qaContent: " + qaContent); + + GeneralLearnerFlowDTO generalLearnerFlowDTO= LearningUtil.buildGeneralLearnerFlowDTO(qaContent); + logger.debug("generalLearnerFlowDTO: " + generalLearnerFlowDTO); + + + LearningUtil.saveFormRequestData(request, qaLearningForm); + populateAnswersMap(qaLearningForm, request, generalLearnerFlowDTO); + return (mapping.findForward(LOAD_LEARNER)); } - public Map populateAnswersMap(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + public Map populateAnswersMap(ActionForm form, HttpServletRequest request, GeneralLearnerFlowDTO generalLearnerFlowDTO) { - logger.debug("doing populateAnswersMap"); QaLearningForm qaLearningForm = (QaLearningForm) form; - Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS); - logger.debug("MAP_ANSWERS:" + mapAnswers); + //Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS); + //logger.debug("MAP_ANSWERS:" + mapAnswers); - int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue(); - logger.debug("currentQuestionIndex is: " + currentQuestionIndex); + String httpSessionID=qaLearningForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + Map mapSequentialAnswers=(Map)sessionMap.get(MAP_SEQUENTIAL_ANSWERS_KEY); + logger.debug("pre mapSequentialAnswers: " + mapSequentialAnswers); + + String currentQuestionIndex=qaLearningForm.getCurrentQuestionIndex(); + logger.debug("currentQuestionIndex:" + currentQuestionIndex); + + + //int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue(); logger.debug("getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer()); - logger.debug("mapAnswers size:" + mapAnswers.size()); + logger.debug("mapSequentialAnswers size:" + mapSequentialAnswers.size()); - if (mapAnswers.size() >= currentQuestionIndex) + + if (mapSequentialAnswers.size() >= new Integer(currentQuestionIndex).intValue()) { - logger.debug("mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex); - mapAnswers.remove(new Long(currentQuestionIndex).toString()); + logger.debug("mapSequentialAnswers size:" + mapSequentialAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex); + mapSequentialAnswers.remove(new Long(currentQuestionIndex).toString()); } - logger.debug("before adding to mapAnswers: " + mapAnswers); - mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer()); - logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers."); + logger.debug("before adding to mapSequentialAnswers: " + mapSequentialAnswers); + mapSequentialAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer()); + logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapSequentialAnswers."); + + logger.debug("updated mapSequentialAnswers:" + mapSequentialAnswers); - currentQuestionIndex++; + int intCurrentQuestionIndex=new Integer(currentQuestionIndex).intValue(); + logger.debug("intCurrentQuestionIndex:" + intCurrentQuestionIndex); + intCurrentQuestionIndex++; LearningUtil learningUtil= new LearningUtil(); - request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString())); - logger.debug("currentQuestionIndex will be: " + currentQuestionIndex); - request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex)); - learningUtil.feedBackAnswersProgress(request,currentQuestionIndex); + //request.getSession().setAttribute(CURRENT_ANSWER, mapSequentialAnswers.get(new Long(currentQuestionIndex).toString())); + String currentAnswer=(String)mapSequentialAnswers.get(new Long(currentQuestionIndex).toString()); + logger.debug("currentAnswer:" + currentAnswer); + generalLearnerFlowDTO.setCurrentAnswer(currentAnswer); + + logger.debug("currentQuestionIndex will be: " + intCurrentQuestionIndex); + //request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex)); + generalLearnerFlowDTO.setCurrentQuestionIndex(new Integer(intCurrentQuestionIndex)); + + String totalQuestionCount=qaLearningForm.getTotalQuestionCount(); + logger.debug("totalQuestionCount: " + totalQuestionCount); + + String userFeedback=learningUtil.feedBackAnswersProgress(request,intCurrentQuestionIndex,totalQuestionCount); + logger.debug("userFeedback: " + userFeedback); + generalLearnerFlowDTO.setUserFeedback(userFeedback); + qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */ - request.getSession().setAttribute(MAP_ANSWERS, mapAnswers); - logger.debug("final MAP_ANSWERS: " + mapAnswers); - return mapAnswers; + //request.getSession().setAttribute(MAP_ANSWERS, mapSequentialAnswers); + //logger.debug("final MAP_ANSWERS: " + mapSequentialAnswers); + + sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + + request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); + return mapSequentialAnswers; } @@ -373,7 +435,7 @@ request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString())); logger.debug("currentQuestionIndex will be: " + currentQuestionIndex); request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex)); - learningUtil.feedBackAnswersProgress(request,currentQuestionIndex); + //learningUtil.feedBackAnswersProgress(request,currentQuestionIndex); qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */ request.getSession().setAttribute(MAP_ANSWERS, mapAnswers); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java =================================================================== diff -u -rfef255c381132c29ddbd1f7a7c37106ba90f2b52 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java (.../QaLearningForm.java) (revision fef255c381132c29ddbd1f7a7c37106ba90f2b52) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningForm.java (.../QaLearningForm.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -41,34 +41,11 @@ protected String getPreviousQuestion; protected String endLearning; - protected String toolSessionID; + protected String totalQuestionCount; + protected String httpSessionID; + protected String toolSessionID; + protected String questionIndex; protected String userID; - /** - * @return Returns the userID. - */ - public String getUserID() { - return userID; - } - /** - * @param userID The userID to set. - */ - public void setUserID(String userID) { - this.userID = userID; - } - protected String mode; - - /** - * @return Returns the mode. - */ - public String getMode() { - return mode; - } - /** - * @param mode The mode to set. - */ - public void setMode(String mode) { - this.mode = mode; - } protected String viewAllResults; protected String responseId; @@ -208,5 +185,68 @@ */ public void setToolSessionID(String toolSessionID) { this.toolSessionID = toolSessionID; + } + + /** + * @return Returns the httpSessionID. + */ + public String getHttpSessionID() { + return httpSessionID; + } + /** + * @param httpSessionID The httpSessionID to set. + */ + public void setHttpSessionID(String httpSessionID) { + this.httpSessionID = httpSessionID; + } + /** + * @return Returns the userID. + */ + public String getUserID() { + return userID; + } + /** + * @param userID The userID to set. + */ + public void setUserID(String userID) { + this.userID = userID; + } + protected String mode; + + /** + * @return Returns the mode. + */ + public String getMode() { + return mode; + } + /** + * @param mode The mode to set. + */ + public void setMode(String mode) { + this.mode = mode; } + /** + * @return Returns the questionIndex. + */ + public String getQuestionIndex() { + return questionIndex; + } + /** + * @param questionIndex The questionIndex to set. + */ + public void setQuestionIndex(String questionIndex) { + this.questionIndex = questionIndex; + } + /** + * @return Returns the totalQuestionCount. + */ + public String getTotalQuestionCount() { + return totalQuestionCount; + } + /** + * @param totalQuestionCount The totalQuestionCount to set. + */ + public void setTotalQuestionCount(String totalQuestionCount) { + this.totalQuestionCount = totalQuestionCount; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== diff -u -r0120babf4ee377217a385ca28e4f6202b4b4dbf6 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 0120babf4ee377217a385ca28e4f6202b4b4dbf6) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -22,6 +22,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.qa.web; import java.io.IOException; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.TreeMap; @@ -53,6 +54,7 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; /** * @@ -180,6 +182,15 @@ //request.getSession().setAttribute(CURRENT_ANSWER, ""); generalLearnerFlowDTO.setCurrentAnswer(""); + + SessionMap sessionMap = new SessionMap(); + Map mapSequentialAnswers= new HashMap(); + sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + + /*initialize available question display modes in the session */ //request.getSession().setAttribute(QUESTION_LISTING_MODE_SEQUENTIAL,QUESTION_LISTING_MODE_SEQUENTIAL); //request.getSession().setAttribute(QUESTION_LISTING_MODE_COMBINED, QUESTION_LISTING_MODE_COMBINED); @@ -372,7 +383,9 @@ //request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestions.size()).toString()); generalLearnerFlowDTO.setTotalQuestionCount(new Integer(mapQuestions.size())); + qaLearningForm.setTotalQuestionCount(new Integer(mapQuestions.size()).toString()); + //String userFeedback= feedBackType + request.getSession().getAttribute(TOTAL_QUESTION_COUNT) + QUESTIONS; String userFeedback= feedBackType + generalLearnerFlowDTO.getTotalQuestionCount() + QUESTIONS; Index: lams_tool_laqa/web/learning/AnswersContent.jsp =================================================================== diff -u -r0120babf4ee377217a385ca28e4f6202b4b4dbf6 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision 0120babf4ee377217a385ca28e4f6202b4b4dbf6) +++ lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -49,6 +49,7 @@ { submitLearningMethod(actionMethod); } + @@ -65,7 +66,10 @@ - + + + +
Index: lams_tool_laqa/web/learning/IndividualLearnerResults.jsp =================================================================== diff -u -r0120babf4ee377217a385ca28e4f6202b4b4dbf6 -r3733f9f2d907c3e4b498ee5890b36d93a64814ce --- lams_tool_laqa/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision 0120babf4ee377217a385ca28e4f6202b4b4dbf6) +++ lams_tool_laqa/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision 3733f9f2d907c3e4b498ee5890b36d93a64814ce) @@ -64,7 +64,9 @@
- + + +