Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r289926a27bdbc9bd2519e3064a85f489fc1845ec -re4c72d9ff29d298b32927e0e1c0970b653acb86e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision e4c72d9ff29d298b32927e0e1c0970b653acb86e) @@ -57,21 +57,6 @@ private static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); /** - * returns McQuestionDTO in the specified order of the list - */ - public static McQuestionDTO getQuestionAtDisplayOrder(List questionDTOs, int intOriginalQuestionIndex) { - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = (McQuestionDTO) iter.next(); - - if (new Integer(intOriginalQuestionIndex).toString().equals(questionDto.getDisplayOrder())) { - return questionDto; - } - } - return null; - } - - /** * extractCandidateAtOrder */ public static McOptionDTO getOptionAtDisplayOrder(List options, int intOriginalCandidateIndex) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r289926a27bdbc9bd2519e3064a85f489fc1845ec -re4c72d9ff29d298b32927e0e1c0970b653acb86e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision e4c72d9ff29d298b32927e0e1c0970b653acb86e) @@ -165,13 +165,13 @@ McQuestionDTO questionDto = null; //editing existing question if (questionIndex != null) { - mcAuthoringForm.setQuestionIndex("" + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); //find according questionDto for (McQuestionDTO questionDtoIter : questionDtos) { Integer displayOrder = questionDtoIter.getDisplayOrder(); - if ((displayOrder != null) && (!displayOrder.equals("")) && displayOrder.equals(questionIndex)) { + if ((displayOrder != null) && displayOrder.equals(questionIndex)) { questionDto = questionDtoIter; break; } @@ -207,7 +207,7 @@ request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); Integer questionIndexToDelete = WebUtil.readIntParam(request, "questionIndex"); - mcAuthoringForm.setQuestionIndex("" + questionIndexToDelete); + mcAuthoringForm.setQuestionIndex(questionIndexToDelete); List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); @@ -218,18 +218,20 @@ String questionText = questionDTO.getQuestion(); Integer displayOrder = questionDTO.getDisplayOrder(); - if ((questionText != null) && (!questionText.isEmpty()) && !displayOrder.equals(questionIndexToDelete)) { + if ((questionText != null) && !questionText.isEmpty()) { - ++queIndex; - questionDTO.setDisplayOrder(queIndex); - tempQuestionDtos.add(questionDTO); + if (!displayOrder.equals(questionIndexToDelete)) { + ++queIndex; + questionDTO.setDisplayOrder(queIndex); + tempQuestionDtos.add(questionDTO); + + } else { + List deletedQuestionDTOs = (List) sessionMap + .get(McAppConstants.LIST_DELETED_QUESTION_DTOS); + deletedQuestionDTOs.add(questionDTO); + sessionMap.put(McAppConstants.LIST_DELETED_QUESTION_DTOS, deletedQuestionDTOs); + } } - if ((questionText != null) && (!questionText.isEmpty()) && displayOrder.equals(questionIndexToDelete)) { - List deletedQuestionDTOs = (List) sessionMap - .get(McAppConstants.LIST_DELETED_QUESTION_DTOS); - deletedQuestionDTOs.add(questionDTO); - sessionMap.put(McAppConstants.LIST_DELETED_QUESTION_DTOS, deletedQuestionDTOs); - } } questionDTOs = tempQuestionDtos; sessionMap.put(McAppConstants.QUESTION_DTOS, questionDTOs); @@ -257,7 +259,7 @@ .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - String questionIndex = request.getParameter("questionIndex"); + Integer questionIndex = WebUtil.readIntParam(request, "questionIndex"); mcAuthoringForm.setQuestionIndex(questionIndex); List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); @@ -276,7 +278,7 @@ .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - String questionIndex = request.getParameter("questionIndex"); + Integer questionIndex = WebUtil.readIntParam(request, "questionIndex"); mcAuthoringForm.setQuestionIndex(questionIndex); List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); @@ -290,21 +292,13 @@ /* * swappes McQuestionDTO questions in the list. Auxiliary method for moveQuestionDown() and moveQuestionUp() */ - private static List swapQuestions(List questionDTOs, String questionIndex, + private static List swapQuestions(List questionDTOs, Integer originalQuestionIndex, String direction) { - int intQuestionIndex = new Integer(questionIndex).intValue(); - int intOriginalQuestionIndex = intQuestionIndex; + int replacedQuestionIndex = direction.equals("down") ? originalQuestionIndex + 1 : originalQuestionIndex - 1; - int replacedQuestionIndex = 0; - if (direction.equals("down")) { - replacedQuestionIndex = ++intQuestionIndex; - } else { - replacedQuestionIndex = --intQuestionIndex; - } - - McQuestionDTO mainQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, intOriginalQuestionIndex); - McQuestionDTO replacedQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, replacedQuestionIndex); + McQuestionDTO mainQuestion = questionDTOs.get(originalQuestionIndex - 1); + McQuestionDTO replacedQuestion = questionDTOs.get(replacedQuestionIndex - 1); if ((mainQuestion == null) || (replacedQuestion == null)) { return questionDTOs; } @@ -316,16 +310,16 @@ McQuestionDTO questionDto = iter.next(); McQuestionDTO tempQuestion = new McQuestionDTO(); - if ((!questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) - && !questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { + if ((!questionDto.getDisplayOrder().equals(originalQuestionIndex)) + && !questionDto.getDisplayOrder().equals(replacedQuestionIndex)) { // normal copy tempQuestion = questionDto; - } else if (questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) { + } else if (questionDto.getDisplayOrder().equals(originalQuestionIndex)) { // move type 1 tempQuestion = replacedQuestion; - } else if (questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { + } else if (questionDto.getDisplayOrder().equals(replacedQuestionIndex)) { // move type 2 tempQuestion = mainQuestion; } @@ -396,7 +390,7 @@ String newQuestion = request.getParameter("newQuestion"); String feedback = request.getParameter("feedback"); Integer questionIndex = WebUtil.readIntParam(request, "questionIndex", true); - mcAuthoringForm.setQuestionIndex("" + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); if ((newQuestion != null) && (newQuestion.length() > 0)) { // adding new question @@ -406,7 +400,7 @@ if (!duplicates) { //finding max displayOrder - int maxDisplayOrder = 1; + int maxDisplayOrder = 0; for (McQuestionDTO questionDTO : questionDTOs) { int displayOrder = new Integer(questionDTO.getDisplayOrder()); if (displayOrder > maxDisplayOrder) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -rec381d32c228f460e0fd3ce3857aab14d4f6fd87 -re4c72d9ff29d298b32927e0e1c0970b653acb86e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision ec381d32c228f460e0fd3ce3857aab14d4f6fd87) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision e4c72d9ff29d298b32927e0e1c0970b653acb86e) @@ -336,17 +336,16 @@ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent); Integer totalQuestionCount = mcGeneralLearnerFlowDTO.getTotalQuestionCount(); - String questionIndex = mcLearningForm.getQuestionIndex(); - Integer intQuestionIndex = new Integer(questionIndex); - if (totalQuestionCount.equals(intQuestionIndex)) { + Integer questionIndex = mcLearningForm.getQuestionIndex(); + if (totalQuestionCount.equals(questionIndex)) { mcGeneralLearnerFlowDTO.setTotalCountReached(new Boolean(true).toString()); } mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString()); mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString()); mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcContent.getTotalMarksPossible()); - mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(questionIndex)); + mcGeneralLearnerFlowDTO.setQuestionIndex(questionIndex); request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); LearningWebUtil.putActivityPositionInRequestByToolSessionId(new Long(toolSessionID), request, Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java =================================================================== diff -u -r289926a27bdbc9bd2519e3064a85f489fc1845ec -re4c72d9ff29d298b32927e0e1c0970b653acb86e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java (.../McAuthoringForm.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java (.../McAuthoringForm.java) (revision e4c72d9ff29d298b32927e0e1c0970b653acb86e) @@ -30,7 +30,6 @@ public class McAuthoringForm extends McLearningForm { /* form controllers */ - protected String questionIndex; protected String optionIndex; protected String showMarks; @@ -67,23 +66,6 @@ private String candidateIndex; /** - * @return Returns the questionIndex. - */ - @Override - public String getQuestionIndex() { - return questionIndex; - } - - /** - * @param questionIndex - * The questionIndex to set. - */ - @Override - public void setQuestionIndex(String questionIndex) { - this.questionIndex = questionIndex; - } - - /** * @return Returns the submitAllContent. */ public String getSubmitAllContent() { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java =================================================================== diff -u -r289926a27bdbc9bd2519e3064a85f489fc1845ec -re4c72d9ff29d298b32927e0e1c0970b653acb86e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java (.../McLearningForm.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java (.../McLearningForm.java) (revision e4c72d9ff29d298b32927e0e1c0970b653acb86e) @@ -60,7 +60,7 @@ protected String entryText; - protected String questionIndex; + protected Integer questionIndex; protected String nextQuestionSelected; protected String httpSessionID; @@ -283,15 +283,15 @@ /** * @return Returns the questionIndex. */ - public String getQuestionIndex() { + public Integer getQuestionIndex() { return questionIndex; } /** * @param questionIndex * The questionIndex to set. */ - public void setQuestionIndex(String questionIndex) { + public void setQuestionIndex(Integer questionIndex) { this.questionIndex = questionIndex; }