Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -rc4892b09d93fd9811095b7b24ede460121832159 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision c4892b09d93fd9811095b7b24ede460121832159) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -1836,15 +1836,47 @@ if (correct.equals("Correct")) { - logger.debug("there is at leat one Correct candidate, it is good."); + logger.debug("there is at least one Correct candidate, it is good."); return true; } } return false; } + + protected boolean validateOnlyOneCorrectCandidate(List caList) + { + int correctCandidatesCount= 0; + + Iterator itCaList= caList.iterator(); + while (itCaList.hasNext()) + { + McCandidateAnswersDTO mcCandidateAnswersDTO= (McCandidateAnswersDTO)itCaList.next(); + logger.debug("mcCandidateAnswersDTO:" + mcCandidateAnswersDTO); + + String candidateAnswer= mcCandidateAnswersDTO.getCandidateAnswer(); + String correct= mcCandidateAnswersDTO.getCorrect(); + logger.debug("correct:" + correct); + + if (correct.equals("Correct")) + { + logger.debug("there is at leat one Correct candidate, it is good."); + ++correctCandidatesCount; + } + } + logger.debug("correctCandidatesCount: " + correctCandidatesCount); + + if (correctCandidatesCount > 1) + return false; //not good + + return true; + } + + + + /** * buildDefaultQuestionContent(McContent mcContent, IMcService mcService) * Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r993fec58a7198f31f151cf47d6ba331148ce4fae -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -521,10 +521,14 @@ boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); + /* + boolean validateOnlyOneCorrectCandidate=authoringUtil.validateOnlyOneCorrectCandidate(caList); + logger.debug("validateOnlyOneCorrectCandidate: " + validateOnlyOneCorrectCandidate); + */ + ActionMessages errors = new ActionMessages(); - if (caList.size() == 0) { ActionMessage error = new ActionMessage("candidates.none.provided"); @@ -537,6 +541,16 @@ ActionMessage error = new ActionMessage("candidates.none.correct"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } + + /* + if (!validateOnlyOneCorrectCandidate) + { + ActionMessage error = new ActionMessage("candidates.duplicate.correct"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + */ + + logger.debug("errors: " + errors); if(!errors.isEmpty()){ @@ -941,6 +955,11 @@ boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); + /* + boolean validateOnlyOneCorrectCandidate=authoringUtil.validateOnlyOneCorrectCandidate(caList); + logger.debug("validateOnlyOneCorrectCandidate: " + validateOnlyOneCorrectCandidate); + */ + ActionMessages errors = new ActionMessages(); @@ -957,6 +976,15 @@ ActionMessage error = new ActionMessage("candidates.none.correct"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } + + /* + if (!validateOnlyOneCorrectCandidate) + { + ActionMessage error = new ActionMessage("candidates.duplicate.correct"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + */ + logger.debug("errors: " + errors); if(!errors.isEmpty()){ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java =================================================================== diff -u -r993fec58a7198f31f151cf47d6ba331148ce4fae -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -121,6 +121,7 @@ private String feedback; private String candidateIndex; private String totalMarks; + protected String currentField; public void resetUserAction() { @@ -985,4 +986,16 @@ public void setClickedObj(String clickedObj) { this.clickedObj = clickedObj; } + /** + * @return Returns the currentField. + */ + public String getCurrentField() { + return currentField; + } + /** + * @param currentField The currentField to set. + */ + public void setCurrentField(String currentField) { + this.currentField = currentField; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java =================================================================== diff -u -r993fec58a7198f31f151cf47d6ba331148ce4fae -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -1235,6 +1235,11 @@ boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); + + /* + boolean validateOnlyOneCorrectCandidate=authoringUtil.validateOnlyOneCorrectCandidate(caList); + logger.debug("validateOnlyOneCorrectCandidate: " + validateOnlyOneCorrectCandidate); + */ ActionMessages errors = new ActionMessages(); @@ -1252,6 +1257,15 @@ ActionMessage error = new ActionMessage("candidates.none.correct"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } + + /* + if (!validateOnlyOneCorrectCandidate) + { + ActionMessage error = new ActionMessage("candidates.duplicate.correct"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + */ + logger.debug("errors: " + errors); if(!errors.isEmpty()){ @@ -1634,7 +1648,12 @@ boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); + /* + boolean validateOnlyOneCorrectCandidate=authoringUtil.validateOnlyOneCorrectCandidate(caList); + logger.debug("validateOnlyOneCorrectCandidate: " + validateOnlyOneCorrectCandidate); + */ + ActionMessages errors = new ActionMessages(); if (caList.size() == 0) @@ -1649,15 +1668,21 @@ ActionMessage error = new ActionMessage("candidates.none.correct"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } + + /* + if (!validateOnlyOneCorrectCandidate) + { + ActionMessage error = new ActionMessage("candidates.duplicate.correct"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + */ logger.debug("errors: " + errors); if(!errors.isEmpty()){ saveErrors(request, errors); logger.debug("errors saved: " + errors); } - - logger.debug("errors saved: " + errors); if(errors.isEmpty()) Index: lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp =================================================================== diff -u -r7011368b3f7cc34d52ce8f8640b64a9add794dd6 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 7011368b3f7cc34d52ce8f8640b64a9add794dd6) +++ lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -58,7 +58,7 @@ - Index: lams_tool_lamc/web/authoring/candidateAnswersList.jsp =================================================================== diff -u -r7011368b3f7cc34d52ce8f8640b64a9add794dd6 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 7011368b3f7cc34d52ce8f8640b64a9add794dd6) +++ lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -63,7 +63,7 @@ - Index: lams_tool_lamc/web/authoring/editQuestionBox.jsp =================================================================== diff -u -r7011368b3f7cc34d52ce8f8640b64a9add794dd6 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 7011368b3f7cc34d52ce8f8640b64a9add794dd6) +++ lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -68,7 +68,34 @@ document.McAuthoringForm.questionIndex.value=questionIndexValue; submitMethod("removeCandidate"); } - + + function validateDuplicateCorrectAnswers() + { + var correctCount = 0; + for(i = 1; i < 51; i++) + { + var currentId="select".concat(i) + var currentField=document.getElementById(currentId); + + if (currentField != null) + { + if ((typeof(currentField) != 'undefined') && (typeof(currentField) != null)) + { + if (currentField.value == 'Correct') + { + correctCount = correctCount + 1; + } + } + } + } + + if (correctCount > 1) + { + var msg = ""; + alert(msg); + } + } + @@ -78,6 +105,7 @@ styleId="newQuestionForm" enctype="multipart/form-data" method="POST"> + @@ -131,7 +159,7 @@
- Index: lams_tool_lamc/web/authoring/newQuestionBox.jsp =================================================================== diff -u -r7011368b3f7cc34d52ce8f8640b64a9add794dd6 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 7011368b3f7cc34d52ce8f8640b64a9add794dd6) +++ lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -50,6 +50,33 @@ document.McAuthoringForm.candidateIndex.value=candidateIndexValue; submitMethod("removeAddedCandidate"); } + + function validateDuplicateCorrectAnswers() + { + var correctCount = 0; + for(i = 1; i < 51; i++) + { + var currentId="select".concat(i) + var currentField=document.getElementById(currentId); + + if (currentField != null) + { + if ((typeof(currentField) != 'undefined') && (typeof(currentField) != null)) + { + if (currentField.value == 'Correct') + { + correctCount = correctCount + 1; + } + } + } + } + + if (correctCount > 1) + { + var msg = ""; + alert(msg); + } + } @@ -58,6 +85,7 @@ + @@ -110,7 +138,7 @@
- Index: lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp =================================================================== diff -u -r6f9a82945ad22a613ebdf36b17d6b1294d81eac0 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 6f9a82945ad22a613ebdf36b17d6b1294d81eac0) +++ lams_tool_lamc/web/monitoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -59,7 +59,7 @@ - Index: lams_tool_lamc/web/monitoring/candidateAnswersList.jsp =================================================================== diff -u -r6f9a82945ad22a613ebdf36b17d6b1294d81eac0 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/monitoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 6f9a82945ad22a613ebdf36b17d6b1294d81eac0) +++ lams_tool_lamc/web/monitoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -66,7 +66,7 @@ - Index: lams_tool_lamc/web/monitoring/editQuestionBox.jsp =================================================================== diff -u -r6f9a82945ad22a613ebdf36b17d6b1294d81eac0 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 6f9a82945ad22a613ebdf36b17d6b1294d81eac0) +++ lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -51,9 +51,34 @@ document.McMonitoringForm.questionIndex.value=questionIndexValue; submitMethod("removeCandidate"); } + + function validateDuplicateCorrectAnswers() + { + var correctCount = 0; + for(i = 1; i < 51; i++) + { + var currentId="select".concat(i) + var currentField=document.getElementById(currentId); + + if (currentField != null) + { + if ((typeof(currentField) != 'undefined') && (typeof(currentField) != null)) + { + if (currentField.value == 'Correct') + { + correctCount = correctCount + 1; + } + } + } + } + + if (correctCount > 1) + { + var msg = ""; + alert(msg); + } + } - - @@ -63,6 +88,7 @@ + @@ -145,7 +171,7 @@ Index: lams_tool_lamc/web/monitoring/newQuestionBox.jsp =================================================================== diff -u -r6f9a82945ad22a613ebdf36b17d6b1294d81eac0 -r525fef17717ea250350b7204056960f735ce02cb --- lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 6f9a82945ad22a613ebdf36b17d6b1294d81eac0) +++ lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 525fef17717ea250350b7204056960f735ce02cb) @@ -49,9 +49,34 @@ document.McMonitoringForm.candidateIndex.value=candidateIndexValue; submitMethod("removeAddedCandidate"); } + + function validateDuplicateCorrectAnswers() + { + var correctCount = 0; + for(i = 1; i < 51; i++) + { + var currentId="select".concat(i) + var currentField=document.getElementById(currentId); + + if (currentField != null) + { + if ((typeof(currentField) != 'undefined') && (typeof(currentField) != null)) + { + if (currentField.value == 'Correct') + { + correctCount = correctCount + 1; + } + } + } + } + + if (correctCount > 1) + { + var msg = ""; + alert(msg); + } + } - - @@ -61,6 +86,7 @@ + @@ -143,7 +169,7 @@
                     - +
                     - +