Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -race2e94a6c8e3f5a1980661bb2746444f780776f -r8f4ede3494f8c087de161a50616e511dd22d1605 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision ace2e94a6c8e3f5a1980661bb2746444f780776f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 8f4ede3494f8c087de161a50616e511dd22d1605) @@ -97,6 +97,7 @@ public static final String MAP_QUESTIONS_CONTENT ="mapQuestionsContent"; public static final String MAP_OPTIONS_CONTENT ="mapOptionsContent"; public static final String MAP_DEFAULTOPTIONS_CONTENT ="mapDefaultOptionsContent"; + public static final String MAP_DEFAULTSELECTEDOPTIONS_CONTENT ="mapDefaultSelectedOptionsContent"; public static final String MAP_DISABLED_QUESTIONS ="mapDisabledQuestions"; public static final String MAP_GENERAL_OPTIONS_CONTENT ="mapGeneralOptionsContent"; public static final String MAP_GENERAL_SELECTED_OPTIONS_CONTENT ="mapGeneralSelectedOptionsContent"; @@ -120,6 +121,8 @@ public static final String MAP_WEIGHTS ="mapWeights"; public static final String MAP_CHECKBOX_STATES ="mapCheckBoxStates"; public static final String MAP_SELECTED_OPTIONS ="mapSelectedOptions"; + + public static final String DEFAULT_FIRST_OPTION ="Candidate Answer 1"; public static final String DEFAULT_SELECTED_OPTION ="Candidate Answer 2"; public static final String MAP_FEEDBACK_INCORRECT ="mapFeedbackIncorrect"; public static final String MAP_INCORRECT_FEEDBACK ="mapIncorrectFeedback"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r8f4ede3494f8c087de161a50616e511dd22d1605 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 8f4ede3494f8c087de161a50616e511dd22d1605) @@ -205,7 +205,7 @@ } - public static void persistRichText(HttpServletRequest request) + public static void persistInSessionRichText(HttpServletRequest request) { String richTextOfflineInstructions=request.getParameter(RICHTEXT_OFFLINEINSTRUCTIONS); logger.debug("read parameter richTextOfflineInstructions: " + richTextOfflineInstructions); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r8f4ede3494f8c087de161a50616e511dd22d1605 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 8f4ede3494f8c087de161a50616e511dd22d1605) @@ -78,7 +78,7 @@ mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - McUtils.persistRichText(request); + McUtils.persistInSessionRichText(request); AuthoringUtil.populateParameters(request, mcAuthoringForm); } @@ -1597,22 +1597,162 @@ } logger.debug("questionFound: " + questionFound); - if (questionFound == true) + + logger.debug("will add this question to the the questionsMap:" + pairs.getKey().toString()); + mapUpdatedQuestionsContent.put(pairs.getKey().toString(), pairs.getValue().toString()); + + if (questionFound == false) { - logger.debug("will add this question to the the questionsMap:" + pairs.getKey().toString()); - mapUpdatedQuestionsContent.put(pairs.getKey().toString(), pairs.getValue().toString()); - } - else - { request.getSession().setAttribute(QUESTIONS_WITHNO_OPTIONS, new Boolean(true)); - logger.debug("setting QUESTIONS_WITHNO_OPTIONS to true."); + logger.debug("setting QUESTIONS_WITHNO_OPTIONS to true. using key: " + pairs.getKey().toString()); + addDefaultOptionsContentToQuestion(request, mapGeneralOptionsContent,pairs.getKey().toString()); } logger.debug("final mapUpdatedQuestionsContent:" + mapUpdatedQuestionsContent); } return mapUpdatedQuestionsContent; } + public static void addDefaultOptionsContentToQuestion(HttpServletRequest request, Map mapGeneralOptionsContent,String newKey) + { + logger.debug("doing addDefaultOptionsContentToQuestion with newKey:" + newKey); + logger.debug("mapGeneralOptionsContent:" + mapGeneralOptionsContent); + Map mapDefaultOptionsContent=(Map)request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT); + logger.debug("mapDefaultOptionsContent:" + mapDefaultOptionsContent); + mapGeneralOptionsContent.put(newKey, mapDefaultOptionsContent); + logger.debug("mapGeneralOptionsContent after put:" + mapGeneralOptionsContent); + } + + + public static Map addDefaultOptionsContentToMap(HttpServletRequest request, Map mapGO, Map mapQuestionsContent) + { + logger.debug("starting addDefaultOptionsContentToMap with map:" + mapGO); + + Map newMap= new TreeMap(new McComparator()); + Map mapDefaultOptionsContent=(Map)request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT); + logger.debug("mapDefaultOptionsContent:" + mapDefaultOptionsContent); + + boolean found=false; + Iterator itMap = mapQuestionsContent.entrySet().iterator(); + while (itMap.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + String localKey=(String)pairs.getKey(); + logger.debug("localKey: " + localKey); + + String question=(String)pairs.getValue(); + logger.debug("question: " + question); + + Iterator itGOMap = mapGO.entrySet().iterator(); + found=false; + Map generalMap=null; + while (itGOMap.hasNext()) + { + Map.Entry pairsGo = (Map.Entry)itGOMap.next(); + logger.debug("using the pairsGo: " + pairsGo.getKey() + " = " + pairsGo.getValue()); + String localGOKey=(String)pairsGo.getKey(); + logger.debug("localGOKey: " + localGOKey); + + if (localGOKey.equals(localKey)) + { + Map localMap=(Map)pairsGo.getValue(); + logger.debug("localMap: " + localMap); + generalMap=localMap; + + found=true; + break; + } + + } + + logger.debug("found: " + found); + logger.debug("generalMap: " + generalMap); + logger.debug("localKey: " + localKey); + + if (found == false) + { + newMap.put(localKey, mapDefaultOptionsContent); + } + else if (generalMap == null) + { + newMap.put(localKey, mapDefaultOptionsContent); + } + else + { + newMap.put(localKey, generalMap); + } + } + logger.debug("returning newMap: " + newMap); + return newMap; + } + + + + public static Map addDefaultSelectedOptionsContentToMap(HttpServletRequest request, Map mapGSO, Map mapQuestionsContent) + { + logger.debug("starting addDefaultSelectedOptionsContentToMap with map:" + mapGSO); + + Map newMap= new TreeMap(new McComparator()); + Map mapDefaultSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_DEFAULTSELECTEDOPTIONS_CONTENT); + logger.debug("mapDefaultSelectedOptionsContent:" + mapDefaultSelectedOptionsContent); + + boolean found=false; + Iterator itMap = mapQuestionsContent.entrySet().iterator(); + while (itMap.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + String localKey=(String)pairs.getKey(); + logger.debug("localKey: " + localKey); + + String question=(String)pairs.getValue(); + logger.debug("question: " + question); + + Iterator itGSOMap = mapGSO.entrySet().iterator(); + found=false; + Map generalMap=null; + while (itGSOMap.hasNext()) + { + Map.Entry pairsGSo = (Map.Entry)itGSOMap.next(); + logger.debug("using the pairsGSo: " + pairsGSo.getKey() + " = " + pairsGSo.getValue()); + String localGOKey=(String)pairsGSo.getKey(); + logger.debug("localGOKey: " + localGOKey); + + if (localGOKey.equals(localKey)) + { + Map localMap=(Map)pairsGSo.getValue(); + logger.debug("localMap: " + localMap); + generalMap=localMap; + + found=true; + break; + } + + } + + logger.debug("found: " + found); + logger.debug("generalMap: " + generalMap); + logger.debug("localKey: " + localKey); + + if (found == false) + { + newMap.put(localKey, mapDefaultSelectedOptionsContent); + } + else if (generalMap == null) + { + newMap.put(localKey, mapDefaultSelectedOptionsContent); + } + else + { + newMap.put(localKey, generalMap); + } + } + logger.debug("returning newMap: " + newMap); + return newMap; + } + + /** * * removes only unused question entries from the db. It keeps the valid entries since they get updated. @@ -1931,35 +2071,38 @@ public static void updateOrCreateOptions(HttpServletRequest request, Map mapSGO, Map mapGO, Map options, String questionIndex, Map mapGeneralSelectedOptionsContent) { logger.debug("doing updateOrCreateOptions..."); - Iterator itOptionsGoMap = mapGO.entrySet().iterator(); - boolean optionContentFound=false; - while (itOptionsGoMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itOptionsGoMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - optionContentFound = false; - Iterator itOptionsSGO = mapSGO.entrySet().iterator(); - while (itOptionsSGO.hasNext()) + if (mapGO != null) + { + Iterator itOptionsGoMap = mapGO.entrySet().iterator(); + boolean optionContentFound=false; + while (itOptionsGoMap.hasNext()) { - Map.Entry pairsSGO = (Map.Entry)itOptionsSGO.next(); - if (pairsSGO.getValue().equals(pairs.getValue())) - { - optionContentFound = true; - break; - } - } + Map.Entry pairs = (Map.Entry)itOptionsGoMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + optionContentFound = false; + Iterator itOptionsSGO = mapSGO.entrySet().iterator(); + while (itOptionsSGO.hasNext()) + { + Map.Entry pairsSGO = (Map.Entry)itOptionsSGO.next(); + if (pairsSGO.getValue().equals(pairs.getValue())) + { + optionContentFound = true; + break; + } + } - if (optionContentFound == false) - { - String optionText=pairs.getValue().toString(); - logger.debug("optionContentFound is false and option is: " + optionText); - if ((optionText != null) && (!optionText.equals(""))) - { - createOptionContent(request, options, optionText, questionIndex, mapGeneralSelectedOptionsContent); - } - } - } + if (optionContentFound == false) + { + String optionText=pairs.getValue().toString(); + logger.debug("optionContentFound is false and option is: " + optionText); + if ((optionText != null) && (!optionText.equals(""))) + { + createOptionContent(request, options, optionText, questionIndex, mapGeneralSelectedOptionsContent); + } + } + } + } } @@ -2204,10 +2347,16 @@ String incorrectFeedback=(String)mapFeedbackIncorrect.get(new Integer(displayOrder).toString()); logger.debug("new incorrectFeedback will be :" + incorrectFeedback); + + if ((incorrectFeedback == null) || (incorrectFeedback.equals(""))) + incorrectFeedback=DEFAULT_FEEDBACK_INCORRECT; String correctFeedback=(String)mapFeedbackCorrect.get(new Integer(displayOrder).toString()); logger.debug("new correctFeedback will be :" + correctFeedback); + if ((correctFeedback == null) || (correctFeedback.equals(""))) + correctFeedback=DEFAULT_FEEDBACK_CORRECT; + McQueContent mcQueContent= new McQueContent(question, new Integer(displayOrder), new Integer(weight), Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r8f4ede3494f8c087de161a50616e511dd22d1605 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 8f4ede3494f8c087de161a50616e511dd22d1605) @@ -555,7 +555,7 @@ Map mapIncorrectFeedback=new TreeMap(new McComparator()); Map mapCorrectFeedback=new TreeMap(new McComparator()); - logger.debug("getting feedback maps from cache:"); + logger.debug("getting feedback maps from cache, start using: feedback maps. "); mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); logger.debug("mapIncorrectFeedback:" + mapIncorrectFeedback); mapCorrectFeedback=(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); @@ -564,6 +564,7 @@ if (mapIncorrectFeedback != null) { + logger.debug("mapIncorrectFeedback, condition1 "); String incorrectFeedback=""; if (mapIncorrectFeedback.size() > 0) { @@ -576,6 +577,7 @@ if (mapCorrectFeedback != null) { + logger.debug("mapCorrectFeedback, condition2 "); String correctFeedback=""; if (mapCorrectFeedback.size() > 0) { @@ -792,6 +794,7 @@ } /* present the feedback content the same way for the conditions above*/ + logger.debug("present the feedback content the same way for the conditions above.."); String richTextFeedbackInCorrect=mcQueContent.getFeedbackIncorrect(); logger.debug("richTextFeedbackInCorrect: " + richTextFeedbackInCorrect); if (richTextFeedbackInCorrect == null) richTextFeedbackInCorrect=""; @@ -877,6 +880,22 @@ McUtils.debugMaps(request); logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); + + String richTextFeedbackInCorrect=(String) request.getSession().getAttribute(RICHTEXT_FEEDBACK_INCORRECT); + logger.debug("before forward2 richTextFeedbackInCorrect: " + richTextFeedbackInCorrect); + if ((richTextFeedbackInCorrect == null) || (richTextFeedbackInCorrect=="")) + { + request.getSession().setAttribute(RICHTEXT_INCORRECT_FEEDBACK,DEFAULT_FEEDBACK_INCORRECT); + } + + + String richTextFeedbackCorrect=(String) request.getSession().getAttribute(RICHTEXT_FEEDBACK_CORRECT); + logger.debug("before forward2 richTextFeedbackCorrect: " + richTextFeedbackCorrect); + if ((richTextFeedbackCorrect == null) || (richTextFeedbackCorrect=="")) + { + request.getSession().setAttribute(RICHTEXT_CORRECT_FEEDBACK,DEFAULT_FEEDBACK_CORRECT); + } + return true; } @@ -1448,7 +1467,7 @@ HttpServletResponse response, boolean defaultStarter) throws IOException, ServletException { - logger.debug("starting doneOptions..."); + logger.debug("starting performDoneOptions..."); logger.debug("using defaultStarter: " + defaultStarter); McUtils.cleanUpUserExceptions(request); request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); @@ -1571,6 +1590,8 @@ Map mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); logger.debug("mapIncorrectFeedback:" + mapIncorrectFeedback); + logger.debug("using feedback maps, condition 3"); + String richTextIncorrectFeedback=(String)request.getSession().getAttribute(RICHTEXT_INCORRECT_FEEDBACK); logger.debug("richTextIncorrectFeedback:" + richTextIncorrectFeedback); if (richTextIncorrectFeedback == null) richTextIncorrectFeedback=""; @@ -1736,6 +1757,15 @@ Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); + mapGeneralOptionsContent=AuthoringUtil.addDefaultOptionsContentToMap(request, mapGeneralOptionsContent, mapQuestionsContent); + logger.debug("mapGeneralOptionsContent after adding default options: " + mapGeneralOptionsContent); + + Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); + mapGeneralSelectedOptionsContent=AuthoringUtil.addDefaultSelectedOptionsContentToMap(request, mapGeneralSelectedOptionsContent, mapQuestionsContent); + logger.debug("mapGeneralSelectedOptionsContent after adding default options: " + mapGeneralSelectedOptionsContent); + request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT,mapGeneralSelectedOptionsContent); + + Boolean isRevisitingUser= (Boolean) request.getSession().getAttribute(IS_REVISITING_USER); logger.debug("isRevisitingUser: " + isRevisitingUser); @@ -1755,8 +1785,12 @@ logger.debug("remove from mapQuestionsContent the questions with no options"); /* remove from mapQuestionsContent the questions with no options */ - mapQuestionsContent=AuthoringUtil.updateQuestionsMapForNoOptions(request, mapQuestionsContent, mapTestableOptionsContent); + //mapQuestionsContent=AuthoringUtil.updateQuestionsMapForNoOptions(request, mapQuestionsContent, mapTestableOptionsContent); logger.debug("returned mapQuestionsContent: " + mapQuestionsContent); + logger.debug("assign mapGeneralOptionsContent post test: " + mapTestableOptionsContent); + mapGeneralOptionsContent=mapTestableOptionsContent; + logger.debug("using mapGeneralOptionsContent post test: " + mapGeneralOptionsContent); + request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); logger.debug("persisted MAP_QUESTIONS_CONTENT: " + mapQuestionsContent); @@ -1803,6 +1837,7 @@ } + logger.debug("mapWeights: " + mapWeights); boolean isTotalWeightsValid=AuthoringUtil.validateTotalWeight(mapWeights); logger.debug("isTotalWeightsValid:" + isTotalWeightsValid); if (isTotalWeightsValid == false) @@ -2097,7 +2132,7 @@ logger.debug("start processing options content..."); logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); + mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); logger.debug("mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); logger.debug("will refresh maps..."); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r8f4ede3494f8c087de161a50616e511dd22d1605 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 8f4ede3494f8c087de161a50616e511dd22d1605) @@ -687,6 +687,7 @@ List list=mcService.findMcOptionsContentByQueId(mcQueContent.getUid()); logger.debug("options list:" + list); + Map mapOptionsContent= new TreeMap(new McStringComparator()); Iterator listIterator=list.iterator(); Long mapIndex=new Long(1); @@ -700,8 +701,9 @@ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); Map mapDefaultOptionsContent=mapOptionsContent; request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptionsContent); + + logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); - logger.debug("starter initialized the Default Options Map: " + request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT)); Map mapWeights= new TreeMap(new McComparator()); long mapCounter=1; @@ -761,6 +763,17 @@ mapCheckBoxStates.put("2" ,"CORRECT"); request.getSession().setAttribute(MAP_CHECKBOX_STATES, mapCheckBoxStates); + + Map mapDefaultOptions= new TreeMap(new McComparator()); + mapDefaultOptions.put("2" ,DEFAULT_FIRST_OPTION); + mapDefaultOptions.put("2" ,DEFAULT_SELECTED_OPTION); + request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptions); + + + Map mapDefaultSelectedOptions= new TreeMap(new McComparator()); + mapDefaultSelectedOptions.put("1" ,DEFAULT_SELECTED_OPTION); + request.getSession().setAttribute(MAP_DEFAULTSELECTEDOPTIONS_CONTENT, mapDefaultSelectedOptions); + Map mapSelectedOptions= new TreeMap(new McComparator()); mapSelectedOptions.put("1",DEFAULT_SELECTED_OPTION); request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions);