Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -r735c5db341aaba22874662bf7e44ec91a24424c7 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 735c5db341aaba22874662bf7e44ec91a24424c7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -126,7 +126,10 @@ public static final String MAP_DEFAULTOPTIONS_CONTENT ="mapDefaultOptionsContent"; public static final String MAP_DISABLED_QUESTIONS ="mapDisabledQuestions"; 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 SELECTED_QUESTION_CONTENT_UID ="selectedQuestionContentUid"; public static final String SELECTED_QUESTION ="selectedQuestion"; public static final String SELECTED_QUESTION_INDEX ="selectedQuestionIndex"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties =================================================================== diff -u -r3ac967a36c1e5841b515192a57c717f332dc3bb6 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 3ac967a36c1e5841b515192a57c717f332dc3bb6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -33,6 +33,8 @@ label.option1 =Option 1 label.options =Options label.option.correct =Correct +label.candidateAnswers =Candidate Answers +label.isCorrect =Correct? label.report.title =Report Title label.monitoringReport.title =Monitoring Report Title @@ -64,6 +66,7 @@ feedback =Please address the following issues before submit.
error.weights.empty =Please correct this: The question weights can not be empty. +error.checkBoxes.empty =Please correct this: No candidate answer has been selected. error.weights.notInteger =Please correct this: The question weights must be an integer. error.emptyQuestion =Please enter the question text. The chosen question can not be empty. error.title =Please correct this: The field "Title" is mandatory.
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java =================================================================== diff -u -r8742c4d01b2ac066988448e0c64d76998d5f4f5b -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision 8742c4d01b2ac066988448e0c64d76998d5f4f5b) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -40,6 +40,8 @@ public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid); + public List getPersistedSelectedOptions(Long mcQueContentId); + public void saveMcOptionsContent(McOptsContent mcOptionsContent); public void updateMcOptionsContent(McOptsContent mcOptionsContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java =================================================================== diff -u -r8742c4d01b2ac066988448e0c64d76998d5f4f5b -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 8742c4d01b2ac066988448e0c64d76998d5f4f5b) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -49,6 +49,8 @@ private static final String LOAD_OPTION_CONTENT_BY_OPTION_TEXT = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueOptionText=:option and mcOptsContent.mcQueContentId=:mcQueContentUid"; + private static final String LOAD_PERSISTED_SELECTED_OPTIONS = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueContentId=:mcQueContentUid and mcOptsContent.correctOption = 1"; + public McOptsContent getMcOptionsContentByUID(Long uid) { return (McOptsContent) this.getHibernateTemplate() @@ -84,6 +86,16 @@ return null; } + + public List getPersistedSelectedOptions(Long mcQueContentId) + { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_PERSISTED_SELECTED_OPTIONS) + .setLong("mcQueContentUid", mcQueContentId.longValue()) + .list(); + + return list; + } public void saveMcOptionsContent(McOptsContent mcOptsContent) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r735c5db341aaba22874662bf7e44ec91a24424c7 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 735c5db341aaba22874662bf7e44ec91a24424c7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -89,6 +89,8 @@ public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid); + public List getPersistedSelectedOptions(Long mcQueContentId); + public List getAllQuestionEntries(final Long mcContentId) throws McApplicationException; public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -r735c5db341aaba22874662bf7e44ec91a24424c7 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 735c5db341aaba22874662bf7e44ec91a24424c7) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -391,7 +391,23 @@ } } + public List getPersistedSelectedOptions(Long mcQueContentId) throws McApplicationException + { + try + { + return mcOptionsContentDAO.getPersistedSelectedOptions(mcQueContentId); + } + catch (DataAccessException e) + { + throw new McApplicationException("Exception occured when lams is gettong persisted selected" + + " the mc options content: " + + e.getMessage(),e); + } + + } + + public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentId) { try Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r8e5bcd24456af53095d2bd8619aa6808ae5e8b17 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 8e5bcd24456af53095d2bd8619aa6808ae5e8b17) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -330,7 +330,7 @@ userAction="editOption"; request.setAttribute(USER_ACTION, userAction); logger.debug("userAction:" + userAction); - + Map mapQuestionsContent=repopulateMap(request, "questionContent"); logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); @@ -406,6 +406,26 @@ request.getSession().setAttribute(SELECTED_QUESTION_CONTENT_UID, mcQueContent.getUid() ); logger.debug("SELECTED_QUESTION_CONTENT_UID:" + request.getSession().getAttribute(SELECTED_QUESTION_CONTENT_UID)); + + Map mapSelectedOptions= (Map) request.getSession().getAttribute(MAP_SELECTED_OPTIONS); + mapSelectedOptions.clear(); + + List listSelectedOptions=mcService.getPersistedSelectedOptions(mcQueContent.getUid()); + logger.debug("listSelectedOptions:" + listSelectedOptions); + + Iterator listIteratorSelectedOptions=listSelectedOptions.iterator(); + Long mapIndex=new Long(1); + while (listIteratorSelectedOptions.hasNext()) + { + McOptsContent mcOptsContent=(McOptsContent)listIteratorSelectedOptions.next(); + logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); + mapSelectedOptions.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); + mapIndex=new Long(mapIndex.longValue()+1); + } + request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); + logger.debug("persisted SELECTED MAP_SELECTED_OPTIONS:" + request.getSession().getAttribute(MAP_SELECTED_OPTIONS)); + + request.getSession().setAttribute(SELECTED_QUESTION_INDEX, questionIndex); logger.debug("SELECTED_QUESTION_INDEX:" + request.getSession().getAttribute(SELECTED_QUESTION_INDEX)); @@ -428,7 +448,7 @@ { logger.debug("not an empty options list"); Iterator listIterator=list.iterator(); - Long mapIndex=new Long(1); + mapIndex=new Long(1); while (listIterator.hasNext()) { McOptsContent mcOptsContent=(McOptsContent)listIterator.next(); @@ -548,40 +568,27 @@ userAction="doneOptions"; request.setAttribute(USER_ACTION, userAction); logger.debug("userAction:" + userAction); - - String selectedIndex=mcAuthoringForm.getSelectedIndex(); - logger.debug("selectedIndex:" + selectedIndex); + + boolean validateOptions=validateOptions(request); + logger.debug("validateOptions:" + validateOptions); - if ((selectedIndex == null) || (selectedIndex.equals(""))) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.selectedIndex.empty")); - logger.debug("add error.selectedIndex.empty to ActionMessages"); + if (validateOptions == false) + { + ActionMessages errors= new ActionMessages(); + errors.add(Globals.ERROR_KEY,new ActionMessage("error.checkBoxes.empty")); + logger.debug("add error.checkBoxes.empty to ActionMessages"); saveErrors(request,errors); mcAuthoringForm.resetUserAction(); logger.debug("return to EDIT_OPTS_CONTENT to fix error."); - return (mapping.findForward(EDIT_OPTS_CONTENT)); - } - - String parameterType="optionContent"; - long mapCounter=0; - String selectedAnswer=null; - for (long i=1; i <= MAX_OPTION_COUNT ; i++) - { - if (selectedIndex.equals(new Long(i).toString())) - { - selectedAnswer=request.getParameter(parameterType + i); - logger.debug("found selectedAnswer: " + selectedAnswer); - } - } - - Long selectedQuestionContentUid=(Long)request.getSession().getAttribute(SELECTED_QUESTION_CONTENT_UID); + return (mapping.findForward(EDIT_OPTS_CONTENT)); + } + + Long selectedQuestionContentUid=(Long)request.getSession().getAttribute(SELECTED_QUESTION_CONTENT_UID); logger.debug("selectedQuestionContentUid:" + selectedQuestionContentUid); - + selectedQuestion=(String) request.getSession().getAttribute(SELECTED_QUESTION); logger.debug("final selectedQuestion:" + selectedQuestion); - /** make the particular question content in the main page disabled for user access*/ McQueContent mcQueContent = mcService.retrieveMcQueContentByUID(selectedQuestionContentUid); logger.debug("mcQueContent:" + mcQueContent); @@ -593,52 +600,47 @@ request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); logger.debug("updated MAP_QUESTIONS_CONTENT with the changed question:" + mapQuestionsContent); - - /** parse all the options and persist them */ - Map mapOptionsContent=repopulateMap(request,"optionContent"); - logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); - logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size()); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); - mcService.removeMcOptionsContentByQueId(selectedQuestionContentUid); logger.debug("removed all mcOptionsContents for mcQueContentId :" + selectedQuestionContentUid); - if (mcQueContent != null) - { - /** iterate the options Map and persist the options into the DB*/ - Iterator itOptionsMap = mapOptionsContent.entrySet().iterator(); - while (itOptionsMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itOptionsMap.next(); - logger.debug("adding the pair: " + pairs.getKey() + " = " + pairs.getValue()); - if ((pairs.getValue() != null) && (!pairs.getValue().equals(""))) - { - McOptsContent mcOptionsContent= new McOptsContent(false,pairs.getValue().toString() , mcQueContent, new HashSet()); - logger.debug("created mcOptionsContent: " + mcOptionsContent); - mcService.saveMcOptionsContent(mcOptionsContent); - logger.debug("persisted the answer: " + pairs.getValue().toString()); - } - } - } - logger.debug("doneOptions persists all the options"); - - if (selectedAnswer != null && selectedAnswer.length() > 0) + + String isCheckBoxSelected=null; + boolean isCorrect=false; + for (int i=1; i <= MAX_OPTION_COUNT ; i++) { - logger.debug("update the record for the correct option."); - McOptsContent mcOptsContent=mcService.getOptionContentByOptionText(selectedAnswer, selectedQuestionContentUid); - logger.debug("found mcOptsContent to be updated " + mcOptsContent); - - if (mcOptsContent != null) - { - logger.debug("found mcOptsContent is correctOption" + mcOptsContent.isCorrectOption()); - mcOptsContent.setCorrectOption(true); - mcService.updateMcOptionsContent(mcOptsContent); - logger.debug("persisted the updated mcOptsContent" + mcOptsContent); - logger.debug("updated mcOptsContent isCorrect?" + mcOptsContent.isCorrectOption()); - } + isCorrect=false; + isCheckBoxSelected=request.getParameter("checkBoxSelected" + i); + logger.debug("isCheckBoxSelected: " + isCheckBoxSelected); + String selectedIndex=null; + + if (isCheckBoxSelected != null) + { + if (isCheckBoxSelected.equals("Correct")) + { + isCorrect=true; + } + + logger.debug("looped isCorrect: " + isCorrect); + logger.debug("looped selectedIndex: " + i); + + long mapCounter=0; + String selectedAnswer=null; + selectedAnswer=request.getParameter("optionContent" + i); + logger.debug("found selectedAnswer: " + selectedAnswer); + + Map mapOptionsContent=repopulateMap(request,"optionContent"); + logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); + logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size()); + request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); + logger.debug("Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + + McOptsContent mcOptionsContent= new McOptsContent(isCorrect,selectedAnswer , mcQueContent, new HashSet()); + logger.debug("created mcOptionsContent: " + mcOptionsContent); + mcService.saveMcOptionsContent(mcOptionsContent); + logger.debug("final persistance of option"); + } } - mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } @@ -1239,37 +1241,58 @@ McContent mcContent=mcService.retrieveMc(toolContentId); logger.debug("mcContent:" + mcContent); - List allQuestions=mcService.getAllQuestionEntries(mcContent.getUid()); - logger.debug("allQuestions:" + allQuestions); - - Iterator listIterator=allQuestions.iterator(); - - while (listIterator.hasNext()) + if (mcContent != null) + { + List allQuestions=mcService.getAllQuestionEntries(mcContent.getUid()); + logger.debug("allQuestions:" + allQuestions); + + Iterator listIterator=allQuestions.iterator(); + + while (listIterator.hasNext()) + { + McQueContent mcQueContent=(McQueContent)listIterator.next(); + logger.debug("mcQueContent:" + mcQueContent); + + Iterator itQuestionsMap = mapQuestionsContent.entrySet().iterator(); + boolean matchFound=false; + while (itQuestionsMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itQuestionsMap.next(); + logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue().toString().equals(mcQueContent.getQuestion())) + { + logger.debug("match found the pair: " + pairs.getValue().toString()); + matchFound=true; + } + } + + if (matchFound == false) + { + mcService.removeMcQueContent(mcQueContent); + logger.debug("removed mcQueContent: " + mcQueContent); + } + } + } + } + + protected boolean validateOptions(HttpServletRequest request) + { + logger.debug("will validateOptions"); + String parameterType="checkBoxSelected"; + for (int i=1; i <= MAX_OPTION_COUNT ; i++) { - McQueContent mcQueContent=(McQueContent)listIterator.next(); - logger.debug("mcQueContent:" + mcQueContent); + String isCorrect=request.getParameter(parameterType + i); + logger.debug("isCorrect: " + isCorrect); - Iterator itQuestionsMap = mapQuestionsContent.entrySet().iterator(); - boolean matchFound=false; - while (itQuestionsMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itQuestionsMap.next(); - logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue().toString().equals(mcQueContent.getQuestion())) - { - logger.debug("match found the pair: " + pairs.getValue().toString()); - matchFound=true; - } - } - - if (matchFound == false) - { - mcService.removeMcQueContent(mcQueContent); - logger.debug("removed mcQueContent: " + mcQueContent); - } + if (isCorrect != null) + { + if (isCorrect.equals("Correct")) + return true; + } } - + return false; } + protected boolean validateQuestionWeights(HttpServletRequest request, McAuthoringForm mcAuthoringForm) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u -r3ac967a36c1e5841b515192a57c717f332dc3bb6 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 3ac967a36c1e5841b515192a57c717f332dc3bb6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -116,7 +116,16 @@ Map mapWeights= new TreeMap(new McComparator()); request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - + + Map mapCheckBoxStates= new TreeMap(new McComparator()); + mapCheckBoxStates.put("1" ,"INCORRECT"); + mapCheckBoxStates.put("2" ,"CORRECT"); + request.getSession().setAttribute(MAP_CHECKBOX_STATES, mapCheckBoxStates); + + Map mapSelectedOptions= new TreeMap(new McComparator()); + request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); + + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; mcAuthoringForm.resetRadioBoxes(); Index: lams_tool_lamc/web/authoringMaincontent.jsp =================================================================== diff -u -r8e5bcd24456af53095d2bd8619aa6808ae5e8b17 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 8e5bcd24456af53095d2bd8619aa6808ae5e8b17) +++ lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -131,13 +131,13 @@ -

+
-

+
-

+
Index: lams_tool_lamc/web/editOptionsContent.jsp =================================================================== diff -u -rdef7c02eeb52a92c47c04b3f21fe337350aef897 -re8526e7f760e36faf92d8c56da58cf04d7e2b3db --- lams_tool_lamc/web/editOptionsContent.jsp (.../editOptionsContent.jsp) (revision def7c02eeb52a92c47c04b3f21fe337350aef897) +++ lams_tool_lamc/web/editOptionsContent.jsp (.../editOptionsContent.jsp) (revision e8526e7f760e36faf92d8c56da58cf04d7e2b3db) @@ -102,7 +102,7 @@
- + + + + + + + + - + + + + + + + + + + + + + - @@ -144,26 +178,47 @@ " value="" size="50" maxlength="255"> + +\ + + + + + + + + + + + - + "> - -
+ : @@ -116,24 +116,58 @@
+
+
+
+
+
+
+ " value="" size="50" maxlength="255"> + + + + - ;"> -
+ + + + - ;"> -
+   
+ @@ -207,6 +262,21 @@

+ + +