Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java,v diff -u -r1.49.4.1.4.2 -r1.49.4.1.4.3 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 5 Mar 2010 00:11:19 -0000 1.49.4.1.4.2 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 1 Nov 2010 10:36:55 -0000 1.49.4.1.4.3 @@ -107,24 +107,21 @@ while (listIterator.hasNext()) { QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); queIndex++; - QaQuestionContentDTO tempNode = new QaQuestionContentDTO(); - + QaQuestionContentDTO tempNode = null; + if (!qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString()) && !qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { AuthoringUtil.logger.debug("normal copy "); - tempNode.setQuestion(qaQuestionContentDTO.getQuestion()); - tempNode.setDisplayOrder(qaQuestionContentDTO.getDisplayOrder()); - tempNode.setFeedback(qaQuestionContentDTO.getFeedback()); + tempNode = new QaQuestionContentDTO(qaQuestionContentDTO.getQuestion(), + qaQuestionContentDTO.getDisplayOrder(), qaQuestionContentDTO.getFeedback(), qaQuestionContentDTO.isRequired()); } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) { AuthoringUtil.logger.debug("move type 1 "); - tempNode.setQuestion(replacedNode.getQuestion()); - tempNode.setDisplayOrder(replacedNode.getDisplayOrder()); - tempNode.setFeedback(replacedNode.getFeedback()); + tempNode = new QaQuestionContentDTO(replacedNode.getQuestion(), + replacedNode.getDisplayOrder(),replacedNode.getFeedback(), replacedNode.isRequired()); } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) { AuthoringUtil.logger.debug("move type 1 "); - tempNode.setQuestion(mainNode.getQuestion()); - tempNode.setDisplayOrder(mainNode.getDisplayOrder()); - tempNode.setFeedback(mainNode.getFeedback()); + tempNode = new QaQuestionContentDTO(mainNode.getQuestion(), + mainNode.getDisplayOrder(), mainNode.getFeedback(), mainNode.isRequired()); } listFinalQuestionContentDTO.add(tempNode); @@ -161,35 +158,7 @@ } return null; } - - protected static Map extractMapQuestionContent(List listQuestionContentDTO) { - Map mapQuestionContent = new TreeMap(new QaComparator()); - - Iterator listIterator = listQuestionContentDTO.iterator(); - int queIndex = 0; - while (listIterator.hasNext()) { - QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); - queIndex++; - AuthoringUtil.logger.debug("Populating question map with key=" + queIndex + " value=" + qaQuestionContentDTO.getQuestion()); - mapQuestionContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getQuestion()); - } - return mapQuestionContent; - } - - protected static Map extractMapFeedback(List listQuestionContentDTO) { - Map mapFeedbackContent = new TreeMap(new QaComparator()); - - Iterator listIterator = listQuestionContentDTO.iterator(); - int queIndex = 0; - while (listIterator.hasNext()) { - QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); - queIndex++; - AuthoringUtil.logger.debug("Populating feedback map with key=" + queIndex + " value=" + qaQuestionContentDTO.getFeedback()); - mapFeedbackContent.put(new Integer(queIndex).toString(), qaQuestionContentDTO.getFeedback()); - } - return mapFeedbackContent; - } - + protected static Map reorderQuestionContentMap(Map mapQuestionContent) { Map mapFinalQuestionContent = new TreeMap(new QaComparator()); @@ -224,6 +193,7 @@ AuthoringUtil.logger.debug("displayOrder:" + displayOrder); String feedback = qaQuestionContentDTO.getFeedback(); + boolean required = qaQuestionContentDTO.isRequired(); AuthoringUtil.logger.debug("displayOrder versus excludeQuestionIndex :" + displayOrder + " versus " + excludeQuestionIndex); @@ -235,6 +205,7 @@ qaQuestionContentDTO.setQuestion(question); qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setRequired(required); listFinalQuestionContentDTO.add(qaQuestionContentDTO); } @@ -253,17 +224,17 @@ QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next(); String question = qaQuestionContentDTO.getQuestion(); - String displayOrder = qaQuestionContentDTO.getDisplayOrder(); + String feedback = qaQuestionContentDTO.getFeedback(); + boolean required = qaQuestionContentDTO.isRequired(); - String feedback = qaQuestionContentDTO.getFeedback(); - if (question != null && !question.equals("")) { ++queIndex; qaQuestionContentDTO.setQuestion(question); qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString()); qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setRequired(required); listFinalQuestionContentDTO.add(qaQuestionContentDTO); } @@ -286,21 +257,22 @@ ++queIndex; String question = qaQuestionContentDTO.getQuestion(); - String displayOrder = qaQuestionContentDTO.getDisplayOrder(); - String feedback = qaQuestionContentDTO.getFeedback(); - + boolean required = qaQuestionContentDTO.isRequired(); + if (displayOrder.equals(editableQuestionIndex)) { qaQuestionContentDTO.setQuestion(qaQuestionContentDTONew.getQuestion()); qaQuestionContentDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder()); qaQuestionContentDTO.setFeedback(qaQuestionContentDTONew.getFeedback()); + qaQuestionContentDTO.setRequired(required); listFinalQuestionContentDTO.add(qaQuestionContentDTO); } else { qaQuestionContentDTO.setQuestion(question); qaQuestionContentDTO.setDisplayOrder(displayOrder); qaQuestionContentDTO.setFeedback(feedback); + qaQuestionContentDTO.setRequired(required); listFinalQuestionContentDTO.add(qaQuestionContentDTO); @@ -333,7 +305,7 @@ } } - public QaContent saveOrUpdateQaContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, + public QaContent saveOrUpdateQaContent(List listQuestionContentDTO, IQaService qaService, QaAuthoringForm qaAuthoringForm, HttpServletRequest request, QaContent qaContent, String strToolContentID, Set conditions) { UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); @@ -452,7 +424,7 @@ } qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); - qaContent = createQuestionContent(mapQuestionContent, mapFeedback, qaService, qaContent, conditions); + qaContent = createQuestionContent(listQuestionContentDTO, qaService, qaContent, conditions); qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); @@ -480,7 +452,7 @@ * @param qaService * @param qaAuthoringForm */ - public void removeRedundantQuestions(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, + public void removeRedundantQuestions(ListlistQuestionContentDTO, IQaService qaService, QaAuthoringForm qaAuthoringForm, HttpServletRequest request, String toolContentID) { AuthoringUtil.logger.debug("removing unused entries... "); AuthoringUtil.logger.debug("toolContentID: " + toolContentID); @@ -501,23 +473,10 @@ AuthoringUtil.logger.info("Checking whether to remove question with id=" + queContent.getUid() + ", displayOrder=" + queContent.getDisplayOrder() + ", question=" + queContent.getQuestion()); entryUsed = false; - Iterator itMap = mapQuestionContent.entrySet().iterator(); int displayOrder = 0; - while (itMap.hasNext()) { + for ( QaQuestionContentDTO questionDTO : listQuestionContentDTO ) { ++displayOrder; - - entryUsed = false; - Map.Entry pairs = (Map.Entry) itMap.next(); - AuthoringUtil.logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - /* - if (pairs.getValue().toString().length() != 0) { - if (mapIndex == displayOrder) { - entryUsed = true; - break; - } - } - */ - if (StringUtils.equals(queContent.getQuestion(), pairs.getValue().toString())) { + if (StringUtils.equals(queContent.getQuestion(), questionDTO.getQuestion())) { entryUsed = true; break; } @@ -549,49 +508,38 @@ * their displayOrder fields haven't been updated yet. Note also that the given * mapQuestionContent maps question numbers to question strings. */ - protected QaContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IQaService qaService, + protected QaContent createQuestionContent(List listQuestionContentDTO, IQaService qaService, QaContent qaContent, Set conditions) { - AuthoringUtil.logger.debug("createQuestionContent: "); - AuthoringUtil.logger.debug("content uid is: " + qaContent.getUid()); - List questions = qaService.retrieveQaQueContentsByToolContentId(qaContent.getUid().longValue()); + AuthoringUtil.logger.debug("createQuestionContent: content uid is: " + qaContent.getUid()); - Iterator itMap = mapQuestionContent.entrySet().iterator(); int displayOrder = 0; - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry) itMap.next(); + for ( QaQuestionContentDTO questionContentDTO : listQuestionContentDTO ) { // LDEV-2526 Assuming here that removed questions exist in mapQuestionContent, but that the value is empty // (this whole thing needs a rewrite). If empty, do not attempt to persist it. - if (StringUtils.isNotBlank(pairs.getValue().toString())) { - AuthoringUtil.logger.info("Persisting question with key=" + pairs.getKey() + " and value=" + pairs.getValue()); + // LDEV-2524 Partial rewrite - removed the old question and feedback maps and just use the original list. + // Overriding the displayOrder with a new displayOrder. + String questionText = questionContentDTO.getQuestion(); + if (StringUtils.isNotBlank(questionText)) { + AuthoringUtil.logger.info("Persisting question with key=" + questionText); - //++displayOrder; - displayOrder = new Integer(pairs.getKey().toString()); + ++displayOrder; - String currentFeedback = (String) mapFeedback.get(new Integer(displayOrder).toString()); - - //QaQueContent existingQaQueContent = qaService.getQuestionContentByDisplayOrder(new Long(displayOrder), - // qaContent.getUid()); - QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(pairs.getValue() - .toString(), qaContent.getUid()); - + QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(questionText, qaContent.getUid()); if (existingQaQueContent == null) { - //QaQueContent duplicateQaQueContent = qaService.getQuestionContentByQuestionText(pairs.getValue() - // .toString(), qaContent.getUid()); - QaQueContent queContent = new QaQueContent(pairs.getValue().toString(), displayOrder, currentFeedback, - qaContent, null, null); + QaQueContent queContent = new QaQueContent(questionText, displayOrder, questionContentDTO.getFeedback(), + questionContentDTO.isRequired(), qaContent, null, null); qaContent.getQaQueContents().add(queContent); queContent.setQaContent(qaContent); AuthoringUtil.logger.info("Creating new question with question=" + queContent.getQuestion() + ", displayOrder=" + queContent.getDisplayOrder()); qaService.createQaQue(queContent); } else { - String existingQuestion = existingQaQueContent.getQuestion(); - - existingQaQueContent.setQuestion(pairs.getValue().toString()); - existingQaQueContent.setFeedback(currentFeedback); + existingQaQueContent.setQuestion(questionText); + existingQaQueContent.setFeedback(questionContentDTO.getFeedback()); existingQaQueContent.setDisplayOrder(displayOrder); + existingQaQueContent.setRequired(questionContentDTO.isRequired()); AuthoringUtil.logger.info("Updating question with id=" + existingQaQueContent.getUid() + ", question=" + existingQaQueContent.getQuestion() + ", displayOrder=" + existingQaQueContent.getDisplayOrder()); qaService.saveOrUpdateQaQueContent(existingQaQueContent); } @@ -601,18 +549,11 @@ return qaContent; } - public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) { + public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) { AuthoringUtil.logger.debug("checkDuplicateQuestions: "); - - Map mapQuestionContent = extractMapQuestionContent(listQuestionContentDTO); - - Iterator itMap = mapQuestionContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry) itMap.next(); - if (pairs.getValue() != null && !pairs.getValue().equals("")) { - if (pairs.getValue().equals(newQuestion)) { - return true; - } + for (QaQuestionContentDTO questionDTO : listQuestionContentDTO ) { + if ( questionDTO.getQuestion() != null && questionDTO.getQuestion().equals(newQuestion) ) { + return true; } } return false; @@ -628,7 +569,7 @@ * @param qaAuthoringForm * @param qaContent */ - public void reOrganizeDisplayOrder(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm, + public void reOrganizeDisplayOrder(IQaService qaService, QaAuthoringForm qaAuthoringForm, QaContent qaContent) { if (qaContent != null) { AuthoringUtil.logger.debug("content uid: " + qaContent.getUid()); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaAuthoringForm.java,v diff -u -r1.25.4.1 -r1.25.4.1.4.1 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 11 May 2009 04:36:35 -0000 1.25.4.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringForm.java 1 Nov 2010 10:36:27 -0000 1.25.4.1.4.1 @@ -91,11 +91,11 @@ private String addSingleQuestion; private String editableQuestionIndex; private String feedback; + private boolean required; private String editQuestionBoxRequest; protected String defineLaterInEditMode; protected String defaultContentIdStr; - protected Map mapQuestionContent; protected IQaService qaService; protected boolean allowRichEditor; @@ -164,6 +164,7 @@ this.lockWhenFinished = OPTION_OFF; this.reflect = OPTION_OFF; this.allowRichEditor = false; + this.required = false; } public String toString() { @@ -720,21 +721,6 @@ } /** - * @return Returns the mapQuestionContent. - */ - public Map getMapQuestionContent() { - return mapQuestionContent; - } - - /** - * @param mapQuestionContent - * The mapQuestionContent to set. - */ - public void setMapQuestionContent(Map mapQuestionContent) { - this.mapQuestionContent = mapQuestionContent; - } - - /** * @return Returns the defineLaterInEditMode. */ public String getDefineLaterInEditMode() { @@ -891,4 +877,12 @@ public void setAllowRichEditor(boolean allowRichEditor) { this.allowRichEditor = allowRichEditor; } + + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java,v diff -u -r1.61 -r1.61.8.1 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 19 Feb 2009 23:59:14 -0000 1.61 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 1 Nov 2010 10:35:43 -0000 1.61.8.1 @@ -100,6 +100,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -674,19 +675,14 @@ Iterator queIterator = qaContent.getQaQueContents().iterator(); while (queIterator.hasNext()) { - QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); - QaQueContent qaQueContent = (QaQueContent) queIterator.next(); if (qaQueContent != null) { - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(qaQueContent); listQuestionContentDTO.add(qaQuestionContentDTO); } } request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); QaGeneralAuthoringDTO qaGeneralAuthoringDTO = (QaGeneralAuthoringDTO) request @@ -2147,18 +2143,11 @@ QaMonitoringAction.logger.debug("defaultContentIdStr: " + defaultContentIdStr); List listQuestionContentDTO = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY); - - Map mapQuestionContent = AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); - - - Map mapFeedback = AuthoringUtil.extractMapFeedback(listQuestionContentDTO); - - ActionMessages errors = new ActionMessages(); - QaMonitoringAction.logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); + QaMonitoringAction.logger.debug("listQuestionContentDTO size: " + listQuestionContentDTO.size()); - if (mapQuestionContent.size() == 0) { + if (listQuestionContentDTO.size() == 0) { ActionMessage error = new ActionMessage("questions.none.submitted"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } @@ -2180,7 +2169,6 @@ sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); QaMonitoringAction.logger.debug("qaGeneralAuthoringDTO now: " + qaGeneralAuthoringDTO); @@ -2202,11 +2190,11 @@ /* * to remove deleted entries in the questions table based on mapQuestionContent */ - authoringUtil.removeRedundantQuestions(mapQuestionContent, qaService, qaAuthoringForm, request, + authoringUtil.removeRedundantQuestions(listQuestionContentDTO, qaService, qaAuthoringForm, request, strToolContentID); QaMonitoringAction.logger.debug("end of removing unused entries... "); - qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, mapFeedback, qaService, + qaContent = authoringUtil.saveOrUpdateQaContent(listQuestionContentDTO, qaService, qaAuthoringForm, request, qaContentTest, strToolContentID, null); @@ -2220,7 +2208,7 @@ } - authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, qaService, qaAuthoringForm, qaContent); + authoringUtil.reOrganizeDisplayOrder(qaService, qaAuthoringForm, qaContent); QaMonitoringAction.logger.debug("strToolContentID: " + strToolContentID); QaUtils.setDefineLater(request, false, strToolContentID, qaService); @@ -2254,8 +2242,6 @@ qaGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); qaAuthoringForm.resetUserAction(); - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); @@ -2380,10 +2366,12 @@ String newQuestion = request.getParameter("newQuestion"); - - String feedback = request.getParameter("feedback"); - + String required = request.getParameter("required"); + boolean requiredBoolean = false; + if (required != null && required.equalsIgnoreCase("1")) { + requiredBoolean = true; + } String editableQuestionIndex = request.getParameter("editableQuestionIndex"); QaMonitoringAction.logger.debug("editableQuestionIndex: " + editableQuestionIndex); @@ -2415,6 +2403,7 @@ qaQuestionContentDTO.setQuestion(newQuestion); qaQuestionContentDTO.setFeedback(feedback); qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + qaQuestionContentDTO.setRequired(requiredBoolean); listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); @@ -2444,6 +2433,7 @@ qaQuestionContentDTO.setQuestion(newQuestion); qaQuestionContentDTO.setFeedback(feedback); qaQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + qaQuestionContentDTO.setRequired(requiredBoolean); listQuestionContentDTO = AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, qaQuestionContentDTO, editableQuestionIndex); @@ -2600,10 +2590,12 @@ String newQuestion = request.getParameter("newQuestion"); - - String feedback = request.getParameter("feedback"); - + String required = request.getParameter("required"); + boolean requiredBoolean = false; + if (required != null && required.equalsIgnoreCase("1")) { + requiredBoolean = true; + } int listSize = listQuestionContentDTO.size(); @@ -2613,11 +2605,8 @@ QaMonitoringAction.logger.debug("duplicates: " + duplicates); if (!duplicates) { - QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); - qaQuestionContentDTO.setDisplayOrder(new Long(listSize + 1).toString()); - qaQuestionContentDTO.setFeedback(feedback); - qaQuestionContentDTO.setQuestion(newQuestion); - + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(newQuestion, + new Long(listSize + 1).toString(), feedback, requiredBoolean); listQuestionContentDTO.add(qaQuestionContentDTO); } else { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java,v diff -u -r1.53 -r1.53.8.1 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 19 Feb 2009 23:59:14 -0000 1.53 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 1 Nov 2010 10:35:18 -0000 1.53.8.1 @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -178,17 +179,14 @@ Iterator queIterator = qaContent.getQaQueContents().iterator(); while (queIterator.hasNext()) { - QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); QaQueContent qaQueContent = (QaQueContent) queIterator.next(); if (qaQueContent != null) { - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(qaQueContent); listQuestionContentDTO.add(qaQuestionContentDTO); } } - + request.setAttribute(LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java,v diff -u -r1.71.4.1 -r1.71.4.1.4.1 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 11 May 2009 04:36:35 -0000 1.71.4.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 1 Nov 2010 10:33:53 -0000 1.71.4.1.4.1 @@ -125,6 +125,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -189,9 +190,6 @@ QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); - Map mapQuestionContent = new TreeMap(new QaComparator()); - QaStarterAction.logger.debug("mapQuestionContent: " + mapQuestionContent); - qaAuthoringForm.resetRadioBoxes(); IQaService qaService = null; @@ -319,7 +317,7 @@ /* fetch default content */ defaultContentIdStr = qaAuthoringForm.getDefaultContentIdStr(); QaStarterAction.logger.debug("defaultContentIdStr:" + defaultContentIdStr); - qaContent = retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, new Long( + qaContent = retrieveContent(request, mapping, qaAuthoringForm, new Long( defaultContentIdStr).longValue(), true, qaService, qaGeneralAuthoringDTO, sessionMap); QaStarterAction.logger.debug("post retrive content :" + sessionMap); @@ -336,7 +334,7 @@ QaStarterAction.logger.debug("add error.content.inUse to ActionMessages."); return mapping.findForward(QaAppConstants.ERROR_LIST); } - qaContent = retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, new Long( + qaContent = retrieveContent(request, mapping, qaAuthoringForm, new Long( strToolContentID).longValue(), false, qaService, qaGeneralAuthoringDTO, sessionMap); QaStarterAction.logger.debug("post retrive content :" + sessionMap); @@ -369,17 +367,9 @@ String destination = QaUtils.getDestination(sourceMcStarter, requestedModule); QaStarterAction.logger.debug("destination: " + destination); - Map mapQuestionContentLocal = qaGeneralAuthoringDTO.getMapQuestionContent(); - - - - sessionMap.put(QaAppConstants.MAP_QUESTION_CONTENT_KEY, mapQuestionContent); - QaStarterAction.logger.debug("persisting sessionMap into session: " + sessionMap); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - - request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); return mapping.findForward(destination); @@ -389,7 +379,7 @@ * retrives the existing content information from the db and prepares the * data for presentation purposes. ActionForward * retrieveExistingContent(HttpServletRequest request, ActionMapping - * mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long + * mapping, QaAuthoringForm qaAuthoringForm, long * toolContentID) * * @param request @@ -400,7 +390,7 @@ * @return ActionForward */ protected QaContent retrieveContent(HttpServletRequest request, ActionMapping mapping, - QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentID, boolean isDefaultContent, + QaAuthoringForm qaAuthoringForm, long toolContentID, boolean isDefaultContent, IQaService qaService, QaGeneralAuthoringDTO qaGeneralAuthoringDTO, SessionMap sessionMap) { QaStarterAction.logger.debug("toolContentID: " + toolContentID); @@ -447,52 +437,38 @@ sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaGeneralAuthoringDTO.getActivityTitle()); sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, qaGeneralAuthoringDTO.getActivityInstructions()); - List listQuestionContentDTO = new LinkedList(); + List listQuestionContentDTO = new LinkedList(); /* * get the existing question content */ - QaStarterAction.logger.debug("setting content data from the db"); - mapQuestionContent.clear(); + boolean isFirst = false; Iterator queIterator = qaContent.getQaQueContents().iterator(); - Long mapIndex = new Long(1); - while (queIterator.hasNext()) { - QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); QaQueContent qaQueContent = (QaQueContent) queIterator.next(); if (qaQueContent != null) { - - - - - mapQuestionContent.put(mapIndex.toString(), qaQueContent.getQuestion()); - - qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); - qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); + QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(qaQueContent); listQuestionContentDTO.add(qaQuestionContentDTO); /** * make the first entry the default(first) one for jsp */ - if (mapIndex.longValue() == 1) { + if (isFirst) { qaGeneralAuthoringDTO.setDefaultQuestionContent(qaQueContent.getQuestion()); + isFirst = false; } - mapIndex = new Long(mapIndex.longValue() + 1); } } - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(mapQuestionContent.size())); - - + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); SortedSet conditionSet = new TreeSet(new TextSearchConditionComparator()); for (QaCondition condition : qaContent.getConditions()) { conditionSet.add(condition); - for (QaQuestionContentDTO dto : (List) listQuestionContentDTO) { + for (QaQuestionContentDTO dto : listQuestionContentDTO) { for (QaQueContent question : condition.getQuestions()) { if (dto.getDisplayOrder().equals(String.valueOf(question.getDisplayOrder()))) { condition.temporaryQuestionDTOSet.add(dto); @@ -508,11 +484,6 @@ } - - qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - - - qaGeneralAuthoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); qaGeneralAuthoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions());