Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -rb8f3c00f53850ba790f01edbc1bb56627d1520ed -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision b8f3c00f53850ba790f01edbc1bb56627d1520ed) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -249,6 +249,7 @@ public static final String OPTION_OFF ="false"; public static final String ACTIVITY_TITLE = "activityTitle"; public static final String ACTIVITY_INSTRUCTIONS = "activityInstructions"; + public static final String CORRECT = "Correct"; /* Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r525fef17717ea250350b7204056960f735ce02cb -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 525fef17717ea250350b7204056960f735ce02cb) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -324,24 +324,6 @@ String feedback=mcQueContent.getFeedback(); logger.debug("feedback:" + feedback); - /* - boolean isFeedbackTextMarkup=LearningUtil.isTextMarkup(feedback); - logger.debug("isFeedbackTextMarkup: " + isFeedbackTextMarkup); - - String newFeedbackText=feedback; - if (!isFeedbackTextMarkup) - { - newFeedbackText= LearningUtil.getWrappedText(feedback, false); - logger.debug("wrapped newFeedbackText: " + newFeedbackText); - } - logger.debug("post warp newFeedbackText: " + newFeedbackText); - - - newFeedbackText=McUtils.replaceNewLines(newFeedbackText); - logger.debug("newFeedbackText after procesing new lines: " + newFeedbackText); - */ - - map.put(mapIndex.toString(),feedback); mapIndex=new Long(mapIndex.longValue()+1); } @@ -352,7 +334,6 @@ - /** * builds a map to hold persisted uid values for questions * rebuildQuestionUidMapfromDB(HttpServletRequest request, Long toolContentId) @@ -580,7 +561,6 @@ } - logger.debug("final listFinalQuestionContentDTO:" + listFinalQuestionContentDTO); return listFinalQuestionContentDTO; } @@ -636,7 +616,6 @@ return listCandidates; } - List listFinalCandidateDTO=new LinkedList(); @@ -932,7 +911,6 @@ mcQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); mcQuestionContentDTO.setFeedback(feedback); mcQuestionContentDTO.setListCandidateAnswersDTO(caList); - //mcQuestionContentDTO.setCaCount(caList); logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); @@ -1675,11 +1653,7 @@ logger.debug("initialScreen: " + initialScreen); Map map= new TreeMap(new McComparator()); - - //if (initialScreen) - // return map; - String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); logger.debug("totalMark: " + totalMark); @@ -1733,26 +1707,6 @@ return map; } - /** - * Map buildPassMarkMap() - * - * @return - */ - /* - protected Map buildPassMarkMap() - { - Map map= new TreeMap(new McComparator()); - - map.put(new Integer(1).toString(), " "); - - for (int i=2; i <= 11 ; i++) - { - map.put(new Integer(i).toString(), new Integer(i-1).toString()); - } - logger.debug("return passmarks Map: " + map); - return map; - } - */ /** * Map buildCorrectMap() @@ -1762,7 +1716,6 @@ protected Map buildCorrectMap() { Map map= new TreeMap(new McComparator()); - map.put(new Integer(1).toString(), "Incorrect"); map.put(new Integer(2).toString(), "Correct"); logger.debug("return marks Map: " + map); return map; @@ -1780,23 +1733,45 @@ { logger.debug("doing repopulateCandidateAnswersBox, addBlankCa: " + addBlankCa); + String correct= request.getParameter("correct"); + logger.debug("correct: " + correct); + + + /* check this logic again*/ + int intCorrect=0; + if (correct == null) + { + logger.debug("correct is null: "); + } + else + { + intCorrect= new Integer(correct).intValue(); + } + + + logger.debug("intCorrect: " + intCorrect); + List listFinalCandidatesDTO=new LinkedList(); for (int i=0; i< MAX_OPTION_COUNT; i++) { String candidate= request.getParameter("ca" + i); logger.debug("candidate: " + candidate); - String correct= request.getParameter("correct" + i); - logger.debug("correct: " + correct); - + String isCorrect="Incorrect"; + logger.debug("i versus intCorrect: " + i + " versus " + intCorrect); + + if (i == intCorrect) + { + isCorrect="Correct"; + } + logger.debug("isCorrect: " + isCorrect); - //if ((candidate != null) && (candidate.length() > 0)) if (candidate != null) { McCandidateAnswersDTO mcCandidateAnswersDTO= new McCandidateAnswersDTO(); mcCandidateAnswersDTO.setCandidateAnswer(candidate); - mcCandidateAnswersDTO.setCorrect(correct); + mcCandidateAnswersDTO.setCorrect(isCorrect); listFinalCandidatesDTO.add(mcCandidateAnswersDTO); } } @@ -1812,8 +1787,44 @@ logger.debug("returning listFinalCandidatesDTO: " + listFinalCandidatesDTO); return listFinalCandidatesDTO; } + + + protected boolean validateCandidateAnswersNotBlank(HttpServletRequest request) + { + + for (int i=0; i< MAX_OPTION_COUNT; i++) + { + String candidate= request.getParameter("ca" + i); + logger.debug("candidate: " + candidate); + + if ((candidate != null) && (candidate.length() == 0)) + { + logger.debug("there is at least 1 blank candidate"); + return false; + } + } + return true; + } + + + + + protected List repopulateCandidateAnswersRadioBox(HttpServletRequest request, boolean addBlankCa) + { + logger.debug("doing repopulateCandidateAnswersRadioBox, addBlankCa: " + addBlankCa); + + String correct= request.getParameter("correct"); + logger.debug("correct: " + correct); + + List listFinalCandidatesDTO=new LinkedList(); + + logger.debug("returning listFinalCandidatesDTO: " + listFinalCandidatesDTO); + return listFinalCandidatesDTO; + } + + /** * boolean validateSingleCorrectCandidate(List caList) * @@ -1919,23 +1930,6 @@ String question=mcQueContent.getQuestion(); logger.debug("question: " + question); - - /* - boolean isTextMarkup=LearningUtil.isTextMarkup(question); - logger.debug("isTextMarkup: " + isTextMarkup); - - String newQuestionText=question; - if (!isTextMarkup) - { - newQuestionText= LearningUtil.getWrappedText(question, true); - logger.debug("wrapped newQuestionText: " + newQuestionText); - } - logger.debug("post warp newQuestionText: " + newQuestionText); - - - newQuestionText=McUtils.replaceNewLines(newQuestionText); - logger.debug("newQuestionText after procesing new lines: " + newQuestionText); - */ mcQuestionContentDTO.setQuestion(question); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -511,6 +511,11 @@ AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -529,9 +534,10 @@ ActionMessages errors = new ActionMessages(); - if (caList.size() == 0) + + if (!validateCandidateAnswersNotBlank) { - ActionMessage error = new ActionMessage("candidates.none.provided"); + ActionMessage error = new ActionMessage("candidates.blank"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } @@ -942,7 +948,11 @@ logger.debug("passmark: " + passmark); mcGeneralAuthoringDTO.setPassMarkValue(passmark); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -961,10 +971,9 @@ ActionMessages errors = new ActionMessages(); - - if (caList.size() == 0) + if (!validateCandidateAnswersNotBlank) { - ActionMessage error = new ActionMessage("candidates.none.provided"); + ActionMessage error = new ActionMessage("candidates.blank"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } @@ -2738,6 +2747,26 @@ logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -2746,43 +2775,47 @@ logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - String editableQuestion=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); - String question=mcQuestionContentDTO.getQuestion(); - String displayOrder=mcQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - logger.debug("displayOrder equals questionIndex :" + questionIndex); - editableQuestion=mcQuestionContentDTO.getQuestion(); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - - break; - } - - } - } + + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + + break; + } + + } + } + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); + } - logger.debug("candidates found :" + candidates); - logger.debug("swapped candidates is :" + listCandidates); logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); @@ -2964,6 +2997,25 @@ mcAuthoringForm.setCandidateIndex(candidateIndex); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -2972,47 +3024,50 @@ logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - String editableQuestion=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); - String question=mcQuestionContentDTO.getQuestion(); - String displayOrder=mcQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - logger.debug("displayOrder equals questionIndex :" + questionIndex); - editableQuestion=mcQuestionContentDTO.getQuestion(); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - - logger.debug("using repopulated caList:" + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); - logger.debug("swapped candidates :" + listCandidates); - - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - mcQuestionContentDTO.setCaCount(new Integer(listCandidates.size()).toString()); - - break; - } - - } - } + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + + logger.debug("using repopulated caList:" + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); + logger.debug("swapped candidates :" + listCandidates); + + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + mcQuestionContentDTO.setCaCount(new Integer(listCandidates.size()).toString()); + + break; + } + + } + } - logger.debug("candidates found :" + candidates); - logger.debug("swapped candidates is :" + listCandidates); + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); + } + logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); @@ -3815,6 +3870,24 @@ mcAuthoringForm.setCandidateIndex(candidateIndex); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -3829,26 +3902,31 @@ logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - - Iterator listIterator=listAddableQuestionContentDTO.iterator(); - /*there is only 1 question dto*/ - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - } + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + + Iterator listIterator=listAddableQuestionContentDTO.iterator(); + /*there is only 1 question dto*/ + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + } + } + + logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: " + listAddableQuestionContentDTO); request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); @@ -4012,6 +4090,25 @@ logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -4024,27 +4121,30 @@ List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); - - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - - Iterator listIterator=listAddableQuestionContentDTO.iterator(); - /*there is only 1 question dto*/ - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - } + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + + Iterator listIterator=listAddableQuestionContentDTO.iterator(); + /*there is only 1 question dto*/ + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + } + } + logger.debug("listAddableQuestionContentDTO after moving down candidates: "); request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -1245,13 +1245,6 @@ ActionMessages errors = new ActionMessages(); - if (caList.size() == 0) - { - ActionMessage error = new ActionMessage("candidates.none.provided"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - - if (!validateSingleCorrectCandidate) { ActionMessage error = new ActionMessage("candidates.none.correct"); @@ -1654,13 +1647,7 @@ ActionMessages errors = new ActionMessages(); - if (caList.size() == 0) - { - ActionMessage error = new ActionMessage("candidates.none.provided"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); - } - if (!validateSingleCorrectCandidate) { ActionMessage error = new ActionMessage("candidates.none.correct"); @@ -2656,51 +2643,72 @@ logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - String editableQuestion=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) + if (errors.isEmpty()) { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); - String question=mcQuestionContentDTO.getQuestion(); - String displayOrder=mcQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - logger.debug("displayOrder equals questionIndex :" + questionIndex); - editableQuestion=mcQuestionContentDTO.getQuestion(); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - - break; - } - - } + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + + break; + } + + } + } + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); } - logger.debug("candidates found :" + candidates); - logger.debug("swapped candidates is :" + listCandidates); logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); @@ -2858,6 +2866,25 @@ mcAuthoringForm.setCandidateIndex(candidateIndex); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -2866,47 +2893,50 @@ logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - String editableQuestion=""; - Iterator listIterator=listQuestionContentDTO.iterator(); - while (listIterator.hasNext()) + if (errors.isEmpty()) { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); - String question=mcQuestionContentDTO.getQuestion(); - String displayOrder=mcQuestionContentDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) - { - if (displayOrder.equals(questionIndex)) - { - logger.debug("displayOrder equals questionIndex :" + questionIndex); - editableQuestion=mcQuestionContentDTO.getQuestion(); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - - logger.debug("using repopulated caList:" + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); - logger.debug("swapped candidates :" + listCandidates); - - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - mcQuestionContentDTO.setCaCount(new Integer(listCandidates.size()).toString()); - - break; - } - - } + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + + logger.debug("using repopulated caList:" + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); + logger.debug("swapped candidates :" + listCandidates); + + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + mcQuestionContentDTO.setCaCount(new Integer(listCandidates.size()).toString()); + + break; + } + + } + } + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); } + - logger.debug("candidates found :" + candidates); - logger.debug("swapped candidates is :" + listCandidates); logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); @@ -3485,6 +3515,24 @@ mcAuthoringForm.setCandidateIndex(candidateIndex); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -3498,26 +3546,28 @@ List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); - - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - - Iterator listIterator=listAddableQuestionContentDTO.iterator(); - /*there is only 1 question dto*/ - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - } + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + + Iterator listIterator=listAddableQuestionContentDTO.iterator(); + /*there is only 1 question dto*/ + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + } + } logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: " + listAddableQuestionContentDTO); request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); @@ -3659,6 +3709,24 @@ logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); + + boolean validateCandidateAnswersNotBlank =authoringUtil.validateCandidateAnswersNotBlank(request); + logger.debug("validateCandidateAnswersNotBlank: " + validateCandidateAnswersNotBlank); + + ActionMessages errors = new ActionMessages(); + + if (!validateCandidateAnswersNotBlank) + { + ActionMessage error = new ActionMessage("candidates.blank"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); @@ -3672,25 +3740,29 @@ logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); - List candidates =new LinkedList(); - List listCandidates =new LinkedList(); - - Iterator listIterator=listAddableQuestionContentDTO.iterator(); - /*there is only 1 question dto*/ - while (listIterator.hasNext()) - { - McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); - logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); - - candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); - logger.debug("candidates found :" + candidates); - logger.debug("but we are using the repopulated caList here: " + caList); - - listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); - logger.debug("swapped candidates :" + listCandidates); - - mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); - } + if (errors.isEmpty()) + { + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + + Iterator listIterator=listAddableQuestionContentDTO.iterator(); + /*there is only 1 question dto*/ + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + } + } + logger.debug("listAddableQuestionContentDTO after moving down candidates: "); request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); Index: lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp =================================================================== diff -u -r525fef17717ea250350b7204056960f735ce02cb -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) +++ lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -41,6 +41,25 @@ + + + + + + + + + + + + + + + + + + + @@ -55,25 +74,24 @@ value="${currentCandidateDTO.candidateAnswer}" size="50"> - + - - " > - + @@ -110,7 +128,7 @@ images/delete.gif" border="0" title="" - onclick="removeAddedCandidate(${caIndex});"> + onclick=" if (validateMinumumCandidateCount()) { removeAddedCandidate(${caIndex}); } "> Index: lams_tool_lamc/web/authoring/candidateAnswersList.jsp =================================================================== diff -u -r525fef17717ea250350b7204056960f735ce02cb -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) +++ lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -18,6 +18,7 @@ http://www.gnu.org/licenses/gpl.txt --%> + <%@ include file="/common/taglibs.jsp"%> @@ -32,7 +33,25 @@ + + + + + + + + + + + + @@ -60,26 +79,22 @@ value="${currentCandidateDTO.candidateAnswer}" size="50"> - Index: lams_tool_lamc/web/authoring/editQuestionBox.jsp =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -72,7 +72,7 @@ function validateDuplicateCorrectAnswers() { var correctCount = 0; - for(i = 1; i < 51; i++) + for(i = 0; i < 51; i++) { var currentId="select".concat(i) var currentField=document.getElementById(currentId); @@ -97,7 +97,87 @@ } return true; } - + + + function validateSingleCorrectAnswer() + { + var singleCorrectEntry = 0; + var radioCorrect=document.McAuthoringForm.correct; + + if ((radioCorrect == 'null') || (radioCorrect == 'undefined')) + { + var msg = ""; + alert(msg); + return false; + } + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize < 2)) + { + var msg = ""; + alert(msg); + return false; + } + + + for(i = 0; i < 51; i++) + { + if (radioCorrect[i] != null) + { + if ((typeof(radioCorrect[i]) != 'undefined') && (typeof(radioCorrect[i]) != null)) + { + if (radioCorrect[i].checked) + { + singleCorrectEntry =1; + } + } + } + } + + if (singleCorrectEntry == 0) + { + var msg = ""; + var msgSetFirst = ""; + + alert(msg); + + if ((radioCorrect[0] != 'undefined') && (radioCorrect[0] != null)) + { + radioCorrect[0].checked=true; + alert(msgSetFirst); + } + + return false; + } + return true; + } + + + function validateMinumumCandidateCount() + { + var radioCorrect=document.McAuthoringForm.correct; + + if ((radioCorrect == 'undefined') || (radioCorrect == null)) + { + var msg = ""; + alert(msg); + return false; + } + + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize <= 2)) + { + var msg = ""; + alert(msg); + return false; + } + + return true; + } + @@ -161,7 +241,7 @@
- Index: lams_tool_lamc/web/authoring/newQuestionBox.jsp =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -80,6 +80,84 @@ return true; } + + function validateSingleCorrectAnswer() + { + var singleCorrectEntry = 0; + var radioCorrect=document.McAuthoringForm.correct; + + if ((radioCorrect == 'null') || (radioCorrect == 'undefined')) + { + var msg = ""; + alert(msg); + return false; + } + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize < 2)) + { + var msg = ""; + alert(msg); + return false; + } + + + for(i = 0; i < 51; i++) + { + if (radioCorrect[i] != null) + { + if ((typeof(radioCorrect[i]) != 'undefined') && (typeof(radioCorrect[i]) != null)) + { + if (radioCorrect[i].checked) + { + singleCorrectEntry =1; + } + } + } + } + + if (singleCorrectEntry == 0) + { + var msg = ""; + var msgSetFirst = ""; + alert(msg); + + if ((radioCorrect[0] != 'undefined') && (radioCorrect[0] != null)) + { + radioCorrect[0].checked=true; + alert(msgSetFirst); + } + + return false; + } + return true; + } + + + function validateMinumumCandidateCount() + { + var radioCorrect=document.McAuthoringForm.correct; + + if ((radioCorrect == 'undefined') || (radioCorrect == null)) + { + var msg = ""; + alert(msg); + return false; + } + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize <= 2)) + { + var msg = ""; + alert(msg); + return false; + } + + return true; + } + @@ -140,7 +218,7 @@
- Index: lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp =================================================================== diff -u -r525fef17717ea250350b7204056960f735ce02cb -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) +++ lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -43,6 +43,24 @@ + +
+ + + + + + + + + + @@ -56,23 +74,24 @@ - - - + + Index: lams_tool_lamc/web/monitoring/candidateAnswersList.jsp =================================================================== diff -u -r525fef17717ea250350b7204056960f735ce02cb -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/monitoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) +++ lams_tool_lamc/web/monitoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -50,6 +50,26 @@ + + + + + + + + + + + + + + @@ -63,23 +83,24 @@ - - + + + Index: lams_tool_lamc/web/monitoring/editQuestionBox.jsp =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -80,7 +80,86 @@ } return true; } + + function validateSingleCorrectAnswer() + { + var singleCorrectEntry = 0; + var radioCorrect=document.McMonitoringForm.correct; + + if ((radioCorrect == 'null') || (radioCorrect == 'undefined')) + { + var msg = ""; + alert(msg); + return false; + } + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize < 2)) + { + var msg = ""; + alert(msg); + return false; + } + + + for(i = 0; i < 51; i++) + { + if (radioCorrect[i] != null) + { + if ((typeof(radioCorrect[i]) != 'undefined') && (typeof(radioCorrect[i]) != null)) + { + if (radioCorrect[i].checked) + { + singleCorrectEntry =1; + } + } + } + } + + if (singleCorrectEntry == 0) + { + var msg = ""; + var msgSetFirst = ""; + alert(msg); + + if ((radioCorrect[0] != 'undefined') && (radioCorrect[0] != null)) + { + radioCorrect[0].checked=true; + alert(msgSetFirst); + } + + return false; + } + return true; + } + + + function validateMinumumCandidateCount() + { + var radioCorrect=document.McMonitoringForm.correct; + + if ((radioCorrect == 'undefined') || (radioCorrect == null)) + { + var msg = ""; + alert(msg); + return false; + } + + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize <= 2)) + { + var msg = ""; + alert(msg); + return false; + } + + return true; + } + @@ -173,7 +252,7 @@
+ + + + + +
+ - - " > - - @@ -116,7 +131,9 @@ images/delete.gif" border="0" title="" - onclick="removeCandidate(${queIndex}, ${caIndex});"> + onclick=" if (validateMinumumCandidateCount()) {removeCandidate(${queIndex}, ${caIndex});} "> + +
+ + + + + +
+ + + + + + + + + - + " > + + + @@ -103,10 +122,12 @@ - + images/delete.gif" border="0"> -
+ + + + + +
+ + + + + + + + + - - + " > + + @@ -110,10 +131,12 @@ - + images/delete.gif" border="0"> -
Index: lams_tool_lamc/web/monitoring/newQuestionBox.jsp =================================================================== diff -u -r9dc619c585fbef88eb9340bd68dd8137298b3129 -r2bd6155d7fad435e1238088f98650b0ec731d0f1 --- lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 9dc619c585fbef88eb9340bd68dd8137298b3129) +++ lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 2bd6155d7fad435e1238088f98650b0ec731d0f1) @@ -78,6 +78,84 @@ } return true; } + + function validateSingleCorrectAnswer() + { + var singleCorrectEntry = 0; + var radioCorrect=document.McMonitoringForm.correct; + + if ((radioCorrect == 'null') || (radioCorrect == 'undefined')) + { + var msg = ""; + alert(msg); + return false; + } + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize < 2)) + { + var msg = ""; + alert(msg); + return false; + } + + + for(i = 0; i < 51; i++) + { + if (radioCorrect[i] != null) + { + if ((typeof(radioCorrect[i]) != 'undefined') && (typeof(radioCorrect[i]) != null)) + { + if (radioCorrect[i].checked) + { + singleCorrectEntry =1; + } + } + } + } + + if (singleCorrectEntry == 0) + { + var msg = ""; + var msgSetFirst = ""; + alert(msg); + + if ((radioCorrect[0] != 'undefined') && (radioCorrect[0] != null)) + { + radioCorrect[0].checked=true; + alert(msgSetFirst); + } + + return false; + } + return true; + } + + + function validateMinumumCandidateCount() + { + var radioCorrect=document.McMonitoringForm.correct; + + if ((radioCorrect == 'undefined') || (radioCorrect == null)) + { + var msg = ""; + alert(msg); + return false; + } + + + var radioGroupSize=radioCorrect.length; + + if ((radioGroupSize == 'undefined') || (radioGroupSize <= 2)) + { + var msg = ""; + alert(msg); + return false; + } + + return true; + } @@ -171,7 +249,7 @@
                     -
                     -