Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== diff -u -r26ea61eae29934bddf4595c3c1aededeeeaca933 -r7c19f4b889eb8c768d97d756f6ce428283136f19 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 26ea61eae29934bddf4595c3c1aededeeeaca933) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 7c19f4b889eb8c768d97d756f6ce428283136f19) @@ -52,9 +52,6 @@ String httpSessionID = request.getParameter("httpSessionID"); mcLearningForm.setHttpSessionID(httpSessionID); - String userID = request.getParameter("userID"); - mcLearningForm.setUserID(userID); - String passMarkApplicable = request.getParameter("passMarkApplicable"); mcLearningForm.setPassMarkApplicable(passMarkApplicable); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -r26ea61eae29934bddf4595c3c1aededeeeaca933 -r7c19f4b889eb8c768d97d756f6ce428283136f19 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 26ea61eae29934bddf4595c3c1aededeeeaca933) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 7c19f4b889eb8c768d97d756f6ce428283136f19) @@ -321,11 +321,7 @@ //prohibit users from submitting answers after response is finalized but Resubmit button is not pressed (e.g. using 2 browsers) if (user.isResponseFinalised()) { - ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("viewAnswersRedirect")); - redirect.addParameter(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionID); - redirect.addParameter(MODE, "learner"); - redirect.addParameter("httpSessionID", httpSessionID); - return redirect; + return viewAnswers(mapping, mcLearningForm, request, response); } // Have to work out in advance if passed so that we can store it against the attempts @@ -397,11 +393,7 @@ //prohibit users from submitting answers after response is finalized but Resubmit button is not pressed (e.g. using 2 browsers) if (user.isResponseFinalised()) { - ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("viewAnswersRedirect")); - redirect.addParameter(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionID); - redirect.addParameter(MODE, "learner"); - redirect.addParameter("httpSessionID", httpSessionID); - return redirect; + return viewAnswers(mapping, mcLearningForm, request, response); } //parse learner input @@ -689,8 +681,6 @@ } /** - * submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse - * response) * * @param mapping * @param form @@ -712,19 +702,18 @@ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); mcLearningForm.setToolSessionID(toolSessionID); - String userID = request.getParameter("userID"); - mcLearningForm.setUserID(userID); + Long userID = mcLearningForm.getUserID(); String reflectionEntry = request.getParameter(McAppConstants.ENTRY_TEXT); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, new Integer(userID)); + McAppConstants.MY_SIGNATURE, userID.intValue()); if (notebookEntry != null) { notebookEntry.setEntry(reflectionEntry); mcService.updateEntry(notebookEntry); } else { mcService.createNotebookEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, new Integer(userID), reflectionEntry); + McAppConstants.MY_SIGNATURE, userID.intValue(), reflectionEntry); } return endLearning(mapping, form, request, response); @@ -759,19 +748,11 @@ mcGeneralLearnerFlowDTO.setActivityTitle(mcContent.getTitle()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); - String userID = ""; - HttpSession ss = SessionManager.getSession(); + Long userID = mcLearningForm.getUserID(); - if (ss != null) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if (user != null && user.getUserID() != null) { - userID = user.getUserID().toString(); - } - } - // attempt getting notebookEntry NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, new Integer(userID)); + McAppConstants.MY_SIGNATURE, userID.intValue()); if (notebookEntry != null) { String notebookEntryPresentable = notebookEntry.getEntry(); @@ -805,10 +786,8 @@ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID)); McContent mcContent = mcSession.getMcContent(); - HttpSession ss = SessionManager.getSession(); - UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); - String userID = userDto.getUserID().toString(); - McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); + Long userID = mcLearningForm.getUserID(); + McQueUsr user = mcService.getMcUserBySession(userID, mcSession.getUid()); //prohibit users from autosaving answers after response is finalized but Resubmit button is not pressed (e.g. using 2 browsers) if (user.isResponseFinalised()) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java =================================================================== diff -u -r26ea61eae29934bddf4595c3c1aededeeeaca933 -r7c19f4b889eb8c768d97d756f6ce428283136f19 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 26ea61eae29934bddf4595c3c1aededeeeaca933) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 7c19f4b889eb8c768d97d756f6ce428283136f19) @@ -49,7 +49,7 @@ protected String[] checkedCa; protected String[] sequentialCheckedCa; - protected String userID; + protected Long userID; protected String toolContentID; protected String toolContentUID; protected String toolSessionID; @@ -458,15 +458,15 @@ /** * @return Returns the userID. */ - public String getUserID() { + public Long getUserID() { return userID; } /** * @param userID * The userID to set. */ - public void setUserID(String userID) { + public void setUserID(Long userID) { this.userID = userID; } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u -r26ea61eae29934bddf4595c3c1aededeeeaca933 -r7c19f4b889eb8c768d97d756f6ce428283136f19 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 26ea61eae29934bddf4595c3c1aededeeeaca933) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 7c19f4b889eb8c768d97d756f6ce428283136f19) @@ -91,11 +91,6 @@ mcLearningForm.setPassMarkApplicable(new Boolean(false).toString()); mcLearningForm.setUserOverPassMark(new Boolean(false).toString()); - ActionForward validateParameters = validateParameters(request, mcLearningForm, mapping); - if (validateParameters != null) { - return validateParameters; - } - SessionMap sessionMap = new SessionMap(); List sequentialCheckedCa = new LinkedList(); sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa); @@ -109,9 +104,7 @@ * by now, we made sure that the passed tool session id exists in the db as a new record Make sure we can * retrieve it and the relavent content */ - McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID)); - if (mcSession == null) { McUtils.cleanUpSessionAbsolute(request); return (mapping.findForward(McAppConstants.ERROR_LIST)); @@ -122,18 +115,18 @@ * tool session id points to a particular content. Many to one mapping. */ McContent mcContent = mcSession.getMcContent(); - if (mcContent == null) { McUtils.cleanUpSessionAbsolute(request); - persistError(request, "error.content.doesNotExist"); + ActionMessages errors = new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.doesNotExist")); + saveErrors(request, errors); return (mapping.findForward(McAppConstants.ERROR_LIST)); } /* * The content we retrieved above must have been created before in Authoring time. And the passed tool session * id already refers to it. */ - McLearnerStarterDTO mcLearnerStarterDTO = new McLearnerStarterDTO(); if (mcContent.isQuestionsSequenced()) { mcLearnerStarterDTO.setQuestionListingMode(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL); @@ -152,13 +145,13 @@ } else { user = getCurrentUser(toolSessionID); } + Long userID = user.getQueUsrId(); + mcLearningForm.setUserID(userID); /* * Is there a deadline set? */ - Date submissionDeadline = mcContent.getSubmissionDeadline(); - if (submissionDeadline != null) { HttpSession ss = SessionManager.getSession(); @@ -189,9 +182,8 @@ // String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); - String userID = mcLearningForm.getUserID(); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, new Integer(userID)); + McAppConstants.MY_SIGNATURE, userID.intValue()); if (notebookEntry != null) { // String notebookEntryPresentable = McUtils.replaceNewLines(notebookEntry.getEntry()); @@ -252,6 +244,7 @@ ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("viewAnswersRedirect")); redirect.addParameter(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionID); + redirect.addParameter("userID", userID); redirect.addParameter(MODE, mode); redirect.addParameter("httpSessionID", sessionMap.getSessionID()); return redirect; @@ -261,53 +254,6 @@ return (mapping.findForward(McAppConstants.LOAD_LEARNER)); } - protected ActionForward validateParameters(HttpServletRequest request, McLearningForm mcLearningForm, - ActionMapping mapping) { - /* - * obtain and setup the current user's data - */ - - String userID = ""; - HttpSession ss = SessionManager.getSession(); - - if (ss != null) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if ((user != null) && (user.getUserID() != null)) { - userID = user.getUserID().toString(); - } - } - - mcLearningForm.setUserID(userID); - - /* - * process incoming tool session id and later derive toolContentId from it. - */ - String strToolSessionId = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); - long toolSessionId = 0; - if ((strToolSessionId == null) || (strToolSessionId.length() == 0)) { - McLearningStarterAction.logger.error("error.toolSessionId.required"); - } else { - try { - toolSessionId = new Long(strToolSessionId).longValue(); - } catch (NumberFormatException e) { - McLearningStarterAction.logger.error("error.sessionId.numberFormatException"); - } - } - - /* mode can be learner, teacher or author */ - String mode = request.getParameter(McAppConstants.MODE); - - if ((mode == null) || (mode.length() == 0)) { - McLearningStarterAction.logger.error("error.mode.required"); - } - - if ((!mode.equals("learner")) && (!mode.equals("teacher")) && (!mode.equals("author"))) { - McLearningStarterAction.logger.error("error.mode.invalid"); - } - - return null; - } - private McQueUsr getCurrentUser(String toolSessionId) { // get back login user DTO @@ -333,16 +279,4 @@ } return qaUser; } - - /** - * persists error messages to request scope - * - * @param request - * @param message - */ - public void persistError(HttpServletRequest request, String message) { - ActionMessages errors = new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - saveErrors(request, errors); - } } Index: lams_tool_lamc/web/WEB-INF/struts-config.xml =================================================================== diff -u -ra68c00dde9fb65afd26005dbf9d1577ba72162c4 -r7c19f4b889eb8c768d97d756f6ce428283136f19 --- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision a68c00dde9fb65afd26005dbf9d1577ba72162c4) +++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 7c19f4b889eb8c768d97d756f6ce428283136f19) @@ -265,12 +265,6 @@ redirect="false" /> - - - <fmt:message key="activity.title" /> - + <fmt:message key="activity.title" />