Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -r81e4b129f71e63322c81c9016ec1ffa93f3c5944 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 81e4b129f71e63322c81c9016ec1ffa93f3c5944) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -91,6 +91,10 @@ public static final String CURRENT_UID ="currentUid"; public static final String NEW_QUESTION_BOX_DTO ="newQuestionBoxDTO"; public static final String NEW_QUESTION_BOX_DTO_KEY ="newQuestionBoxDTOKey"; + public static final String PASSMARK_MAP ="passmarkMap"; + public static final String NEW_ADDABLE_QUESTION_CONTENT ="newAddableQuestionContent"; + public static final String NEW_ADDABLE_QUESTION_CONTENT_KEY ="newAddableQuestionContentKey"; + public static final String NEW_ADDABLE_QUESTION_CONTENT_LIST ="newAddableQuestionContentList"; public static final String AUTHORING ="authoring"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralAuthoringDTO.java =================================================================== diff -u -r81e4b129f71e63322c81c9016ec1ffa93f3c5944 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralAuthoringDTO.java (.../McGeneralAuthoringDTO.java) (revision 81e4b129f71e63322c81c9016ec1ffa93f3c5944) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralAuthoringDTO.java (.../McGeneralAuthoringDTO.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -86,12 +86,15 @@ protected String passMarkValue; protected Map passMarksMap; + protected String totalMarks; public String toString() { return new ToStringBuilder(this) .append("toolContentID: ", toolContentID) .append("contentFolderID: ", contentFolderID) .append("httpSessionID: ", httpSessionID) + .append("passMarksMap: ", passMarksMap) + .append("totalMarks: ", totalMarks) .append("marksMap: ", marksMap) .append("currentTab: ", currentTab) .append("markValue: ", markValue) @@ -609,4 +612,16 @@ public void setPassMarksMap(Map passMarksMap) { this.passMarksMap = passMarksMap; } + /** + * @return Returns the totalMarks. + */ + public String getTotalMarks() { + return totalMarks; + } + /** + * @param totalMarks The totalMarks to set. + */ + public void setTotalMarks(String totalMarks) { + this.totalMarks = totalMarks; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r8522cd628329e0031e21b48f2750b1fd9b1842a6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 8522cd628329e0031e21b48f2750b1fd9b1842a6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -190,7 +190,30 @@ } + protected static List removeBlankEntries(List list) + { + List newList= new LinkedList(); + + Iterator listIterator=list.iterator(); + while (listIterator.hasNext()) + { + McCandidateAnswersDTO mcCandidateAnswersDTO=(McCandidateAnswersDTO)listIterator.next(); + logger.debug("mcCandidateAnswersDTO: " + mcCandidateAnswersDTO); + + if (mcCandidateAnswersDTO != null) + { + String ca=mcCandidateAnswersDTO.getCandidateAnswer(); + logger.debug("ca: " + ca); + + if ((ca != null) && (ca.length() > 0)) + newList.add(mcCandidateAnswersDTO); + } + } + return newList; + } + + /** * * generateOptionsMap(List listQuestionOptions) @@ -547,6 +570,14 @@ McQuestionContentDTO replacedNode=extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex); logger.debug("replacedNode:" + replacedNode); + if ((mainNode == null) || (replacedNode == null)) + { + logger.debug("mainNode/replacedNode is null"); + return listQuestionContentDTO; + } + + + List listFinalQuestionContentDTO=new LinkedList(); listFinalQuestionContentDTO=reorderSwappedListQuestionContentDTO(listQuestionContentDTO, intOriginalQuestionIndex, @@ -677,6 +708,14 @@ McCandidateAnswersDTO replacedNode=extractCandidateAtOrder(listCandidates, replacedNodeIndex); logger.debug("replacedNode:" + replacedNode); + + if ((mainNode == null) || (replacedNode == null)) + { + logger.debug("mainNode/replacedNode is null"); + return listCandidates; + } + + List listFinalCandidateDTO=new LinkedList(); @@ -817,6 +856,35 @@ return null; } + protected static String getTotalMark(List listQuestionContentDTO) + { + logger.debug("starting getTotalMark:" + listQuestionContentDTO); + + Map mapMarks = extractMapMarks(listQuestionContentDTO); + + int intTotalMark=0; + Iterator itMap = mapMarks.entrySet().iterator(); + while (itMap.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + String mark= (String)pairs.getValue(); + logger.debug("mark: " + mark); + + if (mark != null) + { + int intMark= new Integer(mark).intValue(); + intTotalMark+=intMark; + logger.debug("current intTotalMark: " + intTotalMark); + } + } + logger.debug("final intTotalMark: " + intTotalMark); + + String strFinalTotalMark= new Integer(intTotalMark).toString(); + logger.debug("final strFinalTotalMark: " + strFinalTotalMark); + return strFinalTotalMark; + } /** @@ -1678,8 +1746,56 @@ } return mcContent; } + + protected Map buildDynamicPassMarkMap(List listQuestionContentDTO, boolean initialScreen) + { + logger.debug("starting buildDynamicPassMarkMap: " + listQuestionContentDTO); + logger.debug("initialScreen: " + initialScreen); + + Map map= new TreeMap(new McComparator()); + + //if (initialScreen) + // return map; + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + + int intTotalMark=0; + if ((totalMark != null) && (totalMark.length() > 0)) + intTotalMark= new Integer(totalMark).intValue(); + + logger.debug("intTotalMark: " + intTotalMark); + + + Map passMarksMap=buildPassMarkMap(intTotalMark, false); + logger.debug("passMarksMap: " + passMarksMap); + return passMarksMap; + } + + + protected Map buildPassMarkMap(int intTotalMark, boolean initialScreen) + { + logger.debug("building buildMarksMap: " + intTotalMark); + logger.debug("initialScreen: " + initialScreen); + + Map map= new TreeMap(new McComparator()); + + if (initialScreen) + return map; + + for (int i=1; i <= intTotalMark ; i++) + { + map.put(new Integer(i).toString(), new Integer(i).toString()); + } + logger.debug("return passmarks Map: " + map); + return map; + } + + + /** * Map buildMarksMap() * @@ -1702,6 +1818,7 @@ * * @return */ + /* protected Map buildPassMarkMap() { Map map= new TreeMap(new McComparator()); @@ -1715,6 +1832,7 @@ logger.debug("return passmarks Map: " + map); return map; } + */ /** * Map buildCorrectMap() @@ -1753,7 +1871,8 @@ logger.debug("correct: " + correct); - if ((candidate != null) && (candidate.length() > 0)) + //if ((candidate != null) && (candidate.length() > 0)) + if (candidate != null) { McCandidateAnswersDTO mcCandidateAnswersDTO= new McCandidateAnswersDTO(); mcCandidateAnswersDTO.setCandidateAnswer(candidate); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r9143e89a9c23c613879042751449004326a50bf6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 9143e89a9c23c613879042751449004326a50bf6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -214,9 +214,9 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString(); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -227,7 +227,10 @@ logger.debug("extracted mapFeedback: " + mapFeedback); Map mapWeights=new TreeMap(new McComparator()); - + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + Map mapMarks=AuthoringUtil.extractMapMarks(listQuestionContentDTO); logger.debug("extracted mapMarks: " + mapMarks); @@ -407,24 +410,34 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); - logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); - request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); request.getSession().setAttribute(httpSessionID, sessionMap); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); @@ -480,13 +493,16 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + - String mark=request.getParameter("mark"); logger.debug("mark: " + mark); @@ -497,6 +513,10 @@ AuthoringUtil authoringUtil = new AuthoringUtil(); List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); + + caList=AuthoringUtil.removeBlankEntries(caList); + logger.debug("caList after removing blank entries: " + caList); + boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); @@ -677,6 +697,22 @@ mcAuthoringForm, sessionMap, activeModule, strToolContentID, defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); @@ -781,11 +817,19 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -799,7 +843,6 @@ request.getSession().setAttribute(httpSessionID, sessionMap); logger.debug("mcGeneralAuthoringDTO.getMapQuestionContent(); " + mcGeneralAuthoringDTO.getMapQuestionContent()); - } @@ -834,14 +877,17 @@ logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + String activeModule=request.getParameter(ACTIVE_MODULE); logger.debug("activeModule: " + activeModule); String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -858,6 +904,18 @@ List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); + logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); + + McQuestionContentDTO mcQuestionContentDTONew = null; + + + int listSize=listQuestionContentDTO.size(); + logger.debug("listSize: " + listSize); + + logger.debug("listAddableQuestionContentDTO now: " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + String newQuestion=request.getParameter("newQuestion"); logger.debug("newQuestion: " + newQuestion); @@ -872,59 +930,143 @@ logger.debug("passmark: " + passmark); mcGeneralAuthoringDTO.setPassMarkValue(passmark); - - List caList=new LinkedList(); + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); - McCandidateAnswersDTO mcCandidateAnswersDTO= new McCandidateAnswersDTO(); - mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 1"); - mcCandidateAnswersDTO.setCorrect("Incorrect"); - caList.add(mcCandidateAnswersDTO); + caList=AuthoringUtil.removeBlankEntries(caList); + logger.debug("caList after removing blank entries: " + caList); - mcCandidateAnswersDTO= new McCandidateAnswersDTO(); - mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 2"); - mcCandidateAnswersDTO.setCorrect("Correct"); - caList.add(mcCandidateAnswersDTO); + boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); + logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); - int listSize=listQuestionContentDTO.size(); - logger.debug("listSize: " + listSize); + 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"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + logger.debug("errors: " + errors); + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - McQuestionContentDTO mcQuestionContentDTO=new McQuestionContentDTO(); - mcQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - mcQuestionContentDTO.setFeedback(feedback); - mcQuestionContentDTO.setQuestion(newQuestion); - mcQuestionContentDTO.setMark(mark); - - mcQuestionContentDTO.setListCandidateAnswersDTO(caList); - logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); - mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); - - listQuestionContentDTO.add(mcQuestionContentDTO); - logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); - } + + + logger.debug("errors saved: " + errors); + + if(errors.isEmpty()) + { + if ((newQuestion != null) && (newQuestion.length() > 0)) + { + boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + logger.debug("duplicates: " + duplicates); + + if (!duplicates) + { + McQuestionContentDTO mcQuestionContentDTO=new McQuestionContentDTO(); + mcQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); + mcQuestionContentDTO.setFeedback(feedback); + mcQuestionContentDTO.setQuestion(newQuestion); + mcQuestionContentDTO.setMark(mark); + + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); + mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); + + listQuestionContentDTO.add(mcQuestionContentDTO); + logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); + } + else + { + logger.debug("entry duplicate, not adding"); + } + } else { - logger.debug("entry duplicate, not adding"); + logger.debug("entry blank, not adding"); } - } - else - { - logger.debug("entry blank, not adding"); - } + } + else + { + logger.debug("errors, not adding"); + + logger.debug("errors is not empty: " + errors); + + commonSaveCode(request, mcGeneralAuthoringDTO, + mcAuthoringForm, sessionMap, activeModule, strToolContentID, + defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + logger.debug("forwarding using newQuestionBox"); + return newQuestionBox(mapping, form, request, response); + } + + logger.debug("entry using mark: " + mark); mcGeneralAuthoringDTO.setMarkValue(mark); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); @@ -935,9 +1077,10 @@ request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + logger.debug("before forwarding mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + + logger.debug("fwd LOAD_QUESTIONS"); return (mapping.findForward(LOAD_QUESTIONS)); - } @@ -974,13 +1117,17 @@ logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + String activeModule=request.getParameter(ACTIVE_MODULE); logger.debug("activeModule: " + activeModule); String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); @@ -1026,10 +1173,11 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1041,32 +1189,53 @@ String requestType=request.getParameter("requestType"); logger.debug("requestType: " + requestType); - List listQuestionContentDTO=new LinkedList(); + List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); + logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); + if ((requestType != null) && (requestType.equals("direct"))) { - logger.debug("getting the list from the db: "); - listQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("requestType is direct"); + listAddableQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listAddableQuestionContentDTO from db: " + listAddableQuestionContentDTO); + } - int count=listQuestionContentDTO.size(); - logger.debug("question count: " + count); - request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count + 1)); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); - } - else - { - logger.debug("getting the list from the cache: "); - listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - int count=listQuestionContentDTO.size(); - logger.debug("question count: " + count); - request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count)); - - } logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); @@ -1110,6 +1279,10 @@ String httpSessionID=mcAuthoringForm.getHttpSessionID(); logger.debug("httpSessionID: " + httpSessionID); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); logger.debug("sessionMap: " + sessionMap); @@ -1170,7 +1343,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1209,16 +1382,12 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); - logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); @@ -1234,6 +1403,38 @@ mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); } + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + /* + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + */ + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); @@ -1285,6 +1486,10 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -1344,7 +1549,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1424,11 +1629,18 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1476,7 +1688,9 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); - + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -1513,7 +1727,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1584,10 +1798,17 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1656,6 +1877,10 @@ String richTextTitle = request.getParameter(TITLE); logger.debug("richTextTitle: " + richTextTitle); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + String richTextInstructions = request.getParameter(INSTRUCTIONS); logger.debug("richTextInstructions: " + richTextInstructions); @@ -1668,7 +1893,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1739,10 +1964,18 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1790,6 +2023,9 @@ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); String activeModule=request.getParameter(ACTIVE_MODULE); @@ -1812,7 +2048,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1877,10 +2113,17 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1952,7 +2195,11 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); @@ -2038,10 +2285,19 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -2303,14 +2559,16 @@ logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); String activeModule=request.getParameter(ACTIVE_MODULE); logger.debug("activeModule: " + activeModule); String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2389,10 +2647,17 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -2460,6 +2725,8 @@ logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); @@ -2535,7 +2802,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2605,14 +2872,36 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -2657,6 +2946,10 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + String candidateIndex=request.getParameter("candidateIndex"); logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); @@ -2739,7 +3032,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2808,14 +3101,34 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -2863,7 +3176,11 @@ String candidateIndex=request.getParameter("candidateIndex"); logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -2956,7 +3273,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -3034,15 +3351,35 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -3092,6 +3429,9 @@ logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -3182,7 +3522,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); @@ -3251,15 +3591,36 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -3272,6 +3633,1005 @@ } + + public ActionForward updateMarksList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching updateMarksList"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil= new AuthoringUtil(); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("2"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + + public ActionForward moveAddedCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveAddedCandidateUp"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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); + } + + logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newQuestionBox(mapping, form, request, response); + + } + + + + public ActionForward moveAddedCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveAddedCandidateDown"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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); + } + + logger.debug("listAddableQuestionContentDTO after moving down candidates: "); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newQuestionBox(mapping, form, request, response); + } + + + + public ActionForward removeAddedCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching removeAddedCandidate"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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("mcQuestionContentDTO found:" + mcQuestionContentDTO); + logger.debug("setting caList for the content:"); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + + List candidateAnswers=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidateAnswers:" + candidateAnswers); + + McCandidateAnswersDTO mcCandidateAnswersDTO= null; + Iterator listCaIterator=candidateAnswers.iterator(); + int caIndex=0; + while (listCaIterator.hasNext()) + { + caIndex ++; + logger.debug("caIndex:" + caIndex); + mcCandidateAnswersDTO= (McCandidateAnswersDTO)listCaIterator.next(); + logger.debug("mcCandidateAnswersDTO:" + mcCandidateAnswersDTO); + logger.debug("mcCandidateAnswersDTO question:" + mcCandidateAnswersDTO.getCandidateAnswer()); + + if (caIndex == new Integer(candidateIndex).intValue()) + { + logger.debug("candidateIndex found"); + mcCandidateAnswersDTO.setCandidateAnswer(""); + + + break; + } + } + logger.debug("candidateAnswers after resetting answer" + candidateAnswers); + + candidateAnswers=AuthoringUtil.reorderListCandidatesDTO(candidateAnswers); + logger.debug("candidateAnswers after reordering candidate nodes" + candidateAnswers); + + mcQuestionContentDTO.setListCandidateAnswersDTO(candidateAnswers); + mcQuestionContentDTO.setCaCount(new Integer(candidateAnswers.size()).toString()); + + logger.debug("listQuestionContentDTO after remove: " + listQuestionContentDTO); + } + + + logger.debug("listAddableQuestionContentDTO : " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + if (mcContent == null) + { + logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); + } + logger.debug("final mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newQuestionBox(mapping, form, request, response); + + } + + + public ActionForward newAddedCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching newAddedCandidateBox"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, true); + logger.debug("repopulated caList: " + caList); + + int caCount=caList.size(); + logger.debug("caCount: " + caCount); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + + int currentQuestionCount= listQuestionContentDTO.size(); + logger.debug("currentQuestionCount: " + currentQuestionCount); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + + + 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); + + logger.debug("caList:" + caList); + logger.debug("caList size:" + caList.size()); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + mcQuestionContentDTO.setCaCount(new Integer(caList.size()).toString()); + } + + + logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: "); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + + logger.debug("listQuestionContentDTO after repopulating data: " + listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + mcAuthoringForm.setFeedback(feedback); + + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newQuestionBox(mapping, form, request, response); + + } + + + /** * boolean existsContent(long toolContentID, IMcService mcService) * @@ -3287,4 +4647,5 @@ return true; } + } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java =================================================================== diff -u -r9143e89a9c23c613879042751449004326a50bf6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 9143e89a9c23c613879042751449004326a50bf6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -111,13 +111,16 @@ protected String instructionsMonitoring; protected String editActivityMonitoring; protected String statsMonitoring; + + protected String clickedObj; protected String edit; private String contentFolderID; private String editableQuestionIndex; private String defineLaterInEditMode; private String feedback; private String candidateIndex; + private String totalMarks; public void resetUserAction() { @@ -958,4 +961,28 @@ this.candidateIndex = candidateIndex; } + /** + * @return Returns the totalMarks. + */ + public String getTotalMarks() { + return totalMarks; + } + /** + * @param totalMarks The totalMarks to set. + */ + public void setTotalMarks(String totalMarks) { + this.totalMarks = totalMarks; + } + /** + * @return Returns the clickedObj. + */ + public String getClickedObj() { + return clickedObj; + } + /** + * @param clickedObj The clickedObj to set. + */ + public void setClickedObj(String clickedObj) { + this.clickedObj = clickedObj; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java =================================================================== diff -u -r8522cd628329e0031e21b48f2750b1fd9b1842a6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 8522cd628329e0031e21b48f2750b1fd9b1842a6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -654,7 +654,7 @@ { logger.debug("dispatching editActivityQuestions..."); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; logger.debug("mcAuthoringForm: " + mcAuthoringForm); IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); @@ -677,7 +677,8 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString(); + //String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -757,9 +758,6 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); @@ -851,7 +849,9 @@ } + + /** * * ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) @@ -870,7 +870,6 @@ public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispathcing proxy submitAllContent :" +form); logger.debug("dispathcing submitAllContent :" +form); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -894,9 +893,9 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); - logger.debug("defaultContentIdStr: " + defaultContentIdStr); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString(); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -906,9 +905,11 @@ Map mapFeedback=AuthoringUtil.extractMapFeedback(listQuestionContentDTO); logger.debug("extracted mapFeedback: " + mapFeedback); - Map mapWeights=AuthoringUtil.extractMapWeights(listQuestionContentDTO); - logger.debug("extracted mapWeights: " + mapWeights); - + Map mapWeights=new TreeMap(new McComparator()); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + Map mapMarks=AuthoringUtil.extractMapMarks(listQuestionContentDTO); logger.debug("extracted mapMarks: " + mapMarks); @@ -931,7 +932,39 @@ McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + List attachmentListBackup= new ArrayList(); + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + attachmentListBackup=attachmentList; + + List deletedAttachmentListBackup= new ArrayList(); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + deletedAttachmentListBackup=deletedAttachmentList; + + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOfflineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + + } + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); String richTextTitle = request.getParameter(TITLE); @@ -965,9 +998,8 @@ logger.debug("errors saved: " + errors); } - McGeneralMonitoringDTO mcGeneralMonitoringDTO= new McGeneralMonitoringDTO(); - + McContent mcContent=mcContentTest; if(errors.isEmpty()){ logger.debug("errors is empty: " + errors); @@ -993,15 +1025,15 @@ authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, mcService, mcAuthoringForm, mcContent); logger.debug("post reOrganizeDisplayOrder: " + mcContent); - logger.debug("strToolContentID: " + strToolContentID); McUtils.setDefineLater(request, false, strToolContentID, mcService); logger.debug("define later set to false"); McUtils.setFormProperties(request, mcService, mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + logger.debug("go back to view only screen"); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); mcGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); } else @@ -1022,13 +1054,13 @@ McUtils.setFormProperties(request, mcService, mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - + mcGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); } } - - logger.debug("end of refreshSummaryData, mcGeneralMonitoringDTO" + mcGeneralMonitoringDTO); + logger.debug("end of refreshSummaryData, mcGeneralMonitoringDTO" + mcGeneralMonitoringDTO); request.setAttribute(MC_GENERAL_MONITORING_DTO, mcGeneralMonitoringDTO); + mcGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); @@ -1039,24 +1071,34 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); - logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); - request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); request.getSession().setAttribute(httpSessionID, sessionMap); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); @@ -1069,7 +1111,7 @@ mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); mcAuthoringForm.setCurrentTab("3"); - + /*common screen data*/ if (mcService.studentActivityOccurredGlobal(mcContent)) { @@ -1120,16 +1162,17 @@ logger.debug("ending setupCommonScreenData, mcContent " + mcContent); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + + - logger.debug("forwarding to :" + LOAD_MONITORING_CONTENT); - return mapping.findForward(LOAD_MONITORING_CONTENT); + logger.debug("forwarding to :" + LOAD_MONITORING); + return mapping.findForward(LOAD_MONITORING); } /** - * ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * includes a new question in the questions list + * saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * * @param mapping * @param form @@ -1141,7 +1184,7 @@ */ public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispathcing proxy saveSingleQuestion"); + logger.debug("dispathcing saveSingleQuestion"); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -1165,20 +1208,30 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + - String mark=request.getParameter("mark"); logger.debug("mark: " + mark); + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + AuthoringUtil authoringUtil = new AuthoringUtil(); List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); + + caList=AuthoringUtil.removeBlankEntries(caList); + logger.debug("caList after removing blank entries: " + caList); + boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); @@ -1213,11 +1266,12 @@ logger.debug("entry using mark: " + mark); mcGeneralAuthoringDTO.setMarkValue(mark); + mcGeneralAuthoringDTO.setPassMarkValue(passmark); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); logger.debug("mcContent: " + mcContent); - + if(errors.isEmpty()) { logger.debug("errors is empty: " + errors); @@ -1238,6 +1292,7 @@ logger.debug("editableQuestionIndex: " + editableQuestionIndex); mcAuthoringForm.setQuestionIndex(editableQuestionIndex); + if ((newQuestion != null) && (newQuestion.length() > 0)) { if ((editQuestionBoxRequest != null) && (editQuestionBoxRequest.equals("false"))) @@ -1349,9 +1404,10 @@ setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + - logger.debug("fwd ing to LOAD_MONITORING_CONTENT: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); + logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); + return (mapping.findForward(LOAD_MONITORING)); } else { @@ -1361,14 +1417,31 @@ mcAuthoringForm, sessionMap, activeModule, strToolContentID, defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - + + logger.debug("forwarding using newEditableQuestionBox"); return newEditableQuestionBox(mapping, form, request, response); } @@ -1437,11 +1510,19 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1460,7 +1541,7 @@ /** - * ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * * @param mapping * @param form @@ -1473,7 +1554,6 @@ public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispathcing proxy addSingleQuestion"); logger.debug("dispathcing addSingleQuestion"); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -1490,14 +1570,17 @@ logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + String activeModule=request.getParameter(ACTIVE_MODULE); logger.debug("activeModule: " + activeModule); String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1514,6 +1597,18 @@ List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); + logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); + + McQuestionContentDTO mcQuestionContentDTONew = null; + + + int listSize=listQuestionContentDTO.size(); + logger.debug("listSize: " + listSize); + + logger.debug("listAddableQuestionContentDTO now: " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + String newQuestion=request.getParameter("newQuestion"); logger.debug("newQuestion: " + newQuestion); @@ -1524,58 +1619,144 @@ logger.debug("mark: " + mark); mcGeneralAuthoringDTO.setMarkValue(mark); - List caList=new LinkedList(); + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + mcGeneralAuthoringDTO.setPassMarkValue(passmark); - McCandidateAnswersDTO mcCandidateAnswersDTO= new McCandidateAnswersDTO(); - mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 1"); - mcCandidateAnswersDTO.setCorrect("Incorrect"); - caList.add(mcCandidateAnswersDTO); + + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); - mcCandidateAnswersDTO= new McCandidateAnswersDTO(); - mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 2"); - mcCandidateAnswersDTO.setCorrect("Correct"); - caList.add(mcCandidateAnswersDTO); + caList=AuthoringUtil.removeBlankEntries(caList); + logger.debug("caList after removing blank entries: " + caList); + + boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); + logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); - int listSize=listQuestionContentDTO.size(); - logger.debug("listSize: " + listSize); + 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"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + logger.debug("errors: " + errors); + + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } - if ((newQuestion != null) && (newQuestion.length() > 0)) - { - boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); - logger.debug("duplicates: " + duplicates); - - if (!duplicates) - { - McQuestionContentDTO mcQuestionContentDTO=new McQuestionContentDTO(); - mcQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); - mcQuestionContentDTO.setFeedback(feedback); - mcQuestionContentDTO.setQuestion(newQuestion); - mcQuestionContentDTO.setMark(mark); - - mcQuestionContentDTO.setListCandidateAnswersDTO(caList); - logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); - mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); - - listQuestionContentDTO.add(mcQuestionContentDTO); - logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); - } + + + logger.debug("errors saved: " + errors); + + if(errors.isEmpty()) + { + if ((newQuestion != null) && (newQuestion.length() > 0)) + { + boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + logger.debug("duplicates: " + duplicates); + + if (!duplicates) + { + McQuestionContentDTO mcQuestionContentDTO=new McQuestionContentDTO(); + mcQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); + mcQuestionContentDTO.setFeedback(feedback); + mcQuestionContentDTO.setQuestion(newQuestion); + mcQuestionContentDTO.setMark(mark); + + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); + mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); + + listQuestionContentDTO.add(mcQuestionContentDTO); + logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); + } + else + { + logger.debug("entry duplicate, not adding"); + } + } else { - logger.debug("entry duplicate, not adding"); + logger.debug("entry blank, not adding"); } - } - else - { - logger.debug("entry blank, not adding"); - } + } + else + { + logger.debug("errors, not adding"); + + logger.debug("errors is not empty: " + errors); + + commonSaveCode(request, mcGeneralAuthoringDTO, + mcAuthoringForm, sessionMap, activeModule, strToolContentID, + defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + logger.debug("forwarding using newQuestionBox"); + return newQuestionBox(mapping, form, request, response); + } logger.debug("entry using mark: " + mark); mcGeneralAuthoringDTO.setMarkValue(mark); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); @@ -1585,14 +1766,16 @@ defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + + logger.debug("before forwarding mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + - logger.debug("fwd ing to LOAD_MONITORING_CONTENT: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); - + logger.debug("fwd LOAD_MONITORING"); + return (mapping.findForward(LOAD_MONITORING)); } @@ -1601,6 +1784,7 @@ * * opens up an new screen within the current page for adding a new question * + * newQuestionBox * @param mapping * @param form * @param request @@ -1628,19 +1812,19 @@ logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + String activeModule=request.getParameter(ACTIVE_MODULE); logger.debug("activeModule: " + activeModule); String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - long defaultContentID=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + defaultContentID); - String defaultContentIdStr =new Long(defaultContentID).toString(); - logger.debug("retrieved defaultContentIdStr: " + defaultContentIdStr); - /* create default mcContent object*/ McContent mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); @@ -1672,10 +1856,11 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -1687,34 +1872,53 @@ String requestType=request.getParameter("requestType"); logger.debug("requestType: " + requestType); - List listQuestionContentDTO=new LinkedList(); + List listAddableQuestionContentDTO = (List)sessionMap.get(NEW_ADDABLE_QUESTION_CONTENT_KEY); + logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); + if ((requestType != null) && (requestType.equals("direct"))) { - logger.debug("getting the list from the db: "); - listQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("requestType is direct"); + listAddableQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listAddableQuestionContentDTO from db: " + listAddableQuestionContentDTO); + } - int count=listQuestionContentDTO.size(); - logger.debug("question count: " + count); - request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count + 1)); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); - } - else - { - logger.debug("getting the list from the cache: "); - listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); - int count=listQuestionContentDTO.size(); - logger.debug("question count: " + count); - request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count)); - - } - - logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); @@ -1738,7 +1942,7 @@ /** - * ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * * opens up an new screen within the current page for editing a question * @@ -1761,6 +1965,10 @@ String httpSessionID=mcAuthoringForm.getHttpSessionID(); logger.debug("httpSessionID: " + httpSessionID); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); logger.debug("sessionMap: " + sessionMap); @@ -1821,7 +2029,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -1860,20 +2068,46 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); - logger.debug("passMarksMap: " + passMarksMap); - mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); - logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + /* + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + */ + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); @@ -1890,7 +2124,7 @@ setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - + logger.debug("fwd ing to editQuestionBox: "); return (mapping.findForward("editQuestionBox")); } @@ -1914,7 +2148,6 @@ */ public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispatching proxy removeQuestion"); logger.debug("dispatching removeQuestion"); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -1931,8 +2164,11 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); McQuestionContentDTO mcQuestionContentDTO= null; @@ -1990,7 +2226,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2042,33 +2278,42 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + setupCommonScreenData(mcContent, mcService,request); - MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - - logger.debug("fwd ing to LOAD_MONITORING_CONTENT: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); + return (mapping.findForward(LOAD_MONITORING)); } /** - * ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * * moves a question down in the list * + * moveQuestionDown * @param mapping * @param form * @param request @@ -2079,7 +2324,6 @@ */ public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispatching proxy moveQuestionDown"); logger.debug("dispatching moveQuestionDown"); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -2096,7 +2340,10 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); - + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -2132,7 +2379,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2176,10 +2423,17 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -2188,21 +2442,20 @@ request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - - logger.debug("fwd ing to LOAD_MONITORING_CONTENT: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); + logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); + return (mapping.findForward(LOAD_MONITORING)); } /** - * ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * + * moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * * - * moves a question up in the list - * * @param mapping * @param form * @param request @@ -2213,7 +2466,6 @@ */ public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - logger.debug("dispatching proxy moveQuestionUp"); logger.debug("dispatching moveQuestionUp"); McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; @@ -2252,6 +2504,10 @@ String richTextTitle = request.getParameter(TITLE); logger.debug("richTextTitle: " + richTextTitle); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + String richTextInstructions = request.getParameter(INSTRUCTIONS); logger.debug("richTextInstructions: " + richTextInstructions); @@ -2264,7 +2520,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2278,6 +2534,7 @@ mcAuthoringForm.setTitle(richTextTitle); mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + AuthoringUtil authoringUtil= new AuthoringUtil(); mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); @@ -2307,10 +2564,18 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); @@ -2324,15 +2589,16 @@ MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - logger.debug("fwd ing to LOAD_MONITORING_CONTENT: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); + logger.debug("fwd ing to LOAD_MONITORING: " + LOAD_MONITORING); + return (mapping.findForward(LOAD_MONITORING)); } + /** - * ActionForward moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * moves a candidate question down in the list + * moves a candidate dwn in the list * * @param mapping * @param form @@ -2345,7 +2611,7 @@ public ActionForward moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { logger.debug("dispatching moveCandidateDown"); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); logger.debug("mcService: " + mcService); @@ -2364,6 +2630,8 @@ logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); AuthoringUtil authoringUtil = new AuthoringUtil(); List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); @@ -2439,7 +2707,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2470,7 +2738,7 @@ mcAuthoringForm.setHttpSessionID(httpSessionID); mcAuthoringForm.setActiveModule(activeModule); mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - mcAuthoringForm.setCurrentTab("1"); + mcAuthoringForm.setCurrentTab("3"); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); @@ -2481,14 +2749,36 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -2497,19 +2787,19 @@ String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - + return newEditableQuestionBox(mapping, form, request, response); } /** - * ActionForward moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * moves a candidate question up in the list + * moves a candidate up in the list * * @param mapping * @param form @@ -2537,6 +2827,10 @@ logger.debug("questionIndex: " + questionIndex); mcAuthoringForm.setQuestionIndex(questionIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + String candidateIndex=request.getParameter("candidateIndex"); logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); @@ -2619,7 +2913,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2650,7 +2944,7 @@ mcAuthoringForm.setHttpSessionID(httpSessionID); mcAuthoringForm.setActiveModule(activeModule); mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - mcAuthoringForm.setCurrentTab("1"); + mcAuthoringForm.setCurrentTab("3"); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); @@ -2661,35 +2955,55 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); - + return newEditableQuestionBox(mapping, form, request, response); } /** - * ActionForward removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * removes a candidate question from the list + * removes a candidate from the list * * @param mapping * @param form @@ -2702,7 +3016,7 @@ public ActionForward removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { logger.debug("dispatching removeCandidate"); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); logger.debug("mcService: " + mcService); @@ -2720,16 +3034,19 @@ String candidateIndex=request.getParameter("candidateIndex"); logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); - - List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); AuthoringUtil authoringUtil = new AuthoringUtil(); List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); logger.debug("repopulated caList: " + caList); - + McQuestionContentDTO mcQuestionContentDTO= null; Iterator listIterator=listQuestionContentDTO.iterator(); while (listIterator.hasNext()) @@ -2775,7 +3092,6 @@ logger.debug("candidateIndex found"); mcCandidateAnswersDTO.setCandidateAnswer(""); - break; } } @@ -2813,7 +3129,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); @@ -2834,34 +3150,6 @@ mcAuthoringForm.setTitle(richTextTitle); mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - - logger.debug("activeModule: " + activeModule); - if (activeModule.equals(AUTHORING)) - { - String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); - logger.debug("onlineInstructions: " + onlineInstructions); - mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - - String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); - logger.debug("offlineInstructions: " + offlineInstructions); - mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); - - - List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); - logger.debug("attachmentList: " + attachmentList); - List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - logger.debug("deletedAttachmentList: " + deletedAttachmentList); - - mcGeneralAuthoringDTO.setAttachmentList(attachmentList); - mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - - String strOnlineInstructions= request.getParameter("onlineInstructions"); - String strOfflineInstructions= request.getParameter("offlineInstructions"); - logger.debug("onlineInstructions: " + strOnlineInstructions); - logger.debug("offlineInstructions: " + strOnlineInstructions); - mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); - mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); - } mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); @@ -2879,7 +3167,7 @@ mcAuthoringForm.setHttpSessionID(httpSessionID); mcAuthoringForm.setActiveModule(activeModule); mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - mcAuthoringForm.setCurrentTab("1"); + mcAuthoringForm.setCurrentTab("3"); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); logger.debug("mcQuestionContentDTO now: " + mcQuestionContentDTO); @@ -2891,15 +3179,35 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); @@ -2908,20 +3216,20 @@ String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - + setupCommonScreenData(mcContent, mcService,request); - - MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + return newEditableQuestionBox(mapping, form, request, response); } - + /** - * ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * creates screen area for adding a new candidate question + * enables adding a new candidate answer * * @param mapping * @param form @@ -2934,7 +3242,7 @@ public ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { logger.debug("dispatching newCandidateBox"); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); logger.debug("mcService: " + mcService); @@ -2953,6 +3261,9 @@ logger.debug("candidateIndex: " + candidateIndex); mcAuthoringForm.setCandidateIndex(candidateIndex); + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); @@ -3017,10 +3328,8 @@ mcQuestionContentDTOLocal.setCaCount(new Integer(caList.size()).toString()); } - logger.debug("listQuestionContentDTO after repopulating data: " + listQuestionContentDTO); - sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); @@ -3045,7 +3354,7 @@ String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); - String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; logger.debug("defaultContentIdStr: " + defaultContentIdStr); McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); @@ -3073,7 +3382,7 @@ mcAuthoringForm.setHttpSessionID(httpSessionID); mcAuthoringForm.setActiveModule(activeModule); mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); - mcAuthoringForm.setCurrentTab("1"); + mcAuthoringForm.setCurrentTab("3"); request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); logger.debug("mcQuestionContentDTOLocal now: " + mcQuestionContentDTOLocal); @@ -3085,35 +3394,802 @@ logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + setupCommonScreenData(mcContent, mcService,request); + + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + return newEditableQuestionBox(mapping, form, request, response); + } + + + public ActionForward moveAddedCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveAddedCandidateUp"); + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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); + } + + logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + setupCommonScreenData(mcContent, mcService,request); MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + + return newQuestionBox(mapping, form, request, response); + + } + + + + public ActionForward moveAddedCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveAddedCandidateDown"); + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; - return newEditableQuestionBox(mapping, form, request, response); + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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); + } + + logger.debug("listAddableQuestionContentDTO after moving down candidates: "); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + setupCommonScreenData(mcContent, mcService,request); + + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + + return newQuestionBox(mapping, form, request, response); } + + public ActionForward removeAddedCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching removeAddedCandidate"); + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + AuthoringUtil authoringUtil = new AuthoringUtil(); + 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); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + 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("mcQuestionContentDTO found:" + mcQuestionContentDTO); + logger.debug("setting caList for the content:"); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + + List candidateAnswers=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidateAnswers:" + candidateAnswers); + + McCandidateAnswersDTO mcCandidateAnswersDTO= null; + Iterator listCaIterator=candidateAnswers.iterator(); + int caIndex=0; + while (listCaIterator.hasNext()) + { + caIndex ++; + logger.debug("caIndex:" + caIndex); + mcCandidateAnswersDTO= (McCandidateAnswersDTO)listCaIterator.next(); + logger.debug("mcCandidateAnswersDTO:" + mcCandidateAnswersDTO); + logger.debug("mcCandidateAnswersDTO question:" + mcCandidateAnswersDTO.getCandidateAnswer()); + + if (caIndex == new Integer(candidateIndex).intValue()) + { + logger.debug("candidateIndex found"); + mcCandidateAnswersDTO.setCandidateAnswer(""); + + + break; + } + } + logger.debug("candidateAnswers after resetting answer" + candidateAnswers); + + candidateAnswers=AuthoringUtil.reorderListCandidatesDTO(candidateAnswers); + logger.debug("candidateAnswers after reordering candidate nodes" + candidateAnswers); + + mcQuestionContentDTO.setListCandidateAnswersDTO(candidateAnswers); + mcQuestionContentDTO.setCaCount(new Integer(candidateAnswers.size()).toString()); + + logger.debug("listQuestionContentDTO after remove: " + listQuestionContentDTO); + } + + + logger.debug("listAddableQuestionContentDTO : " + listAddableQuestionContentDTO); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + if (mcContent == null) + { + logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); + } + logger.debug("final mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + mcAuthoringForm.setFeedback(feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + setupCommonScreenData(mcContent, mcService,request); + + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + return newQuestionBox(mapping, form, request, response); + + } + + + public ActionForward newAddedCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching newAddedCandidateBox"); + McAuthoringForm mcAuthoringForm = (McMonitoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + String totalMarks=request.getParameter("totalMarks"); + logger.debug("totalMarks: " + totalMarks); + + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, true); + logger.debug("repopulated caList: " + caList); + + int caCount=caList.size(); + logger.debug("caCount: " + caCount); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + + int currentQuestionCount= listQuestionContentDTO.size(); + logger.debug("currentQuestionCount: " + currentQuestionCount); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + + + 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); + + logger.debug("caList:" + caList); + logger.debug("caList size:" + caList.size()); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + mcQuestionContentDTO.setCaCount(new Integer(caList.size()).toString()); + } + + + logger.debug("listAddableQuestionContentDTO after swapping (up) candidates: "); + request.setAttribute(NEW_ADDABLE_QUESTION_CONTENT_LIST, listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + + + logger.debug("listQuestionContentDTO after repopulating data: " + listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=new Long(mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE)).toString();; + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + logger.debug("generating dyn pass map using listQuestionContentDTO: " +listQuestionContentDTO); + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTO, false); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTO); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); + mcAuthoringForm.setFeedback(feedback); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + setupCommonScreenData(mcContent, mcService,request); + + MonitoringUtil.setupAllSessionsData(request, mcContent,mcService); + return newQuestionBox(mapping, form, request, response); + } + + + + + /** * prepareReflectionData(HttpServletRequest request, McContent mcContent, IMcService mcService, String userID, boolean exportMode) Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u -r9143e89a9c23c613879042751449004326a50bf6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 9143e89a9c23c613879042751449004326a50bf6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -31,8 +31,6 @@ /** * Tool path The URL path for the tool should be /tool/$TOOL_SIG. * - * CONTENT_LOCKED ->CONTENT_IN_USE - * * McStarterAction loads the default content and initializes the presentation Map * Requests can come either from authoring envuironment or from the monitoring environment for Edit Activity screen * @@ -234,9 +232,6 @@ mcGeneralAuthoringDTO.setRequestedModule(requestedModule); - /* in development this needs to be called only once. */ - /* McUtils.configureContentRepository(request); */ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); logger.debug("sourceMcStarter: " + sourceMcStarter); @@ -336,9 +331,6 @@ { McUtils.cleanUpSessionAbsolute(request); logger.debug("student activity occurred on this content:" + mcContent); - //persistError(request, "error.content.inUse"); - //logger.debug("add error.content.inUse to ActionMessages."); - //return (mapping.findForward(ERROR_LIST)); } mcContent=retrieveContent(request, mapping, mcAuthoringForm, mapQuestionContent, new Long(strToolContentID).longValue(),false, mcService, mcGeneralAuthoringDTO, sessionMap); @@ -375,35 +367,44 @@ logger.debug("mapQuestionContent: " + mapQuestionContent); sessionMap.put(MAP_QUESTION_CONTENT_KEY, mapQuestionContent); + + + AuthoringUtil authoringUtil =new AuthoringUtil(); + List listAddableQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listAddableQuestionContentDTO: " + listAddableQuestionContentDTO); + sessionMap.put(NEW_ADDABLE_QUESTION_CONTENT_KEY, listAddableQuestionContentDTO); + logger.debug("persisting sessionMap into session: " + sessionMap); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - AuthoringUtil authoringUtil= new AuthoringUtil(); Map marksMap=authoringUtil.buildMarksMap(); logger.debug("marksMap: " + marksMap); mcGeneralAuthoringDTO.setMarksMap(marksMap); mcGeneralAuthoringDTO.setMarkValue("1"); - Map passMarksMap=authoringUtil.buildPassMarkMap(); + List listQuestionContentDTOLocal=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listQuestionContentDTOLocal: " + listQuestionContentDTOLocal); + + Map passMarksMap=authoringUtil.buildDynamicPassMarkMap(listQuestionContentDTOLocal, true); logger.debug("passMarksMap: " + passMarksMap); mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String totalMark=AuthoringUtil.getTotalMark(listQuestionContentDTOLocal); + logger.debug("totalMark: " + totalMark); + mcAuthoringForm.setTotalMarks(totalMark); + mcGeneralAuthoringDTO.setTotalMarks(totalMark); + String passMark=" "; - //if (mcContent.getPassMark() != null) - // passMark=mcContent.getPassMark().toString(); - if ((mcContent.getPassMark() != null) && (mcContent.getPassMark().intValue() != 0)) passMark=mcContent.getPassMark().toString(); mcGeneralAuthoringDTO.setPassMarkValue (passMark); - - - Map correctMap=authoringUtil.buildCorrectMap(); logger.debug("correctMap: " + correctMap); mcGeneralAuthoringDTO.setCorrectMap(correctMap); Index: lams_tool_lamc/web/authoring/AdvancedContent.jsp =================================================================== diff -u -r8522cd628329e0031e21b48f2750b1fd9b1842a6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision 8522cd628329e0031e21b48f2750b1fd9b1842a6) +++ lams_tool_lamc/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -21,13 +21,6 @@ <%@ include file="/common/taglibs.jsp"%> - - - - + + Index: lams_tool_lamc/web/authoring/AuthoringTabsHolder.jsp =================================================================== diff -u -r82475bcf94096557635a347e2927c9995c8a03ee -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 82475bcf94096557635a347e2927c9995c8a03ee) +++ lams_tool_lamc/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -62,13 +62,32 @@ document.McAuthoringForm.questionIndex.value=questionIndexValue; submitMethod(actionMethod); } + + function updatePass(clickedObj) + { + if (clickedObj.checked) + { + document.McAuthoringForm.passmark.disabled= false; + + }else + { + document.McAuthoringForm.passmark.value= ' '; + document.McAuthoringForm.passmark.disabled= true; + } + } + + + var imgRoot="${lams}images/"; var themeName="aqua"; - + function init(){ + if (document.McAuthoringForm.activeModule.value != 'defineLater') { + updatePass(document.McAuthoringForm.retries); + initTabSize(3); var tag = document.getElementById("currentTab"); @@ -135,6 +154,7 @@ + <%@ include file="/common/messages.jsp"%> Index: lams_tool_lamc/web/authoring/BasicContent.jsp =================================================================== diff -u -r9143e89a9c23c613879042751449004326a50bf6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision 9143e89a9c23c613879042751449004326a50bf6) +++ lams_tool_lamc/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -107,7 +107,7 @@ Index: lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp =================================================================== diff -u -r8522cd628329e0031e21b48f2750b1fd9b1842a6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 8522cd628329e0031e21b48f2750b1fd9b1842a6) +++ lams_tool_lamc/web/authoring/candidateAnswersAddList.jsp (.../candidateAnswersAddList.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -21,10 +21,7 @@ <%@ include file="/common/taglibs.jsp" %> - - -
- - - -
@@ -39,12 +32,13 @@
- +
+ + + + + + +
- ');" + ');" style="float:right;width:150px" class="button-add-item">
@@ -35,19 +32,24 @@ <%@ include file="/common/messages.jsp"%> -newQuestionBoxDTO.listCandidateAnswersDTO:
+ + + + + + + - - currentCandidateDTO:
+
+ Index: lams_tool_lamc/web/authoring/editQuestionBox.jsp =================================================================== diff -u -r82475bcf94096557635a347e2927c9995c8a03ee -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 82475bcf94096557635a347e2927c9995c8a03ee) +++ lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -88,6 +88,7 @@ + Index: lams_tool_lamc/web/authoring/itemlist.jsp =================================================================== diff -u -r8522cd628329e0031e21b48f2750b1fd9b1842a6 -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/itemlist.jsp (.../itemlist.jsp) (revision 8522cd628329e0031e21b48f2750b1fd9b1842a6) +++ lams_tool_lamc/web/authoring/itemlist.jsp (.../itemlist.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -28,24 +28,58 @@
- + @@ -75,24 +77,24 @@ - ', '', 'moveAddCandidateDown');"> + ', 'moveAddedCandidateDown');"> images/down.gif" border="0"> - ', '', 'moveAddCandidateUp');"> + ', 'moveAddedCandidateUp');"> images/up.gif" border="0"> - ', '', 'moveAddCandidateDown');"> + ', 'moveAddedCandidateDown');"> images/down.gif" border="0"> - ', '', 'moveAddCandidateUp');"> + ', 'moveAddedCandidateUp');"> images/up.gif" border="0"> @@ -101,12 +103,13 @@ - + images/delete.gif" border="0">
+ + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + +
+   + +   + + + + + +   + +   + +   +
: + + + Index: lams_tool_lamc/web/authoring/newQuestionBox.jsp =================================================================== diff -u -r82475bcf94096557635a347e2927c9995c8a03ee -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 82475bcf94096557635a347e2927c9995c8a03ee) +++ lams_tool_lamc/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -37,21 +37,19 @@ document.McAuthoringForm.submit(); } - function submitModifyAuthoringCandidate(questionIndexValue, candidateIndexValue, actionMethod) + + function submitModifyAddedAuthoringCandidate(candidateIndexValue, actionMethod) { document.McAuthoringForm.candidateIndex.value=candidateIndexValue; - document.McAuthoringForm.questionIndex.value=questionIndexValue; submitMethod(actionMethod); } - function removeCandidate(questionIndexValue, candidateIndexValue) + function removeAddedCandidate(candidateIndexValue) { document.McAuthoringForm.candidateIndex.value=candidateIndexValue; - document.McAuthoringForm.questionIndex.value=questionIndexValue; - submitMethod("removeCandidate"); + submitMethod("removeAddedCandidate"); } - @@ -69,6 +67,7 @@ +
@@ -88,6 +87,22 @@
+ <%@ include file="/authoring/candidateAnswersAddList.jsp"%> +
+ + + +
+ +
+
+ +
+
+ +<%@ include file="/common/messages.jsp"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + ', 'moveAddedCandidateDown');"> + images/down.gif" border="0"> + + + + + + ', 'moveAddedCandidateUp');"> + images/up.gif" border="0"> + + + + + ', 'moveAddedCandidateDown');"> + images/down.gif" border="0"> + + + ', 'moveAddedCandidateUp');"> + images/up.gif" border="0"> + + + + + + + images/delete.gif" border="0"> + +
Index: lams_tool_lamc/web/monitoring/editQuestionBox.jsp =================================================================== diff -u -r82475bcf94096557635a347e2927c9995c8a03ee -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 82475bcf94096557635a347e2927c9995c8a03ee) +++ lams_tool_lamc/web/monitoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -52,6 +52,8 @@ submitMethod("removeCandidate"); } + + Index: lams_tool_lamc/web/monitoring/newQuestionBox.jsp =================================================================== diff -u -r82475bcf94096557635a347e2927c9995c8a03ee -r993fec58a7198f31f151cf47d6ba331148ce4fae --- lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 82475bcf94096557635a347e2927c9995c8a03ee) +++ lams_tool_lamc/web/monitoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 993fec58a7198f31f151cf47d6ba331148ce4fae) @@ -29,14 +29,29 @@ @@ -70,8 +85,25 @@
+ <%@ include file="/monitoring/candidateAnswersAddList.jsp"%> +
+ + + +