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 @@
+ | ++ | + +
+ |
+
+ + | + ++ | ++ | - - - | @@ -116,7 +131,9 @@ |
|
+ | + ++ | + +
+ |
+
+ + | + ++ | ++ |
+ |
-
-
|
-
+
|
+
+
+ | + ++ | + +
+ |
+
+ + | + ++ | ++ |
+ |
-
+
|
-
+
|
+
+