Index: lams_tool_lamc/conf/language/ApplicationResources.properties =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -246,6 +246,7 @@ label.learner= Learner label.yourMark =Your Mark: label.feedback =Question Feedback: +label.notEnoughMarks=You don't have enough marks to finish. Please redo. label.authoring.title.col =Title: label.authoring.instructions.col =Instructions: Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java (.../McGeneralLearnerFlowDTO.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java (.../McGeneralLearnerFlowDTO.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -22,6 +22,8 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.mc; +import java.util.Map; + import org.apache.commons.lang.builder.ToStringBuilder; @@ -67,9 +69,49 @@ protected String lowestMark; protected String averageMark; - + protected String learnerProgress; + + protected String learnerProgressUserId; + + protected Map mapQueAttempts; + + protected Map mapQueCorrectAttempts; + + protected Map mapQueIncorrectAttempts; + + protected Map mapGeneralOptionsContent; + + protected Map mapQuestionsContent; + + protected String toolSessionId; + + /** + * @return Returns the toolSessionId. + */ + public String getToolSessionId() { + return toolSessionId; + } + /** + * @param toolSessionId The toolSessionId to set. + */ + public void setToolSessionId(String toolSessionId) { + this.toolSessionId = toolSessionId; + } + /** + * @return Returns the mapGeneralOptionsContent. + */ + public Map getMapGeneralOptionsContent() { + return mapGeneralOptionsContent; + } + /** + * @param mapGeneralOptionsContent The mapGeneralOptionsContent to set. + */ + public void setMapGeneralOptionsContent(Map mapGeneralOptionsContent) { + this.mapGeneralOptionsContent = mapGeneralOptionsContent; + } + /** * @return Returns the averageMark. */ public String getAverageMark() { @@ -303,4 +345,76 @@ public void setCurrentQuestionIndex(String currentQuestionIndex) { this.currentQuestionIndex = currentQuestionIndex; } + /** + * @return Returns the mapQueAttempts. + */ + public Map getMapQueAttempts() { + return mapQueAttempts; + } + /** + * @param mapQueAttempts The mapQueAttempts to set. + */ + public void setMapQueAttempts(Map mapQueAttempts) { + this.mapQueAttempts = mapQueAttempts; + } + /** + * @return Returns the mapQueCorrectAttempts. + */ + public Map getMapQueCorrectAttempts() { + return mapQueCorrectAttempts; + } + /** + * @param mapQueCorrectAttempts The mapQueCorrectAttempts to set. + */ + public void setMapQueCorrectAttempts(Map mapQueCorrectAttempts) { + this.mapQueCorrectAttempts = mapQueCorrectAttempts; + } + /** + * @return Returns the mapQueIncorrectAttempts. + */ + public Map getMapQueIncorrectAttempts() { + return mapQueIncorrectAttempts; + } + /** + * @param mapQueIncorrectAttempts The mapQueIncorrectAttempts to set. + */ + public void setMapQueIncorrectAttempts(Map mapQueIncorrectAttempts) { + this.mapQueIncorrectAttempts = mapQueIncorrectAttempts; + } + /** + * @return Returns the learnerProgress. + */ + public String getLearnerProgress() { + return learnerProgress; + } + /** + * @param learnerProgress The learnerProgress to set. + */ + public void setLearnerProgress(String learnerProgress) { + this.learnerProgress = learnerProgress; + } + /** + * @return Returns the learnerProgressUserId. + */ + public String getLearnerProgressUserId() { + return learnerProgressUserId; + } + /** + * @param learnerProgressUserId The learnerProgressUserId to set. + */ + public void setLearnerProgressUserId(String learnerProgressUserId) { + this.learnerProgressUserId = learnerProgressUserId; + } + /** + * @return Returns the mapQuestionsContent. + */ + public Map getMapQuestionsContent() { + return mapQuestionsContent; + } + /** + * @param mapQuestionsContent The mapQuestionsContent to set. + */ + public void setMapQuestionsContent(Map mapQuestionsContent) { + this.mapQuestionsContent = mapQuestionsContent; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r54049b70be0d86d212cf2cee1e27bca3b97ea59f -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 54049b70be0d86d212cf2cee1e27bca3b97ea59f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -867,9 +867,8 @@ * @param mapQuestionsUidContent * @return */ - public static Map rebuildStartupGeneralOptionsContentMapfromDB(HttpServletRequest request, Map mapQuestionsUidContent) + public static Map rebuildStartupGeneralOptionsContentMapfromDB(HttpServletRequest request, Map mapQuestionsUidContent, IMcService mcService) { - IMcService mcService =McUtils.getToolService(request); Map mapStartupGeneralOptionsContent= new TreeMap(new McComparator()); Iterator itMap = mapQuestionsUidContent.entrySet().iterator(); @@ -945,11 +944,9 @@ * @param toolContentId * @return Map */ - public static Map rebuildQuestionMapfromDB(HttpServletRequest request, Long toolContentId) + public static Map rebuildQuestionMapfromDB(HttpServletRequest request, Long toolContentId, IMcService mcService) { Map mapQuestionsContent= new TreeMap(new McComparator()); - - IMcService mcService =McUtils.getToolService(request); logger.debug("toolContentId:" + toolContentId); McContent mcContent=mcService.retrieveMc(toolContentId); @@ -981,11 +978,9 @@ * @param toolContentId * @return Map */ - public static Map rebuildQuestionUidMapfromDB(HttpServletRequest request, Long toolContentId) + public static Map rebuildQuestionUidMapfromDB(HttpServletRequest request, Long toolContentId, IMcService mcService) { Map mapQuestionsContent= new TreeMap(new McComparator()); - - IMcService mcService =McUtils.getToolService(request); logger.debug("toolContentId:" + toolContentId); McContent mcContent=mcService.retrieveMc(toolContentId); @@ -2548,16 +2543,16 @@ * @param request * @param toolContentId */ - public static void refreshMaps(HttpServletRequest request, long toolContentId) + public static void refreshMaps(HttpServletRequest request, long toolContentId, IMcService mcService) { logger.debug("refreshing maps.."); - Map mapQuestionsUidContent=AuthoringUtil.rebuildQuestionUidMapfromDB(request, new Long(toolContentId)); + Map mapQuestionsUidContent=AuthoringUtil.rebuildQuestionUidMapfromDB(request, new Long(toolContentId), mcService); logger.debug("mapQuestionsUidContent:" + mapQuestionsUidContent); logger.debug("mapQuestionsUidContent size:" + mapQuestionsUidContent.size()); if (mapQuestionsUidContent.size() > 0) { - Map mapStartupGeneralOptionsContent=AuthoringUtil.rebuildStartupGeneralOptionsContentMapfromDB(request, mapQuestionsUidContent); + Map mapStartupGeneralOptionsContent=AuthoringUtil.rebuildStartupGeneralOptionsContentMapfromDB(request, mapQuestionsUidContent, mcService); logger.debug("mapStartupGeneralOptionsContent:" + mapStartupGeneralOptionsContent); request.getSession().setAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT, mapStartupGeneralOptionsContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -122,51 +122,7 @@ } - - - /** - * redundant method: - * - * assess(HttpServletRequest request, Map mapGeneralCheckedOptionsContent) - * - * @param request - * @param mapGeneralCheckedOptionsContent - */ - public static Map assess(HttpServletRequest request, Map mapGeneralCheckedOptionsContent, Long toolContentId) - { - Map mapGeneralCorrectOptions= new TreeMap(new McComparator()); - - IMcService mcService =McUtils.getToolService(request); - - Map mapQuestionsUidContent=AuthoringUtil.rebuildQuestionUidMapfromDB(request,toolContentId); - logger.debug("mapQuestionsUidContent : " + mapQuestionsUidContent); - - Iterator itMap = mapQuestionsUidContent.entrySet().iterator(); - Long mapIndex=new Long(1); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - logger.debug("using mcQueContentId: " + pairs.getValue()); - List correctOptions=(List) mcService.getPersistedSelectedOptions(new Long(pairs.getValue().toString())); - Map mapCorrectOptions=buildMapCorrectOptions(correctOptions); - logger.debug("mapCorrectOptions: " + mapCorrectOptions); - mapGeneralCorrectOptions.put(mapIndex.toString(),mapCorrectOptions); - mapIndex=new Long(mapIndex.longValue()+1); - } - logger.debug("mapGeneralCorrectOptions : " + mapGeneralCorrectOptions); - - Map mapLeanerAssessmentResults=compare(mapGeneralCorrectOptions,mapGeneralCheckedOptionsContent); - logger.debug("mapLeanerAssessmentResults : " + mapLeanerAssessmentResults); - request.getSession().setAttribute(MAP_LEARNER_ASSESSMENT_RESULTS, mapLeanerAssessmentResults); - - return mapLeanerAssessmentResults; - - } - - - /** * calculateWeights(Map mapLeanerAssessmentResults, Map mapQuestionWeights) * * @param mapLeanerAssessmentResults @@ -533,17 +489,15 @@ return false; } - public static McQueUsr getUser(HttpServletRequest request, IMcService mcService) + public static McQueUsr getUser(HttpServletRequest request, IMcService mcService, String toolSessionId) { + logger.debug("getUser:: " + toolSessionId); Long queUsrId=McUtils.getUserId(); - - Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); - logger.debug("toolSessionId: " + toolSessionId); - McSession mcSession=mcService.retrieveMcSession(toolSessionId); + McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId)); logger.debug("retrieving mcSession: " + mcSession); McQueUsr mcQueUsr=mcService.getMcUserBySession(queUsrId, mcSession.getUid()); - //McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(queUsrId); + logger.debug("retrieving mcQueUsr: " + mcQueUsr); return mcQueUsr; } @@ -560,7 +514,6 @@ Long queUsrId=McUtils.getUserId(); String username=McUtils.getUserName(); String fullname=McUtils.getUserFullName(); - //Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID); McSession mcSession=mcService.retrieveMcSession(toolSessionId); McQueUsr mcQueUsr= new McQueUsr(queUsrId, @@ -606,41 +559,6 @@ } - /* - public static void createAttempt(HttpServletRequest request, McQueUsr mcQueUsr, Map mapGeneralCheckedOptionsContent, int mark, boolean passed, int highestAttemptOrder, Map mapLeanerAssessmentResults) - { - IMcService mcService =McUtils.getToolService(request); - Date attempTime=McUtils.getGMTDateTime(); - String timeZone= McUtils.getCurrentTimeZone(); - logger.debug("timeZone: " + timeZone); - - Long toolContentUID= (Long) request.getSession().getAttribute(TOOL_CONTENT_UID); - logger.debug("toolContentUID: " + toolContentUID); - - if (toolContentUID != null) - { - Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator(); - while (itCheckedMap.hasNext()) - { - Map.Entry checkedPairs = (Map.Entry)itCheckedMap.next(); - Map mapCheckedOptions=(Map) checkedPairs.getValue(); - Long questionDisplayOrder=new Long(checkedPairs.getKey().toString()); - - logger.debug("questionDisplayOrder: " + questionDisplayOrder); - String isAttemptCorrect=(String)mapLeanerAssessmentResults.get(questionDisplayOrder.toString()); - logger.debug("isAttemptCorrect: " + isAttemptCorrect); - - McQueContent mcQueContent=mcService.getQuestionContentByDisplayOrder(questionDisplayOrder, toolContentUID); - logger.debug("mcQueContent: " + mcQueContent); - - if (mcQueContent != null) - { - createIndividualOptions(request, mapCheckedOptions, mcQueContent, mcQueUsr, attempTime, timeZone, mark, passed, new Integer(highestAttemptOrder), isAttemptCorrect); - } - } - } - } - */ public static void createIndividualOptions(HttpServletRequest request, Map candidateAnswers, McQueContent mcQueContent, McQueUsr mcQueUsr, Date attempTime, String timeZone, int mark, boolean passed, Integer highestAttemptOrder, String isAttemptCorrect, Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -rff60206f498b016a282bba4630b2cc4e4324ab21 -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision ff60206f498b016a282bba4630b2cc4e4324ab21) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -1893,7 +1893,7 @@ McContent mcContent=mcService.retrieveMc(toolContentId); logger.debug("mcContent: " + mcContent); - AuthoringUtil.refreshMaps(request, toolContentId.longValue()); + AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); logger.debug("refreshed maps..."); Map mapStartupGeneralOptionsContent= (Map) request.getSession().getAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT); @@ -2257,7 +2257,7 @@ logger.debug("Submit final MAP_FEEDBACK_CORRECT :" + mapFeedbackCorrect); - AuthoringUtil.refreshMaps(request, toolContentId.longValue()); + AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); logger.debug("refreshed maps..."); logger.debug("start processing questions content..."); @@ -2280,7 +2280,7 @@ logger.debug("mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); logger.debug("will refresh maps..."); - AuthoringUtil.refreshMaps(request, toolContentId.longValue()); + AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); mapStartupGeneralOptionsContent= (Map) request.getSession().getAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT); logger.debug("mapStartupGeneralOptionsContent: " + mapStartupGeneralOptionsContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; +import java.util.TreeSet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -298,7 +299,11 @@ { logger.debug("requested learner finished, the learner should be directed to next activity."); - Long toolSessionId = (Long) request.getSession().getAttribute(TOOL_SESSION_ID); + String toolSessionId=mcLearningForm.getToolSessionId(); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId)); + logger.debug("retrieving mcSession: " + mcSession); String userID = ""; HttpSession ss = SessionManager.getSession(); @@ -321,7 +326,7 @@ String nextUrl=null; try { - nextUrl=mcService.leaveToolSession(toolSessionId, new Long(userID)); + nextUrl=mcService.leaveToolSession(new Long(toolSessionId), new Long(userID)); logger.debug("nextUrl: "+ nextUrl); } catch (DataMissingException e) @@ -349,9 +354,6 @@ logger.debug("success getting nextUrl: "+ nextUrl); mcLearningForm.resetCommands(); - McSession mcSession=mcService.retrieveMcSession(toolSessionId); - logger.debug("retrieving mcSession: " + mcSession); - McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid()); logger.debug("mcQueUsr:" + mcQueUsr); @@ -385,29 +387,18 @@ return null; } - else if (mcLearningForm.getDonePreview() != null) - { - logger.debug("requested donePreview."); - mcLearningForm.resetCommands(); - McUtils.cleanUpSessionAbsolute(request); - return (mapping.findForward(LEARNING_STARTER)); - } - else if (mcLearningForm.getDoneLearnerProgress() != null) - { - logger.debug("requested doneLearnerProgress."); - mcLearningForm.resetCommands(); - McUtils.cleanUpSessionAbsolute(request); - return (mapping.findForward(LEARNING_STARTER)); - } mcLearningForm.resetCommands(); return (mapping.findForward(LOAD_LEARNER)); } - protected Set parseLearnerInput(List learnerInput) + protected Set parseLearnerInput(List learnerInput, McContent mcContent, IMcService mcService) { logger.debug("learnerInput: " + learnerInput); + logger.debug("mcContent: " + mcContent); + logger.debug("mcContent uid: " + mcContent.getUid()); + Set questionUids= new HashSet(); Iterator listLearnerInputIterator=learnerInput.iterator(); @@ -422,19 +413,50 @@ questionUids.add(questionUid); } logger.debug("final set questionUid: " + questionUids); - return questionUids; + + + List questionEntriesOrdered=mcService.getAllQuestionEntries(mcContent.getUid()); + logger.debug("questionEntriesOrdered: " + questionEntriesOrdered); + + Set questionOrderedUids= new TreeSet(); + Iterator questionEntriesOrderedIterator=questionEntriesOrdered.iterator(); + while (questionEntriesOrderedIterator.hasNext()) + { + McQueContent mcQueContent= (McQueContent)questionEntriesOrderedIterator.next(); + logger.debug("mcQueContent: " + mcQueContent); + logger.debug("mcQueContent text: " + mcQueContent.getQuestion()); + + + Iterator questionUidsIterator=questionUids.iterator(); + while (questionUidsIterator.hasNext()) + { + String questionUid= (String)questionUidsIterator.next(); + logger.debug("questionUid: " + questionUid); + + logger.debug("questionUid versus objects uid : " + questionUid + " versus " + mcQueContent.getUid()); + if (questionUid.equals(mcQueContent.getUid().toString())) + { + questionOrderedUids.add(questionUid); + } + } + } + logger.debug("questionOrderedUids: " + questionOrderedUids); + return questionOrderedUids; } - protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, McTempDataHolderDTO mcTempDataHolderDTO, IMcService mcService) + protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, McTempDataHolderDTO mcTempDataHolderDTO, + IMcService mcService, McContent mcContent) { logger.debug("mcService: " + mcService); + logger.debug("mcContent: " + mcContent); + logger.debug("learnerInput: " + learnerInput); int mark=0; int userWeight=0; - Set questionUids=parseLearnerInput(learnerInput); + Set questionUids=parseLearnerInput(learnerInput, mcContent, mcService); logger.debug("set questionUids: " + questionUids); List questionAndCandidateAnswersList= new LinkedList(); @@ -555,7 +577,10 @@ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); logger.debug("retrieving mcService from proxy: " + mcService); - String[] checkedCa=mcLearningForm.getCheckedCa(); + String[] checkedCa=mcLearningForm.getCheckedCa(); + mcLearningForm.resetCa(mapping, request); + + logger.debug("checkedCa: " + checkedCa); logger.debug("checkedCa length: " + checkedCa.length ); @@ -570,14 +595,15 @@ String toolContentId=mcLearningForm.getToolContentId(); logger.debug("toolContentId: " + toolContentId); - - - //Integer learnerMark= new Integer(0); - //Integer totalUserWeight= new Integer(0); + + /* process the answers */ + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("mcContent: " + mcContent); + McTempDataHolderDTO mcTempDataHolderDTO= new McTempDataHolderDTO(); List selectedQuestionAndCandidateAnswersDTO=buildSelectedQuestionAndCandidateAnswersDTO(learnerInput,mcTempDataHolderDTO - , mcService); + , mcService, mcContent); logger.debug("selectedQuestionAndCandidateAnswersDTO: " + selectedQuestionAndCandidateAnswersDTO); request.setAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO, selectedQuestionAndCandidateAnswersDTO); logger.debug("LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO)); @@ -591,9 +617,6 @@ - /* process the answers */ - McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); - logger.debug("mcContent: " + mcContent); McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); logger.debug("constructed a new mcGeneralLearnerFlowDTO"); @@ -874,20 +897,52 @@ HttpServletResponse response) throws IOException, ServletException { + + McUtils.cleanUpUserExceptions(request); logger.debug("dispatching viewAnswers..."); McLearningForm mcLearningForm = (McLearningForm) form; - IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - String totalQuestionCount= (String) request.getSession().getAttribute(TOTAL_QUESTION_COUNT); - logger.debug("totalQuestionCount: " + totalQuestionCount); + IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + String toolContentId=mcLearningForm.getToolContentId(); + logger.debug("toolContentId: " + toolContentId); + + String toolSessionId=mcLearningForm.getToolSessionId(); + logger.debug("toolSessionId: " + toolSessionId); + + McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId)); + logger.debug("retrieving mcSession: " + mcSession); + + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("mcContent: " + mcContent); + + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); + + int intTotalQuestionCount=mcContent.getMcQueContents().size(); + String totalQuestionCount= new Integer(intTotalQuestionCount).toString(); + logger.debug("totalQuestionCount: " + totalQuestionCount); + /* this section is needed to separate learner progress view from standard attempts list. Goes from here.. */ - String learnerProgress=(String)request.getSession().getAttribute(LEARNER_PROGRESS); + String learnerProgress=mcLearningForm.getLearnerProgress(); logger.debug("learnerProgress: " + learnerProgress); - - String learnerProgressUserId=(String)request.getSession().getAttribute(LEARNER_PROGRESS_USERID); + mcGeneralLearnerFlowDTO.setLearnerProgress(learnerProgress); + + String learnerProgressUserId=mcLearningForm.getLearnerProgressUserId(); logger.debug("learnerProgressUserId: " + learnerProgressUserId); + mcGeneralLearnerFlowDTO.setLearnerProgressUserId(learnerProgressUserId); + + Map mapQuestionsUidContent=AuthoringUtil.rebuildQuestionUidMapfromDB(request, new Long(toolContentId), mcService); + logger.debug("mapQuestionsUidContent:" + mapQuestionsUidContent); + + Map mapStartupGeneralOptionsContent=AuthoringUtil.rebuildStartupGeneralOptionsContentMapfromDB(request, mapQuestionsUidContent, mcService); + logger.debug("mapStartupGeneralOptionsContent:" + mapStartupGeneralOptionsContent); + mcGeneralLearnerFlowDTO.setMapGeneralOptionsContent(mapStartupGeneralOptionsContent); + + Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, new Long(toolContentId), mcService); + logger.debug("mapQuestionsContent:" + mapQuestionsContent); + mcGeneralLearnerFlowDTO.setMapQuestionsContent(mapQuestionsContent); + boolean learnerProgressOn=false; if (learnerProgressUserId != null) { @@ -906,29 +961,27 @@ Long queUsrId=null; if (learnerProgressOn == false) { - mcQueUsr=LearningUtil.getUser(request, mcService); + mcQueUsr=LearningUtil.getUser(request, mcService, toolSessionId); logger.debug("mcQueUsr: " + mcQueUsr); queUsrId=mcQueUsr.getUid(); logger.debug("queUsrId: " + queUsrId); } else { - Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID); - logger.debug("toolSessionId: " + toolSessionId); - - McSession mcSession=mcService.retrieveMcSession(toolSessionId); - logger.debug("retrieving mcSession: " + mcSession); - + logger.debug("using mcSession: " + mcSession); + logger.debug("using learnerProgressUserId: " + learnerProgressUserId); + mcQueUsr=mcService.getMcUserBySession(new Long(learnerProgressUserId), mcSession.getUid()); + logger.debug("mcQueUsr: " + mcQueUsr); queUsrId=mcQueUsr.getUid(); logger.debug("queUsrId: " + queUsrId); } logger.debug("final mcQueUsr: " + mcQueUsr); logger.debug("final queUsrId: " + queUsrId); - Long toolContentUID= (Long) request.getSession().getAttribute(TOOL_CONTENT_UID); + Long toolContentUID=mcContent.getUid(); logger.debug("toolContentUID: " + toolContentUID); Map mapQueAttempts= new TreeMap(new McComparator()); @@ -1029,13 +1082,18 @@ mapQueIncorrectAttempts.put(new Integer(i).toString(), mapAttemptOrderIncorrectAttempts); } } - request.getSession().setAttribute(MAP_QUE_ATTEMPTS, mapQueAttempts); - request.getSession().setAttribute(MAP_QUE_CORRECT_ATTEMPTS, mapQueCorrectAttempts); - request.getSession().setAttribute(MAP_QUE_INCORRECT_ATTEMPTS, mapQueIncorrectAttempts); - + logger.debug("final mapQueAttempts is: " + mapQueAttempts); logger.debug("final mapQueCorrectAttempts is: " + mapQueCorrectAttempts); logger.debug("final mapQueIncorrectAttempts is: " + mapQueIncorrectAttempts); + + mcGeneralLearnerFlowDTO.setMapQueAttempts(mapQueAttempts); + mcGeneralLearnerFlowDTO.setMapQueCorrectAttempts(mapQueCorrectAttempts); + mcGeneralLearnerFlowDTO.setMapQueIncorrectAttempts(mapQueIncorrectAttempts); + + request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); + logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO)); + mcLearningForm.resetCommands(); return (mapping.findForward(VIEW_ANSWERS)); } @@ -1072,7 +1130,24 @@ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); - int countSessionComplete=mcService.countSessionComplete(); + int countSessionComplete=0; + Iterator sessionsIterator=mcContent.getMcSessions().iterator(); + while (sessionsIterator.hasNext()) + { + McSession mcSession= (McSession)sessionsIterator.next(); + if (mcSession != null) + { + logger.debug("mcSession: " + mcSession); + if (mcSession.getSessionStatus().equals(COMPLETED)) + { + logger.debug("COMPLETED session found: " + mcSession); + ++countSessionComplete; + } + } + } + logger.debug("countSessionComplete: " + countSessionComplete); + + int topMark=LearningUtil.getTopMark(request, mcService); int lowestMark=LearningUtil.getLowestMark(request, mcService); int averageMark=LearningUtil.getAverageMark(request, mcService); @@ -1082,11 +1157,6 @@ logger.debug("lowestMark: " + lowestMark); logger.debug("averageMark: " + averageMark); - //request.getSession().setAttribute(COUNT_SESSION_COMPLETE, new Integer(countSessionComplete).toString()); - //request.getSession().setAttribute(TOP_MARK, new Integer(topMark).toString()); - //request.getSession().setAttribute(LOWEST_MARK, new Integer(lowestMark).toString()); - //request.getSession().setAttribute(AVERAGE_MARK, new Integer(averageMark).toString()); - mcGeneralLearnerFlowDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); mcGeneralLearnerFlowDTO.setTopMark(new Integer(topMark).toString()); mcGeneralLearnerFlowDTO.setLowestMark(new Integer(lowestMark).toString()); @@ -1136,9 +1206,8 @@ /* reset the checked options MAP */ Map mapGeneralCheckedOptionsContent= new TreeMap(new McComparator()); - //request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - - String toolContentId=mcLearningForm.getToolContentId(); + + String toolContentId=mcLearningForm.getToolContentId(); logger.debug("toolContentId: " + toolContentId); McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); @@ -1155,9 +1224,6 @@ logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO)); mcLearningForm.resetCommands(); - - //String previewOnly=(String)request.getSession().getAttribute(PREVIEW_ONLY); - //logger.debug("previewOnly: " + previewOnly); logger.debug("fwding to LOAD_LEARNER: " + LOAD_LEARNER); return (mapping.findForward(LOAD_LEARNER)); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -22,7 +22,10 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.mc.web; +import javax.servlet.http.HttpServletRequest; + import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.mc.McAppConstants; /** @@ -51,10 +54,17 @@ protected String learningMode; protected String currentQuestionIndex; + /**put tghese under SessionMap*/ protected String userOverPassMark; protected String passMarkApplicable; + protected String learnerProgress; + protected String learnerProgressUserId; + + public void resetCa(ActionMapping mapping, HttpServletRequest request) { + checkedCa = new String[0]; + } + - public void resetCommands() { this.setContinueOptions(null); @@ -297,4 +307,28 @@ this.currentQuestionIndex = currentQuestionIndex; } + /** + * @return Returns the learnerProgress. + */ + public String getLearnerProgress() { + return learnerProgress; + } + /** + * @param learnerProgress The learnerProgress to set. + */ + public void setLearnerProgress(String learnerProgress) { + this.learnerProgress = learnerProgress; + } + /** + * @return Returns the learnerProgressUserId. + */ + public String getLearnerProgressUserId() { + return learnerProgressUserId; + } + /** + * @param learnerProgressUserId The learnerProgressUserId to set. + */ + public void setLearnerProgressUserId(String learnerProgressUserId) { + this.learnerProgressUserId = learnerProgressUserId; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -296,8 +296,9 @@ commonContentSetup(request, mcContent, mcService); /* LEARNER_PROGRESS for jsp*/ - request.getSession().setAttribute(LEARNER_PROGRESS_USERID, userId); - request.getSession().setAttribute(LEARNER_PROGRESS, new Boolean(true).toString()); + mcLearningForm.setLearnerProgress(new Boolean(true).toString()); + mcLearningForm.setLearnerProgressUserId(userId); + McLearningAction mcLearningAction= new McLearningAction(); /* pay attention that this userId is the learner's userId passed by the request parameter. * It is differerent than USER_ID kept in the session of the current system user*/ @@ -308,7 +309,7 @@ { McUtils.cleanUpSessionAbsolute(request); persistError(request, "error.learner.required"); - request.getSession().setAttribute(USER_EXCEPTION_LEARNER_REQUIRED, new Boolean(true).toString()); + //request.getSession().setAttribute(USER_EXCEPTION_LEARNER_REQUIRED, new Boolean(true).toString()); return (mapping.findForward(ERROR_LIST)); } @@ -323,7 +324,7 @@ (mcSessionLocal.getMcSessionId().longValue() != toolSessionId.longValue())) { McUtils.cleanUpSessionAbsolute(request); - request.getSession().setAttribute(USER_EXCEPTION_TOOLSESSIONID_INCONSISTENT, new Boolean(true).toString()); + //request.getSession().setAttribute(USER_EXCEPTION_TOOLSESSIONID_INCONSISTENT, new Boolean(true).toString()); persistError(request, "error.learner.sessionId.inconsistent"); return (mapping.findForward(ERROR_LIST)); } @@ -406,18 +407,13 @@ if (highestAttemptOrder == 0) highestAttemptOrder=1; logger.debug("highestAttemptOrder: " + highestAttemptOrder); - //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(highestAttemptOrder).toString()); int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId, mcService); logger.debug("learnerBestMark: " + learnerBestMark); - //request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(learnerBestMark).toString()); } else { logger.debug("mcQueUsr is not available in the db:" + mcQueUsr); - //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(1).toString()); - //request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(0).toString()); - } String learningMode=mcLearningForm.getLearningMode(); @@ -517,41 +513,6 @@ */ logger.debug("IS_TOOL_ACTIVITY_OFFLINE: " + mcContent.isRunOffline()); mcLearnerStarterDTO.setToolActivityOffline(new Boolean(mcContent.isRunOffline()).toString()); - - - /* the following attributes are unused for the moment. - * from here... - */ - /* - logger.debug("IS_USERNAME_VISIBLE: " + mcContent.isUsernameVisible()); - request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(mcContent.isUsernameVisible()).toString()); - - logger.debug("IS_SHOW_FEEDBACK: " + new Boolean(mcContent.isShowFeedback()).toString()); - request.getSession().setAttribute(IS_SHOW_FEEDBACK, new Boolean(mcContent.isShowFeedback()).toString()); - - Map mapGeneralCheckedOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent); - - Map mapLeanerCheckedOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_LEARNER_CHECKED_OPTIONS_CONTENT, mapLeanerCheckedOptionsContent); - - Map mapLeanerAssessmentResults= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_LEARNER_ASSESSMENT_RESULTS, mapLeanerAssessmentResults); - - - Map mapLeanerFeedbackIncorrect=AuthoringUtil.buildInCorrectFeedbackMap(request, mcContent.getMcContentId()); - request.getSession().setAttribute(MAP_LEARNER_FEEDBACK_INCORRECT, mapLeanerFeedbackIncorrect); - logger.debug("MAP_LEARNER_FEEDBACK_INCORRECT: " + mapLeanerFeedbackIncorrect); - - Map mapLeanerFeedbackCorrect=AuthoringUtil.buildCorrectFeedbackMap(request, mcContent.getMcContentId()); - request.getSession().setAttribute(MAP_LEARNER_FEEDBACK_CORRECT, mapLeanerFeedbackCorrect); - logger.debug("MAP_LEARNER_FEEDBACK_CORRECT: " + mapLeanerFeedbackCorrect); - - Map mapQuestionWeights=LearningUtil.buildWeightsMap(request, mcContent.getMcContentId()); - request.getSession().setAttribute(MAP_QUESTION_WEIGHTS, mapQuestionWeights); - logger.debug("MAP_QUESTION_WEIGHTS: " + mapQuestionWeights); - */ - /* .. till here */ } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -180,7 +180,7 @@ request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,mcContent.getInstructions()); request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer - Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, toolContentId); + Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, toolContentId, mcService); logger.debug("mapQuestionsContent:" + mapQuestionsContent); request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); logger.debug("starter initialized the existing Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); @@ -385,7 +385,6 @@ } /* this section is related to Stats tab. Starts here. */ - //int countSessionComplete=mcService.countSessionComplete(); int countSessionComplete=mcService.countSessionComplete(mcContent); logger.debug("countSessionComplete: " + countSessionComplete); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u -rc273a7f656be2448e9c0328570f857f1b3ced28b -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision c273a7f656be2448e9c0328570f857f1b3ced28b) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -586,12 +586,12 @@ request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); - Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, new Long(toolContentId)); + Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, new Long(toolContentId), mcService); logger.debug("mapQuestionsContent:" + mapQuestionsContent); request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); logger.debug("starter initialized the existing Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - AuthoringUtil.refreshMaps(request, toolContentId); + AuthoringUtil.refreshMaps(request, toolContentId, mcService); AuthoringUtil.assignStaterMapsToCurrentMaps(request); /*process offline files metadata*/ Index: lams_tool_lamc/web/learning/IndividualLearnerResults.jsp =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -94,11 +94,7 @@ mcGeneralLearnerFlowDTO.passMarkApplicable == 'true' }"> -   -   -   - - + Index: lams_tool_lamc/web/learning/ViewAnswers.jsp =================================================================== diff -u -r8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de -re49068e45839612d025d20b33368c7ca21346a6f --- lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision 8a81c117f2bb66e5e4c7e5be0f2ca4bb8a1db7de) +++ lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision e49068e45839612d025d20b33368c7ca21346a6f) @@ -50,7 +50,7 @@
- + - + - +
@@ -65,15 +65,15 @@
@@ -82,9 +82,9 @@ - - - + + +
@@ -95,10 +95,10 @@
- - - - + + + +
@@ -117,18 +117,18 @@
- - - + + + - +
- : + : @@ -159,8 +159,8 @@ - - + + - + - +
@@ -170,17 +170,11 @@ - - - - - -
@@ -198,7 +192,7 @@