Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/AnswerDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -27,7 +27,7 @@ */ public interface McAppConstants { - public static final String MY_SIGNATURE = "lamc11"; + public static final String TOOL_SIGNATURE = "lamc11"; /* * Struts level constants @@ -37,12 +37,10 @@ public static final String LOAD_LEARNER = "loadLearner"; public static final String LOAD_MONITORING_CONTENT = "loadMonitoring"; public static final String ERROR_LIST = "errorList"; - public static final String LIST_QUESTION_DTOS = "listQuestionContentDTO"; + public static final String QUESTION_DTOS = "questionDtos"; public static final String LIST_DELETED_QUESTION_DTOS = "deletedQuestionDTOs"; - public static final String MC_GENERAL_AUTHORING_DTO = "mcGeneralAuthoringDTO"; - public static final String CURRENT_EDITABLE_QUESTION_INDEX = "currentEditableQuestionIndex"; public static final String MC_GENERAL_MONITORING_DTO = "mcGeneralMonitoringDTO"; - public static final String NEW_QUESTION_DTO = "newQuestionDTO"; + public static final String QUESTION_DTO = "questionDto"; public static final String REFLECTION_SUBJECT = "reflectionSubject"; public static final String REFLECTIONS_CONTAINER_DTO = "reflectionsContainerDTO"; @@ -85,7 +83,6 @@ /* learner mode contants */ public static final String LEARNER_ANSWERS_DTO_LIST = "learnerAnswersDTOList"; public static final String MC_GENERAL_LEARNER_FLOW_DTO = "mcGeneralLearnerFlowDTO"; - public static final String TOTAL_QUESTION_COUNT = "totalQuestionCount"; public static final String NOTEBOOK = "notebook"; public static final String ENTRY_TEXT = "entryText"; Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McApplicationException.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McComparator.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralAuthoringDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralMonitoringDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McOptionDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQuestionDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McSessionMarkDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McStringComparator.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUserMarkDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/ReflectionDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -24,7 +24,7 @@ import java.util.List; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; /** Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -24,7 +24,7 @@ import java.util.List; -import org.lamsfoundation.lams.tool.mc.McUserMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.McUserMarkDTO; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; /** Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -27,8 +27,8 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; import org.lamsfoundation.lams.tool.mc.dao.IMcOptionsContentDAO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; import org.springframework.stereotype.Repository; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java (.../McUserDAO.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java (.../McUserDAO.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -28,8 +28,8 @@ import org.hibernate.FlushMode; import org.hibernate.Query; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; -import org.lamsfoundation.lams.tool.mc.McUserMarkDTO; import org.lamsfoundation.lams.tool.mc.dao.IMcUserDAO; +import org.lamsfoundation.lams.tool.mc.dto.McUserMarkDTO; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; import org.springframework.stereotype.Repository; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/AnswerDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/AnswerDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/AnswerDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,224 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import java.util.List; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; + +/** + *

+ * DTO that holds question and candidate answers for the learner environment + *

+ * + * @author Ozgur Demirtas + */ +public class AnswerDTO implements Comparable { + protected String question; + + protected String displayOrder; + + protected Long questionUid; + + protected Integer mark; + + protected McOptsContent answerOption; + + protected List options; + + protected boolean attemptCorrect; + + protected String feedbackIncorrect; + + protected String feedbackCorrect; + + protected String feedback; + + /** + * @return Returns the answerOption. + */ + public McOptsContent getAnswerOption() { + return answerOption; + } + + /** + * @param answerOption + * The answerOption to set. + */ + public void setAnswerOption(McOptsContent answerOption) { + this.answerOption = answerOption; + } + + /** + * @return Returns the options. + */ + public List getOptions() { + return options; + } + + /** + * @param options + * The options to set. + */ + public void setOptions(List options) { + this.options = options; + } + + /** + * @return Returns the question. + */ + public String getQuestion() { + return question; + } + + /** + * @param question + * The question to set. + */ + public void setQuestion(String question) { + this.question = question; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("question: ", getQuestion()).append("displayOrder: ", getDisplayOrder()) + .append("answerOption: ", getAnswerOption()).toString(); + } + + @Override + public int compareTo(Object o) { + AnswerDTO answerDto = (AnswerDTO) o; + + if (answerDto == null) { + return 1; + } else { + return 0; + } + } + + /** + * @return Returns the displayOrder. + */ + public String getDisplayOrder() { + return displayOrder; + } + + /** + * @param displayOrder + * The displayOrder to set. + */ + public void setDisplayOrder(String displayOrder) { + this.displayOrder = displayOrder; + } + + /** + * @return Returns the questionUid. + */ + public Long getQuestionUid() { + return questionUid; + } + + /** + * @param questionUid + * The questionUid to set. + */ + public void setQuestionUid(Long questionUid) { + this.questionUid = questionUid; + } + + /** + * @return Returns the feedbackCorrect. + */ + public String getFeedbackCorrect() { + return feedbackCorrect; + } + + /** + * @param feedbackCorrect + * The feedbackCorrect to set. + */ + public void setFeedbackCorrect(String feedbackCorrect) { + this.feedbackCorrect = feedbackCorrect; + } + + /** + * @return Returns the attemptCorrect. + */ + public boolean isAttemptCorrect() { + return attemptCorrect; + } + + /** + * @param attemptCorrect + * The attemptCorrect to set. + */ + public void setAttemptCorrect(boolean attemptCorrect) { + this.attemptCorrect = attemptCorrect; + } + + /** + * @return Returns the feedbackIncorrect. + */ + public String getFeedbackIncorrect() { + return feedbackIncorrect; + } + + /** + * @param feedbackIncorrect + * The feedbackIncorrect to set. + */ + public void setFeedbackIncorrect(String feedbackIncorrect) { + this.feedbackIncorrect = feedbackIncorrect; + } + + /** + * @return Returns the mark. + */ + public Integer getMark() { + return mark; + } + + /** + * @param mark + * The mark to set. + */ + public void setMark(Integer mark) { + this.mark = mark; + } + + /** + * @return Returns the feedback. + */ + public String getFeedback() { + return feedback; + } + + /** + * @param feedback + * The feedback to set. + */ + public void setFeedback(String feedback) { + this.feedback = feedback; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralLearnerFlowDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralLearnerFlowDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralLearnerFlowDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,581 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import java.util.Map; + +import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt; + +/** + *

+ * DTO that holds learner flow decision properties and some other view-only properties + *

+ * + * @author Ozgur Demirtas + */ +public class McGeneralLearnerFlowDTO implements Comparable { + protected String retries; + + protected Integer learnerMark; + + protected String userName; + + protected Integer totalQuestionCount; + + protected Integer passMark; + + protected String passMarkApplicable; + + protected String userPassed; + + protected String userOverPassMark; + + protected String reportTitleLearner; + + protected String activityInstructions; + + protected String activityTitle; + + protected Integer currentQuestionIndex; + + protected String countSessionComplete; + + protected Integer topMark; + + protected String reflection; + + protected String reflectionSubject; + + protected String notebookEntry; + + protected String notebookEntriesVisible; + + protected Integer lowestMark; + + protected Integer averageMark; + + protected String showMarks; + + protected String displayAnswers; + + protected Map mapGeneralOptionsContent; + + protected Map mapQuestionsContent; + + protected String toolSessionId; + + protected String totalCountReached; + + protected Integer questionIndex; + + protected Integer totalMarksPossible; + + protected Map mapFeedbackContent; + + protected Map attemptMap; + + /** + * @return Returns the mapFeedbackContent. + */ + public Map getMapFeedbackContent() { + return mapFeedbackContent; + } + + /** + * @param mapFeedbackContent + * The mapFeedbackContent to set. + */ + public void setMapFeedbackContent(Map mapFeedbackContent) { + this.mapFeedbackContent = mapFeedbackContent; + } + + /** + * @return Returns the questionIndex. + */ + public Integer getQuestionIndex() { + return questionIndex; + } + + /** + * @param questionIndex + * The questionIndex to set. + */ + public void setQuestionIndex(Integer questionIndex) { + this.questionIndex = questionIndex; + } + + /** + * @return Returns the totalCountReached. + */ + public String getTotalCountReached() { + return totalCountReached; + } + + /** + * @param totalCountReached + * The totalCountReached to set. + */ + public void setTotalCountReached(String totalCountReached) { + this.totalCountReached = totalCountReached; + } + + /** + * @return Returns the toolSessionId. + */ + public String getToolSessionId() { + return toolSessionId; + } + + /** + * @param toolSessionId + * The toolSessionId to set. + */ + public void setToolSessionId(String toolSessionId) { + this.toolSessionId = toolSessionId; + } + + /** + * @return Returns the mapGeneralOptionsContent. + */ + public Map getMapGeneralOptionsContent() { + return mapGeneralOptionsContent; + } + + /** + * @param mapGeneralOptionsContent + * The mapGeneralOptionsContent to set. + */ + public void setMapGeneralOptionsContent(Map mapGeneralOptionsContent) { + this.mapGeneralOptionsContent = mapGeneralOptionsContent; + } + + /** + * @return Returns the averageMark. + */ + public Integer getAverageMark() { + return averageMark; + } + + /** + * @param averageMark + * The averageMark to set. + */ + public void setAverageMark(Integer averageMark) { + this.averageMark = averageMark; + } + + /** + * @return Returns the countSessionComplete. + */ + public String getCountSessionComplete() { + return countSessionComplete; + } + + /** + * @param countSessionComplete + * The countSessionComplete to set. + */ + public void setCountSessionComplete(String countSessionComplete) { + this.countSessionComplete = countSessionComplete; + } + + /** + * @return Returns the lowestMark. + */ + public Integer getLowestMark() { + return lowestMark; + } + + /** + * @param lowestMark + * The lowestMark to set. + */ + public void setLowestMark(Integer lowestMark) { + this.lowestMark = lowestMark; + } + + /** + * @return Returns the topMark. + */ + public Integer getTopMark() { + return topMark; + } + + /** + * @param topMark + * The topMark to set. + */ + public void setTopMark(Integer topMark) { + this.topMark = topMark; + } + + /** + * @return Returns the activityInstructions. + */ + public String getActivityInstructions() { + return activityInstructions; + } + + /** + * @param activityInstructions + * The activityInstructions to set. + */ + public void setActivityInstructions(String activityInstructions) { + this.activityInstructions = activityInstructions; + } + + /** + * @return Returns the learnerMark. + */ + public Integer getLearnerMark() { + return learnerMark; + } + + /** + * @param learnerMark + * The learnerMark to set. + */ + public void setLearnerMark(Integer learnerMark) { + this.learnerMark = learnerMark; + } + + /** + * @return Returns the passMark. + */ + public Integer getPassMark() { + return passMark; + } + + /** + * @param passMark + * The passMark to set. + */ + public void setPassMark(Integer passMark) { + this.passMark = passMark; + } + + /** + * @return Returns the passMarkApplicable. + */ + public String getPassMarkApplicable() { + return passMarkApplicable; + } + + /** + * @param passMarkApplicable + * The passMarkApplicable to set. + */ + public void setPassMarkApplicable(String passMarkApplicable) { + this.passMarkApplicable = passMarkApplicable; + } + + /** + * @return Returns the reportTitleLearner. + */ + public String getReportTitleLearner() { + return reportTitleLearner; + } + + /** + * @param reportTitleLearner + * The reportTitleLearner to set. + */ + public void setReportTitleLearner(String reportTitleLearner) { + this.reportTitleLearner = reportTitleLearner; + } + + /** + * @return Returns the totalQuestionCount. + */ + public Integer getTotalQuestionCount() { + return totalQuestionCount; + } + + /** + * @param totalQuestionCount + * The totalQuestionCount to set. + */ + public void setTotalQuestionCount(Integer totalQuestionCount) { + this.totalQuestionCount = totalQuestionCount; + } + + /** + * @return Returns the userOverPassMark. + */ + public String getUserOverPassMark() { + return userOverPassMark; + } + + /** + * @param userOverPassMark + * The userOverPassMark to set. + */ + public void setUserOverPassMark(String userOverPassMark) { + this.userOverPassMark = userOverPassMark; + } + + @Override + public int compareTo(Object o) { + McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = (McGeneralLearnerFlowDTO) o; + + if (mcGeneralLearnerFlowDTO == null) { + return 1; + } else { + return 0; + } + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("retries: ", retries) + .append("mapGeneralOptionsContent: ", mapGeneralOptionsContent).append("learnerMark : ", learnerMark) + .append("totalQuestionCount: ", totalQuestionCount).append("passMark: ", passMark) + .append("passMarkApplicable: ", passMarkApplicable).append("userPassed: ", userPassed) + .append("userOverPassMark: ", userOverPassMark).append("reportTitleLearner: ", reportTitleLearner) + .append("activityInstructions: ", activityInstructions).append("activityTitle: ", activityTitle) + .append("displayAnswers: ", displayAnswers).append("reflection: ", reflection) + .append("reflectionSubject: ", reflectionSubject).append("notebookEntry: ", notebookEntry) + .append("notebookEntriesVisible: ", notebookEntriesVisible).toString(); + } + + /** + * @return Returns the retries. + */ + public String getRetries() { + return retries; + } + + /** + * @param retries + * The retries to set. + */ + public void setRetries(String retries) { + this.retries = retries; + } + + /** + * @return Returns the activityTitle. + */ + public String getActivityTitle() { + return activityTitle; + } + + /** + * @param activityTitle + * The activityTitle to set. + */ + public void setActivityTitle(String activityTitle) { + this.activityTitle = activityTitle; + } + + /** + * @return Returns the userPassed. + */ + public String getUserPassed() { + return userPassed; + } + + /** + * @param userPassed + * The userPassed to set. + */ + public void setUserPassed(String userPassed) { + this.userPassed = userPassed; + } + + /** + * @return Returns the currentQuestionIndex. + */ + public Integer getCurrentQuestionIndex() { + return currentQuestionIndex; + } + + /** + * @param currentQuestionIndex + * The currentQuestionIndex to set. + */ + public void setCurrentQuestionIndex(Integer currentQuestionIndex) { + this.currentQuestionIndex = currentQuestionIndex; + } + + /** + * @return Returns the mapQuestionsContent. + */ + public Map getMapQuestionsContent() { + return mapQuestionsContent; + } + + /** + * @param mapQuestionsContent + * The mapQuestionsContent to set. + */ + public void setMapQuestionsContent(Map mapQuestionsContent) { + this.mapQuestionsContent = mapQuestionsContent; + } + + /** + * @return Returns the reflection. + */ + public String getReflection() { + return reflection; + } + + /** + * @param reflection + * The reflection to set. + */ + public void setReflection(String reflection) { + this.reflection = reflection; + } + + /** + * @return Returns the reflectionSubject. + */ + public String getReflectionSubject() { + return reflectionSubject; + } + + /** + * @param reflectionSubject + * The reflectionSubject to set. + */ + public void setReflectionSubject(String reflectionSubject) { + this.reflectionSubject = reflectionSubject; + } + + /** + * @return Returns the notebookEntry. + */ + public String getNotebookEntry() { + return notebookEntry; + } + + /** + * @param notebookEntry + * The notebookEntry to set. + */ + public void setNotebookEntry(String notebookEntry) { + this.notebookEntry = notebookEntry; + } + + /** + * @return Returns the notebookEntriesVisible. + */ + public String getNotebookEntriesVisible() { + return notebookEntriesVisible; + } + + /** + * @param notebookEntriesVisible + * The notebookEntriesVisible to set. + */ + public void setNotebookEntriesVisible(String notebookEntriesVisible) { + this.notebookEntriesVisible = notebookEntriesVisible; + } + + /** + * @return Returns the userName. + */ + public String getUserName() { + return userName; + } + + /** + * @param userName + * The userName to set. + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * @return Returns the totalMarksPossible. + */ + public Integer getTotalMarksPossible() { + return totalMarksPossible; + } + + /** + * @param totalMarksPossible + * The totalMarksPossible to set. + */ + public void setTotalMarksPossible(Integer totalMarksPossible) { + this.totalMarksPossible = totalMarksPossible; + } + + /** + * If using for a display screen then showMarks controls whether or not to show the average and top marks for the + * session. If using for the "get answers" screens, then this controls whether or not to show the marks for each + * question - this allows us to NOT show the marks if ALL of the questions have a mark of 1. + * + * @return Returns the showMarks. + */ + public String getShowMarks() { + return showMarks; + } + + /** + * See getShowMarks() for the meaning of "showMarks". + * + * @param showMarks + * The showMarks to set. + */ + public void setShowMarks(String showMarks) { + this.showMarks = showMarks; + } + + /** + * Displays answers on the screen + * + * @return Returns the displayAnswers. + */ + public String getDisplayAnswers() { + return displayAnswers; + } + + /** + * See getDisplayAnswers() for the meaning of "displayAnswers". + * + * @param displayAnswers + * The displayAnswers to set. + */ + public void setDisplayAnswers(String displayAnswers) { + this.displayAnswers = displayAnswers; + } + + /** + * @return Returns the attemptMap. + */ + public Map getAttemptMap() { + return attemptMap; + } + + /** + * @param attemptMap + * The attemptMap to set. + */ + public void setAttemptMap(Map attemptMap) { + this.attemptMap = attemptMap; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralMonitoringDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralMonitoringDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McGeneralMonitoringDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,147 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +/** + *

+ * DTO that holds monitoring flow properties + *

+ * + * @author Ozgur Demirtas + */ +public class McGeneralMonitoringDTO { + + protected String activityTitle; + protected String activityInstructions; + protected Integer countAllUsers; + protected Integer countSessionComplete; + protected String displayAnswers; + protected String toolContentID; + + protected String contentFolderID; + + /** + * @return Returns the activityInstructions. + */ + public String getActivityInstructions() { + return activityInstructions; + } + + /** + * @param activityInstructions + * The activityInstructions to set. + */ + public void setActivityInstructions(String activityInstructions) { + this.activityInstructions = activityInstructions; + } + + /** + * @return Returns the activityTitle. + */ + public String getActivityTitle() { + return activityTitle; + } + + /** + * @param activityTitle + * The activityTitle to set. + */ + public void setActivityTitle(String activityTitle) { + this.activityTitle = activityTitle; + } + + /** + * @return Returns the countAllUsers. + */ + public Integer getCountAllUsers() { + return countAllUsers; + } + + /** + * @param countAllUsers + * The countAllUsers to set. + */ + public void setCountAllUsers(Integer countAllUsers) { + this.countAllUsers = countAllUsers; + } + + /** + * @return Returns the countSessionComplete. + */ + public Integer getCountSessionComplete() { + return countSessionComplete; + } + + /** + * @param countSessionComplete + * The countSessionComplete to set. + */ + public void setCountSessionComplete(Integer countSessionComplete) { + this.countSessionComplete = countSessionComplete; + } + + /** + * @return Returns the displayAnswers. + */ + public String getDisplayAnswers() { + return displayAnswers; + } + + /** + * @param displayAnswers + * The displayAnswers to set. + */ + public void setDisplayAnswers(String displayAnswers) { + this.displayAnswers = displayAnswers; + } + + /** + * @return Returns the toolContentID. + */ + public String getToolContentID() { + return toolContentID; + } + + /** + * @param toolContentID + * The toolContentID to set. + */ + public void setToolContentID(String toolContentID) { + this.toolContentID = toolContentID; + } + + /** + * @return Returns the contentFolderID. + */ + public String getContentFolderID() { + return contentFolderID; + } + + /** + * @param contentFolderID + * The contentFolderID to set. + */ + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McOptionDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McOptionDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McOptionDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,110 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; + +/** + * DTO that holds candiate answers data for summary page + * + * @author Ozgur Demirtas + */ +public class McOptionDTO implements Comparable { + + private Long uid; + private String candidateAnswer; + private String correct; + + public McOptionDTO() { + + } + + public McOptionDTO(McOptsContent option) { + this.uid = option.getUid(); + this.candidateAnswer = option.getMcQueOptionText(); + //this.correct = new Boolean(option.isCorrectOption()).toString(); + + if (option.isCorrectOption()) { + this.correct = "Correct"; + } else { + this.correct = "Incorrect"; + } + } + + /** + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @return Returns the candidateAnswer. + */ + public String getCandidateAnswer() { + return candidateAnswer; + } + + /** + * @param candidateAnswer + * The candidateAnswer to set. + */ + public void setCandidateAnswer(String candidateAnswer) { + this.candidateAnswer = candidateAnswer; + } + + /** + * @return Returns the correct. + */ + public String getCorrect() { + return correct; + } + + /** + * @param correct + * The correct to set. + */ + public void setCorrect(String correct) { + this.correct = correct; + } + + @Override + public int compareTo(Object o) { + McOptionDTO mcOptionDTO = (McOptionDTO) o; + + if (mcOptionDTO == null) { + return 1; + } else { + return 0; + } + } + +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,141 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mc.dto; + +import java.util.List; + +/** + * DTO that holds users attempt history data for jsp purposes + * + * @author Ozgur Demirtas + */ +public class McQuestionDTO implements Comparable { + private Long uid; + private String question; + private Integer displayOrder; + private String feedback; + private String mark; + + private List optionDtos; + + @Override + public int compareTo(McQuestionDTO mcQuestionDTO) { + + if (mcQuestionDTO == null) { + return 1; + } else { + return 0; + } + } + + /** + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @return Returns the displayOrder. + */ + public Integer getDisplayOrder() { + return displayOrder; + } + + /** + * @param displayOrder + * The displayOrder to set. + */ + public void setDisplayOrder(Integer displayOrder) { + this.displayOrder = displayOrder; + } + + /** + * @return Returns the feedback. + */ + public String getFeedback() { + return feedback; + } + + /** + * @param feedback + * The feedback to set. + */ + public void setFeedback(String feedback) { + this.feedback = feedback; + } + + /** + * @return Returns the question. + */ + public String getQuestion() { + return question; + } + + /** + * @param question + * The question to set. + */ + public void setQuestion(String question) { + this.question = question; + } + + /** + * @return Returns the mark. + */ + public String getMark() { + return mark; + } + + /** + * @param mark + * The mark to set. + */ + public void setMark(String mark) { + this.mark = mark; + } + + /** + * @return Returns the optionDtos. + */ + public List getOptionDtos() { + return optionDtos; + } + + /** + * @param optionDtos + * The optionDtos to set. + */ + public void setOptionDtos(List optionDtos) { + this.optionDtos = optionDtos; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McSessionMarkDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McSessionMarkDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McSessionMarkDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,102 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import java.util.Map; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + *

+ * DTO that hols session user marks + *

+ * + * @author Ozgur Demirtas + */ +public class McSessionMarkDTO implements Comparable { + private String sessionId; + private String sessionName; + private Map userMarks; + + @Override + public String toString() { + return new ToStringBuilder(this).append("Listing SessionMarkDTO: ").append("sessionId: ", sessionId) + .append("sessionName: ", sessionName).append("userMarks: ", userMarks).toString(); + } + + @Override + public int compareTo(Object o) { + McSessionMarkDTO mcSessionMarkDTO = (McSessionMarkDTO) o; + + if (mcSessionMarkDTO == null) { + return 1; + } else { + return (int) (new Long(sessionId).longValue() - new Long(mcSessionMarkDTO.sessionId).longValue()); + } + } + + /** + * @return Returns the sessionId. + */ + public String getSessionId() { + return sessionId; + } + + /** + * @param sessionId + * The sessionId to set. + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** + * @return Returns the sessionName. + */ + public String getSessionName() { + return sessionName; + } + + /** + * @param sessionName + * The sessionName to set. + */ + public void setSessionName(String sessionName) { + this.sessionName = sessionName; + } + + /** + * @return Returns the userMarks. + */ + public Map getUserMarks() { + return userMarks; + } + + /** + * @param userMarks + * The userMarks to set. + */ + public void setUserMarks(Map userMarks) { + this.userMarks = userMarks; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McUserMarkDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McUserMarkDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McUserMarkDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,208 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import java.util.Date; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + *

+ * DTO that hols user marks + *

+ * + * @author Ozgur Demirtas + */ +public class McUserMarkDTO implements Comparable { + private String sessionId; + private String sessionName; + private String queUsrId; + private String userName; + private String fullName; + private boolean isUserLeader; + private Date attemptTime; + private Integer[] marks; + private String[] answeredOptions; + private Long totalMark; + + @Override + public String toString() { + return new ToStringBuilder(this).append("Listing UserMarkDTO:").append("sessionId", sessionId) + .append("queUsrId", queUsrId).append("userName", userName).append("fullName", fullName) + .append("marks", marks).append("totalMark", totalMark).append("attemptTime", attemptTime).toString(); + } + + /** + * @return Returns the marks. + */ + public Integer[] getMarks() { + return marks; + } + + /** + * @param marks + * The marks to set. + */ + public void setMarks(Integer[] marks) { + this.marks = marks; + } + + /** + * @return Returns the answeredOptions - sequencial letter of the option that was chosen. + */ + public String[] getAnsweredOptions() { + return answeredOptions; + } + + /** + * @param answeredOptions + * The answeredOptions to set. + */ + public void setAnsweredOptions(String[] answeredOptions) { + this.answeredOptions = answeredOptions; + } + + /** + * @return Returns the queUsrId. + */ + public String getQueUsrId() { + return queUsrId; + } + + /** + * @param queUsrId + * The queUsrId to set. + */ + public void setQueUsrId(String queUsrId) { + this.queUsrId = queUsrId; + } + + /** + * @return Returns the userName. + */ + public String getUserName() { + return userName; + } + + /** + * @param userName + * The userName to set. + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * @return Returns the userName. + */ + public String getFullName() { + return fullName; + } + + /** + * @param userName + * The userName to set. + */ + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public boolean setUserGroupLeader(boolean isUserLeader) { + return this.isUserLeader = isUserLeader; + } + + public boolean isUserGroupLeader() { + return isUserLeader; + } + + @Override + public int compareTo(Object o) { + McUserMarkDTO mcUserMarkDTO = (McUserMarkDTO) o; + + if (mcUserMarkDTO == null) { + return 1; + } else { + return (int) (new Long(queUsrId).longValue() - new Long(mcUserMarkDTO.queUsrId).longValue()); + } + } + + /** + * @return Returns the sessionId. + */ + public String getSessionId() { + return sessionId; + } + + /** + * @param sessionId + * The sessionId to set. + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** + * @return Returns the totalMark. + */ + public Long getTotalMark() { + return totalMark; + } + + /** + * @param totalMark + * The totalMark to set. + */ + public void setTotalMark(Long totalMark) { + this.totalMark = totalMark; + } + + /** + * @return Returns the sessionName. + */ + public String getSessionName() { + return sessionName; + } + + /** + * @param sessionName + * The sessionName to set. + */ + public void setSessionName(String sessionName) { + this.sessionName = sessionName; + } + + /** + * @return Returns the attemptTime. + */ + public Date getAttemptTime() { + return attemptTime; + } + + /** + * @param attemptTime + * The attemptTime to set. + */ + public void setAttemptTime(Date attemptTime) { + this.attemptTime = attemptTime; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/ReflectionDTO.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/ReflectionDTO.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/ReflectionDTO.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,137 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.dto; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + *

+ * DTO that holds reflections from users + *

+ * + * @author Ozgur Demirtas + */ +public class ReflectionDTO implements Comparable { + protected String userName; + + protected String userId; + + protected String sessionId; + + protected String reflectionUid; + + protected String entry; + + @Override + public int compareTo(Object o) { + ReflectionDTO reflectionDTO = (ReflectionDTO) o; + + if (reflectionDTO == null) { + return 1; + } else { + return 0; + } + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("userName: ", userName).append("userId: ", userId) + .append("sessionId: ", sessionId).append("reflectionUid: ", reflectionUid).append("entry: ", entry) + .toString(); + } + + /** + * @return Returns the entry. + */ + public String getEntry() { + return entry; + } + + /** + * @param entry + * The entry to set. + */ + public void setEntry(String entry) { + this.entry = entry; + } + + /** + * @return Returns the sessionId. + */ + public String getSessionId() { + return sessionId; + } + + /** + * @param sessionId + * The sessionId to set. + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + /** + * @return Returns the reflectionUid. + */ + public String getReflectionUid() { + return reflectionUid; + } + + /** + * @param reflectionUid + * The reflectionUid to set. + */ + public void setReflectionUid(String reflectionUid) { + this.reflectionUid = reflectionUid; + } + + /** + * @return Returns the userId. + */ + public String getUserId() { + return userId; + } + + /** + * @param userId + * The userId to set. + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * @return Returns the userName. + */ + public String getUserName() { + return userName; + } + + /** + * @param userName + * The userName to set. + */ + public void setUserName(String userName) { + this.userName = userName; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -31,13 +31,12 @@ import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; -import org.lamsfoundation.lams.tool.mc.AnswerDTO; -import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; -import org.lamsfoundation.lams.tool.mc.McQuestionDTO; -import org.lamsfoundation.lams.tool.mc.McSessionMarkDTO; -import org.lamsfoundation.lams.tool.mc.McUserMarkDTO; -import org.lamsfoundation.lams.tool.mc.ReflectionDTO; +import org.lamsfoundation.lams.tool.mc.dto.AnswerDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McSessionMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.McUserMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.mc.dto.ToolOutputDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McApplicationException.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McApplicationException.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McApplicationException.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.service; + +/** + *

+ * This exception wraps all basic exception occured in the mcq tool. It is not suppose to be try and catched in any + * level. The struts should be taking care of handling this exception. + *

+ * + * @author Ozgur Demirtas + * + */ +public class McApplicationException extends RuntimeException { + /** + * Default Constructor + */ + public McApplicationException() { + super(); + } + + /** + * Constructor for customized error message + * + * @param message + */ + public McApplicationException(String message) { + super(message); + } + + /** + * Constructor for wrapping the throwable object + * + * @param cause + */ + public McApplicationException(Throwable cause) { + super(cause); + } + + /** + * Constructor for wrapping both the customized error message and throwable exception object. + * + * @param message + * @param cause + */ + public McApplicationException(String message, Throwable cause) { + super(message, cause); + } + +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -r2abc3485dc2d24ea02044a64271f3ee0d3b8c11b -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 2abc3485dc2d24ea02044a64271f3ee0d3b8c11b) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -73,21 +73,19 @@ import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; -import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; -import org.lamsfoundation.lams.tool.mc.McQuestionDTO; -import org.lamsfoundation.lams.tool.mc.McSessionMarkDTO; -import org.lamsfoundation.lams.tool.mc.McStringComparator; -import org.lamsfoundation.lams.tool.mc.McUserMarkDTO; -import org.lamsfoundation.lams.tool.mc.ReflectionDTO; import org.lamsfoundation.lams.tool.mc.dao.IMcContentDAO; import org.lamsfoundation.lams.tool.mc.dao.IMcOptionsContentDAO; import org.lamsfoundation.lams.tool.mc.dao.IMcQueContentDAO; import org.lamsfoundation.lams.tool.mc.dao.IMcSessionDAO; import org.lamsfoundation.lams.tool.mc.dao.IMcUserDAO; import org.lamsfoundation.lams.tool.mc.dao.IMcUsrAttemptDAO; +import org.lamsfoundation.lams.tool.mc.dto.AnswerDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McSessionMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.McUserMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.mc.dto.ToolOutputDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; @@ -96,6 +94,7 @@ import org.lamsfoundation.lams.tool.mc.pojos.McSession; import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt; import org.lamsfoundation.lams.tool.mc.util.McSessionComparator; +import org.lamsfoundation.lams.tool.mc.util.McStringComparator; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; @@ -323,7 +322,7 @@ } // persist candidate answers - List optionDTOs = questionDTO.getListCandidateAnswersDTO(); + List optionDTOs = questionDTO.getOptionDtos(); Set oldOptions = question.getMcOptionsContents(); Set newOptions = new HashSet(); int displayOrderOption = 1; @@ -792,7 +791,7 @@ gradebookService.updateActivityMark(new Double(totalMark), null, userId, toolSessionId, false); // record mark change with audit service - auditService.logMarkChange(McAppConstants.MY_SIGNATURE, userAttempt.getMcQueUsr().getQueUsrId(), + auditService.logMarkChange(McAppConstants.TOOL_SIGNATURE, userAttempt.getMcQueUsr().getQueUsrId(), userAttempt.getMcQueUsr().getUsername(), "" + oldMark, "" + totalMark); } @@ -824,7 +823,7 @@ // options are different Set oldOptions = oldQuestion.getMcOptionsContents(); - List optionDTOs = questionDTO.getListCandidateAnswersDTO(); + List optionDTOs = questionDTO.getOptionDtos(); for (McOptsContent oldOption : oldOptions) { for (McOptionDTO optionDTO : optionDTOs) { if (oldOption.getUid().equals(optionDTO.getUid())) { @@ -1233,7 +1232,7 @@ if (fromContentId == null) { McServicePOJO.logger.warn("fromContentId is null."); - long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.TOOL_SIGNATURE); fromContentId = new Long(defaultContentId); } @@ -1246,7 +1245,7 @@ if (fromContent == null) { McServicePOJO.logger.warn("fromContent is null."); - long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.TOOL_SIGNATURE); fromContent = mcContentDAO.findMcContentById(defaultContentId); } @@ -1270,7 +1269,7 @@ for (McSession session : (Set) mcContent.getMcSessions()) { List entries = coreNotebookService.getEntry(session.getMcSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.MY_SIGNATURE); + CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.TOOL_SIGNATURE); for (NotebookEntry entry : entries) { coreNotebookService.deleteEntry(entry); } @@ -1305,7 +1304,7 @@ mcUsrAttemptDAO.removeAllUserAttempts(user.getUid()); NotebookEntry entry = getEntry(session.getMcSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, userId); + McAppConstants.TOOL_SIGNATURE, userId); if (entry != null) { mcContentDAO.delete(entry); } @@ -1326,7 +1325,7 @@ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { McContent toolContentObj = mcContentDAO.findMcContentById(toolContentId); if (toolContentObj == null) { - long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + long defaultContentId = getToolDefaultContentIdBySignature(McAppConstants.TOOL_SIGNATURE); toolContentObj = mcContentDAO.findMcContentById(defaultContentId); } if (toolContentObj == null) { @@ -1372,7 +1371,7 @@ throws ToolException { McContent content = getMcContent(toolContentId); if (content == null) { - long defaultToolContentId = getToolDefaultContentIdBySignature(McAppConstants.MY_SIGNATURE); + long defaultToolContentId = getToolDefaultContentIdBySignature(McAppConstants.TOOL_SIGNATURE); content = getMcContent(defaultToolContentId); } return mcOutputFactory.getToolOutputDefinitions(content, definitionType); @@ -1694,7 +1693,7 @@ for (McQueUsr user : (Set) mcSession.getMcQueUsers()) { NotebookEntry notebookEntry = this.getEntry(mcSession.getMcSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.MY_SIGNATURE, + CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.TOOL_SIGNATURE, new Integer(user.getQueUsrId().toString())); if (notebookEntry != null) { @@ -1717,7 +1716,7 @@ McQueUsr user = (McQueUsr) userIter.next(); if (user.getQueUsrId().equals(userID)) { NotebookEntry notebookEntry = this.getEntry(mcSession.getMcSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.MY_SIGNATURE, + CoreNotebookConstants.NOTEBOOK_TOOL, McAppConstants.TOOL_SIGNATURE, new Integer(user.getQueUsrId().toString())); if (notebookEntry != null) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McComparator.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McComparator.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McComparator.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.util; + +import java.io.Serializable; +import java.util.Comparator; + +/** + * @author Ozgur Demirtas A comparator implementation that can be used as a constructor to collections. The TreeMap in + * the web layer makes use of it. + * + */ +public class McComparator implements Comparator, Serializable { + + @Override + public int compare(Object o1, Object o2) { + String s1 = (String) o1; + String s2 = (String) o2; + + int key1 = new Long(s1).intValue(); + int key2 = new Long(s2).intValue(); + return key1 - key2; + } + + @Override + public boolean equals(Object o) { + String s = (String) o; + return compare(this, o) == 0; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McStringComparator.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McStringComparator.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/McStringComparator.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.util; + +import java.io.Serializable; +import java.util.Comparator; + +import org.apache.log4j.Logger; + +/** + * @author Ozgur Demirtas * A comparator implementation that can be used as a constructor to collections. The TreeMap in + * the web layer makes use of it. + * + */ +public class McStringComparator implements Comparator, Serializable { + static Logger logger = Logger.getLogger(McStringComparator.class.getName()); + + @Override + public int compare(Object o1, Object o2) { + String s1 = (String) o1; + String s2 = (String) o2; + + return s1.compareTo(s2); + } + + @Override + public boolean equals(Object o) { + return compare(this, o) == 0; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java =================================================================== diff -u -r1555edf007ae13898458700147b51f6909126179 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 1555edf007ae13898458700147b51f6909126179) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -37,13 +37,13 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McComparator; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; -import org.lamsfoundation.lams.tool.mc.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.util.McComparator; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -53,129 +53,13 @@ * * @author Ozgur Demirtas */ -public class AuthoringUtil implements McAppConstants { +public class AuthoringUtil { private static Logger logger = Logger.getLogger(AuthoringUtil.class.getName()); - public static List removeBlankOptions(List optionDtos) { - List newList = new LinkedList(); - - for (McOptionDTO optionDTO : optionDtos) { - String optionText = optionDTO.getCandidateAnswer(); - - if ((optionText != null) && (optionText.length() > 0)) { - newList.add(optionDTO); - } - } - - return newList; - } - /** - * swappes McQuestionDTO questions in the list - */ - public static List swapQuestions(List questionDTOs, String questionIndex, - String direction) { - - int intQuestionIndex = new Integer(questionIndex).intValue(); - int intOriginalQuestionIndex = intQuestionIndex; - - int replacedQuestionIndex = 0; - if (direction.equals("down")) { - replacedQuestionIndex = ++intQuestionIndex; - } else { - replacedQuestionIndex = --intQuestionIndex; - } - - McQuestionDTO mainQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, intOriginalQuestionIndex); - - McQuestionDTO replacedQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, replacedQuestionIndex); - - if ((mainQuestion == null) || (replacedQuestion == null)) { - return questionDTOs; - } - - List newQuestionDtos = new LinkedList(); - - int queIndex = 0; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = iter.next(); - queIndex++; - McQuestionDTO tempQuestion = new McQuestionDTO(); - - if ((!questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) - && !questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { - // normal copy - tempQuestion = questionDto; - - } else if (questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) { - // move type 1 - tempQuestion = replacedQuestion; - - } else if (questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { - // move type 2 - tempQuestion = mainQuestion; - } - - newQuestionDtos.add(tempQuestion); - } - - return newQuestionDtos; - } - - /** - * swaps options in the list - */ - public static List swapOptions(List optionDtos, String optionIndex, String direction) { - - int intOptionIndex = new Integer(optionIndex).intValue(); - int intOriginalOptionIndex = intOptionIndex; - - int replacedOptionIndex = 0; - if (direction.equals("down")) { - replacedOptionIndex = ++intOptionIndex; - } else { - replacedOptionIndex = --intOptionIndex; - } - - McOptionDTO mainOption = AuthoringUtil.getOptionAtDisplayOrder(optionDtos, intOriginalOptionIndex); - - McOptionDTO replacedOption = AuthoringUtil.getOptionAtDisplayOrder(optionDtos, replacedOptionIndex); - - if ((mainOption == null) || (replacedOption == null)) { - return optionDtos; - } - - List newOptionDtos = new LinkedList(); - - int queIndex = 1; - for (McOptionDTO option : optionDtos) { - - McOptionDTO tempOption = new McOptionDTO(); - if ((!new Integer(queIndex).toString().equals(new Integer(intOriginalOptionIndex).toString())) - && !new Integer(queIndex).toString().equals(new Integer(replacedOptionIndex).toString())) { - // normal copy - tempOption = option; - } else if (new Integer(queIndex).toString().equals(new Integer(intOriginalOptionIndex).toString())) { - // move type 1 - tempOption = replacedOption; - } else if (new Integer(queIndex).toString().equals(new Integer(replacedOptionIndex).toString())) { - // move type 2 - tempOption = mainOption; - } - - newOptionDtos.add(tempOption); - queIndex++; - } - - return newOptionDtos; - } - - /** * 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(); @@ -191,7 +75,6 @@ * extractCandidateAtOrder */ public static McOptionDTO getOptionAtDisplayOrder(List options, int intOriginalCandidateIndex) { - int counter = 0; Iterator iter = options.iterator(); while (iter.hasNext()) { @@ -205,106 +88,7 @@ return null; } - public static int getTotalMark(List questionDTOs) { - - Iterator iter = questionDTOs.iterator(); - int totalMark = 0; - while (iter.hasNext()) { - McQuestionDTO questionDto = iter.next(); - - String mark = questionDto.getMark(); - - if (StringUtils.isNotBlank(mark)) { - int intMark = new Integer(mark).intValue(); - totalMark += intMark; - } - } - - return totalMark; - } - /** - * reorderSimpleListQuestionContentDTO - */ - public static List reorderSimpleQuestionDtos(List questionDTOs) { - List listFinalQuestionContentDTO = new LinkedList(); - - int queIndex = 0; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = iter.next(); - - String question = questionDto.getQuestion(); - - String feedback = questionDto.getFeedback(); - - List optionDtos = questionDto.getListCandidateAnswersDTO(); - - String mark = questionDto.getMark(); - - if ((question != null) && (!question.equals(""))) { - ++queIndex; - - questionDto.setQuestion(question); - questionDto.setDisplayOrder(new Integer(queIndex).toString()); - questionDto.setFeedback(feedback); - questionDto.setListCandidateAnswersDTO(optionDtos); - questionDto.setMark(mark); - listFinalQuestionContentDTO.add(questionDto); - } - } - - return listFinalQuestionContentDTO; - } - - /** - * reorderUpdateListQuestionContentDTO - */ - public static List reorderUpdateQuestionDtos(List questionDTOs, McQuestionDTO mcQuestionContentDTONew, - String editableQuestionIndex) { - - List listFinalQuestionContentDTO = new LinkedList(); - - int queIndex = 0; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = (McQuestionDTO) iter.next(); - - ++queIndex; - String question = questionDto.getQuestion(); - - String displayOrder = questionDto.getDisplayOrder(); - - String feedback = questionDto.getFeedback(); - - String mark = questionDto.getMark(); - - List optionDtos = questionDto.getListCandidateAnswersDTO(); - - if (displayOrder.equals(editableQuestionIndex)) { - questionDto.setQuestion(mcQuestionContentDTONew.getQuestion()); - questionDto.setDisplayOrder(mcQuestionContentDTONew.getDisplayOrder()); - questionDto.setFeedback(mcQuestionContentDTONew.getFeedback()); - questionDto.setMark(mcQuestionContentDTONew.getMark()); - questionDto.setListCandidateAnswersDTO(mcQuestionContentDTONew.getListCandidateAnswersDTO()); - - listFinalQuestionContentDTO.add(questionDto); - } else { - questionDto.setQuestion(question); - questionDto.setDisplayOrder(displayOrder); - questionDto.setFeedback(feedback); - questionDto.setMark(mark); - questionDto.setListCandidateAnswersDTO(optionDtos); - listFinalQuestionContentDTO.add(questionDto); - - } - - } - - return listFinalQuestionContentDTO; - } - - /** * verifies that there are no duplicate questions */ public static boolean checkDuplicateQuestions(List questionDTOs, String newQuestion) { @@ -437,6 +221,16 @@ mcContent.setReflect(reflectBoolean); mcContent.setReflectionSubject(reflectionSubject); + + //calculate total mark + int totalMark = 0; + for (McQuestionDTO questionDto: questionDTOs) { + String mark = questionDto.getMark(); + if (StringUtils.isNotBlank(mark)) { + int intMark = new Integer(mark).intValue(); + totalMark += intMark; + } + } String passmarkStr = request.getParameter("passmark"); //nullify passmark in case 'retries' option is OFF @@ -445,7 +239,6 @@ } //passmark can't be more than total mark Integer passmark = new Integer(passmarkStr); - int totalMark = AuthoringUtil.getTotalMark(questionDTOs); if (totalMark < passmark) { passmark = totalMark; } @@ -466,7 +259,7 @@ * generates a list for holding default questions and their candidate answers */ public static List buildDefaultQuestions(McContent mcContent) { - List questionDTOs = new LinkedList(); + List questionDtos = new LinkedList(); Long mapIndex = new Long(1); @@ -482,7 +275,7 @@ questionDto.setUid(question.getUid()); questionDto.setQuestion(questionText); - questionDto.setDisplayOrder(question.getDisplayOrder().toString()); + questionDto.setDisplayOrder(question.getDisplayOrder()); questionDto.setFeedback(feedback); questionDto.setMark(question.getMark().toString()); @@ -493,13 +286,12 @@ optionDtos.add(optionDTO); } - questionDto.setListCandidateAnswersDTO(optionDtos); + questionDto.setOptionDtos(optionDtos); + questionDtos.add(questionDto); - questionDTOs.add(questionDto); - mapIndex = new Long(mapIndex.longValue() + 1); } - return questionDTOs; + return questionDtos; } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ClearSessionAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ClearSessionAction.java (.../ClearSessionAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ClearSessionAction.java (.../ClearSessionAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -26,7 +26,6 @@ import javax.servlet.http.HttpSession; -import org.lamsfoundation.lams.authoring.web.AuthoringConstants; import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; import org.lamsfoundation.lams.tool.ToolAccessMode; @@ -37,7 +36,9 @@ @Override public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { - session.removeAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG); + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -28,18 +28,18 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.tool.mc.AnswerDTO; -import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.mc.dto.AnswerDTO; +import org.lamsfoundation.lams.tool.mc.dto.McGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; +import org.lamsfoundation.lams.tool.mc.web.form.McLearningForm; /** * * Keeps all operations needed for Authoring mode. * * @author Ozgur Demirtas */ -public class LearningUtil implements McAppConstants { +public class LearningUtil { static Logger logger = Logger.getLogger(LearningUtil.class.getName()); public static void saveFormRequestData(HttpServletRequest request, McLearningForm mcLearningForm) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -r1555edf007ae13898458700147b51f6909126179 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 1555edf007ae13898458700147b51f6909126179) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -48,13 +48,13 @@ import org.lamsfoundation.lams.questions.QuestionParser; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McGeneralAuthoringDTO; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; -import org.lamsfoundation.lams.tool.mc.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.web.form.McAuthoringForm; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -65,7 +65,7 @@ * * @author Ozgur Demirtas */ -public class McAction extends LamsDispatchAction implements McAppConstants { +public class McAction extends LamsDispatchAction { private static Logger logger = Logger.getLogger(McAction.class.getName()); /** @@ -82,108 +82,292 @@ request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); String strToolContentID = (String) sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - ActionMessages errors = new ActionMessages(); + List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); + McContent mcContent = mcService.getMcContent(new Long(strToolContentID)); + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + List deletedQuestionDTOs = (List) sessionMap + .get(McAppConstants.LIST_DELETED_QUESTION_DTOS); + if (questionDTOs.isEmpty()) { + ActionMessages errors = new ActionMessages(); ActionMessage error = new ActionMessage("questions.none.submitted"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); saveErrors(request, errors); McAction.logger.debug("errors saved: " + errors); + return mapping.findForward(McAppConstants.LOAD_AUTHORING); } - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); + // in case request is from monitoring module - prepare for recalculate User Answers + if (mode.isTeacher()) { + Set oldQuestions = mcContent.getMcQueContents(); + mcService.releaseQuestionsFromCache(mcContent); + mcService.setDefineLater(strToolContentID, false); - String richTextTitle = request.getParameter(McAppConstants.TITLE); + // audit log the teacher has started editing activity in monitor + mcService.auditLogStartEditingActivityInMonitor(new Long(strToolContentID)); - mcAuthoringForm.setTitle(richTextTitle); + // recalculate User Answers + mcService.recalculateUserAnswers(mcContent, oldQuestions, questionDTOs, deletedQuestionDTOs); + } - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + // remove deleted questions + for (McQuestionDTO deletedQuestionDTO : deletedQuestionDTOs) { + McQueContent removeableQuestion = mcService.getQuestionByUid(deletedQuestionDTO.getUid()); + if (removeableQuestion != null) { + // Set attempts = removeableQuestion.getMcUsrAttempts(); + // Iterator iter = attempts.iterator(); + // while (iter.hasNext()) { + // McUsrAttempt attempt = iter.next(); + // iter.remove(); + // } + // mcService.updateQuestion(removeableQuestion); + mcContent.getMcQueContents().remove(removeableQuestion); + mcService.removeMcQueContent(removeableQuestion); + } + } - McContent mcContentTest = mcService.getMcContent(new Long(strToolContentID)); + // store content + mcContent = AuthoringUtil.saveOrUpdateMcContent(mcService, request, mcContent, strToolContentID, questionDTOs); - McContent mcContent = mcContentTest; - if (errors.isEmpty()) { + // store questions + mcContent = mcService.createQuestions(questionDTOs, mcContent); - ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + if (mcContent != null) { + // sorts the questions by the display order + List sortedQuestions = mcService.getAllQuestionsSorted(mcContent.getUid().longValue()); + int displayOrder = 1; + for (McQueContent question : sortedQuestions) { + McQueContent existingQuestion = mcService.getQuestionByUid(question.getUid()); + existingQuestion.setDisplayOrder(new Integer(displayOrder)); + mcService.updateQuestion(existingQuestion); + displayOrder++; + } + } - List deletedQuestionDTOs = (List) sessionMap.get(LIST_DELETED_QUESTION_DTOS); + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + return mapping.findForward(McAppConstants.LOAD_AUTHORING); + } + + /** + * opens up an new screen within the current page for editing a question + */ + public ActionForward editQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); + List questionDtos = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); - // in case request is from monitoring module - prepare for recalculate User Answers - if (mode.isTeacher()) { - Set oldQuestions = mcContent.getMcQueContents(); - mcService.releaseQuestionsFromCache(mcContent); - mcService.setDefineLater(strToolContentID, false); + Integer questionIndex = WebUtil.readIntParam(request, "questionIndex", true); + + McQuestionDTO questionDto = null; + //editing existing question + if (questionIndex != null) { + mcAuthoringForm.setQuestionIndex("" + questionIndex); + + //find according questionDto + for (McQuestionDTO questionDtoIter : questionDtos) { + Integer displayOrder = questionDtoIter.getDisplayOrder(); - // audit log the teacher has started editing activity in monitor - mcService.auditLogStartEditingActivityInMonitor(new Long(strToolContentID)); - - // recalculate User Answers - mcService.recalculateUserAnswers(mcContent, oldQuestions, questionDTOs, deletedQuestionDTOs); - } - - // remove deleted questions - for (McQuestionDTO deletedQuestionDTO : deletedQuestionDTOs) { - McQueContent removeableQuestion = mcService.getQuestionByUid(deletedQuestionDTO.getUid()); - if (removeableQuestion != null) { -// Set attempts = removeableQuestion.getMcUsrAttempts(); -// Iterator iter = attempts.iterator(); -// while (iter.hasNext()) { -// McUsrAttempt attempt = iter.next(); -// iter.remove(); -// } -// mcService.updateQuestion(removeableQuestion); - mcContent.getMcQueContents().remove(removeableQuestion); - mcService.removeMcQueContent(removeableQuestion); + if ((displayOrder != null) && (!displayOrder.equals("")) && displayOrder.equals(questionIndex)) { + questionDto = questionDtoIter; + break; } } + + //adding new question + } else { + // prepare question for adding new question page + questionDto = new McQuestionDTO(); + List newOptions = new ArrayList(); + McOptionDTO newOption1 = new McOptionDTO(); + newOption1.setCorrect("Correct"); + McOptionDTO newOption2 = new McOptionDTO(); + newOptions.add(newOption1); + newOptions.add(newOption2); + questionDto.setOptionDtos(newOptions); + } + sessionMap.put(McAppConstants.QUESTION_DTO, questionDto); - //store content - mcContent = AuthoringUtil.saveOrUpdateMcContent(mcService, request, mcContentTest, strToolContentID, questionDTOs); + return (mapping.findForward("editQuestionBox")); + } - //store questions - mcContent = mcService.createQuestions(questionDTOs, mcContent); + /** + * removes a question from the questions map + */ + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - if (mcContent != null) { - // sorts the questions by the display order - List sortedQuestions = mcService.getAllQuestionsSorted(mcContent.getUid().longValue()); - int displayOrder = 1; - for (McQueContent question : sortedQuestions) { - McQueContent existingQuestion = mcService.getQuestionByUid(question.getUid()); - existingQuestion.setDisplayOrder(new Integer(displayOrder)); - mcService.updateQuestion(existingQuestion); - displayOrder++; - } + String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); + + Integer questionIndexToDelete = WebUtil.readIntParam(request, "questionIndex"); + mcAuthoringForm.setQuestionIndex("" + questionIndexToDelete); + + List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); + + //exclude Question with questionIndex From List + List tempQuestionDtos = new LinkedList(); + int queIndex = 0; + for (McQuestionDTO questionDTO : questionDTOs) { + + String questionText = questionDTO.getQuestion(); + Integer displayOrder = questionDTO.getDisplayOrder(); + if ((questionText != null) && (!questionText.isEmpty()) && !displayOrder.equals(questionIndexToDelete)) { + + ++queIndex; + questionDTO.setDisplayOrder(queIndex); + tempQuestionDtos.add(questionDTO); } + 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); - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); + return (mapping.findForward("itemList")); + } - request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + /** + * moves a question down in the list + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); + + String questionIndex = request.getParameter("questionIndex"); + mcAuthoringForm.setQuestionIndex(questionIndex); + + List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); + questionDTOs = McAction.swapQuestions(questionDTOs, questionIndex, "down"); + questionDTOs = McAction.reorderQuestionDtos(questionDTOs); + sessionMap.put(McAppConstants.QUESTION_DTOS, questionDTOs); + + return (mapping.findForward("itemList")); + } + + public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); + + String questionIndex = request.getParameter("questionIndex"); + mcAuthoringForm.setQuestionIndex(questionIndex); + + List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); + questionDTOs = McAction.swapQuestions(questionDTOs, questionIndex, "up"); + questionDTOs = McAction.reorderQuestionDtos(questionDTOs); + sessionMap.put(McAppConstants.QUESTION_DTOS, questionDTOs); + + return (mapping.findForward("itemList")); + } + + /* + * swappes McQuestionDTO questions in the list. Auxiliary method for moveQuestionDown() and moveQuestionUp() + */ + private static List swapQuestions(List questionDTOs, String questionIndex, + String direction) { + + int intQuestionIndex = new Integer(questionIndex).intValue(); + int intOriginalQuestionIndex = intQuestionIndex; + + int replacedQuestionIndex = 0; + if (direction.equals("down")) { + replacedQuestionIndex = ++intQuestionIndex; } else { - // errors is not empty + replacedQuestionIndex = --intQuestionIndex; + } - if (mcContent != null) { - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); + McQuestionDTO mainQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, intOriginalQuestionIndex); + McQuestionDTO replacedQuestion = AuthoringUtil.getQuestionAtDisplayOrder(questionDTOs, replacedQuestionIndex); + if ((mainQuestion == null) || (replacedQuestion == null)) { + return questionDTOs; + } + + List questionDtos = new LinkedList(); + + Iterator iter = questionDTOs.iterator(); + while (iter.hasNext()) { + McQuestionDTO questionDto = iter.next(); + McQuestionDTO tempQuestion = new McQuestionDTO(); + + if ((!questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) + && !questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { + // normal copy + tempQuestion = questionDto; + + } else if (questionDto.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) { + // move type 1 + tempQuestion = replacedQuestion; + + } else if (questionDto.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) { + // move type 2 + tempQuestion = mainQuestion; } + + questionDtos.add(tempQuestion); } - mcAuthoringForm.resetUserAction(); + return questionDtos; + } - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); + /* + *Auxiliary method for moveQuestionDown() and moveQuestionUp() + */ + private static List reorderQuestionDtos(List questionDTOs) { + List tempQuestionDtos = new LinkedList(); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + int queIndex = 0; + Iterator iter = questionDTOs.iterator(); + while (iter.hasNext()) { + McQuestionDTO questionDto = iter.next(); - mcAuthoringForm.setCurrentTab("1"); + String question = questionDto.getQuestion(); + String feedback = questionDto.getFeedback(); + String mark = questionDto.getMark(); - return mapping.findForward(McAppConstants.LOAD_AUTHORING); + List optionDtos = questionDto.getOptionDtos(); + if ((question != null) && (!question.equals(""))) { + ++queIndex; + + questionDto.setQuestion(question); + questionDto.setDisplayOrder(queIndex); + questionDto.setFeedback(feedback); + questionDto.setOptionDtos(optionDtos); + questionDto.setMark(mark); + tempQuestionDtos.add(questionDto); + } + } + + return tempQuestionDtos; } - public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward saveQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; @@ -193,98 +377,80 @@ .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - boolean editQuestionBoxRequest = WebUtil.readBooleanParam(request, "editQuestionBoxRequest"); - String mark = request.getParameter("mark"); - String passmark = request.getParameter("passmark"); List options = McAction.repopulateOptionDTOs(request, false); - options = AuthoringUtil.removeBlankOptions(options); + + //remove blank options + List optionsWithoutEmptyOnes = new LinkedList(); + for (McOptionDTO optionDTO : options) { + String optionText = optionDTO.getCandidateAnswer(); + if ((optionText != null) && (optionText.length() > 0)) { + optionsWithoutEmptyOnes.add(optionDTO); + } + } + options = optionsWithoutEmptyOnes; - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); + List questionDTOs = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - mcGeneralAuthoringDTO.setMarkValue(mark); - mcGeneralAuthoringDTO.setPassMarkValue(passmark); - String newQuestion = request.getParameter("newQuestion"); String feedback = request.getParameter("feedback"); - String editableQuestionIndex = request.getParameter("editableQuestionIndex"); - mcAuthoringForm.setQuestionIndex(editableQuestionIndex); + Integer questionIndex = WebUtil.readIntParam(request, "questionIndex", true); + mcAuthoringForm.setQuestionIndex("" + questionIndex); if ((newQuestion != null) && (newQuestion.length() > 0)) { - if (!editQuestionBoxRequest) { - // request for add and save - boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, newQuestion); + // adding new question + if (questionIndex == null) { + boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, newQuestion); if (!duplicates) { - McQuestionDTO questionDTO = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - questionDTO = iter.next(); - - String displayOrder = questionDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(editableQuestionIndex)) { - break; - } - + + //finding max displayOrder + int maxDisplayOrder = 1; + for (McQuestionDTO questionDTO : questionDTOs) { + int displayOrder = new Integer(questionDTO.getDisplayOrder()); + if (displayOrder > maxDisplayOrder) { + maxDisplayOrder = displayOrder; } } + McQuestionDTO questionDTO = new McQuestionDTO(); questionDTO.setQuestion(newQuestion); questionDTO.setFeedback(feedback); - questionDTO.setDisplayOrder(editableQuestionIndex); - questionDTO.setListCandidateAnswersDTO(options); + questionDTO.setDisplayOrder(maxDisplayOrder + 1); + questionDTO.setOptionDtos(options); questionDTO.setMark(mark); - questionDTOs = AuthoringUtil.reorderUpdateQuestionDtos(questionDTOs, questionDTO, - editableQuestionIndex); - // post reorderUpdateListQuestionContentDTO questionDTOs + questionDTOs.add(questionDTO); } else { // duplicate question entry, not adding } + + // updating existing question } else { - // request for edit and save - McQuestionDTO questionDTO = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - questionDTO = iter.next(); + McQuestionDTO questionDto = null; + for (McQuestionDTO questionDtoIter : questionDTOs) { + Integer displayOrder = questionDtoIter.getDisplayOrder(); - String displayOrder = questionDTO.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(editableQuestionIndex)) { - break; - } - + if ((displayOrder != null) && displayOrder.equals(questionIndex)) { + questionDto = questionDtoIter; + break; } } - questionDTO.setQuestion(newQuestion); - questionDTO.setFeedback(feedback); - questionDTO.setDisplayOrder(editableQuestionIndex); - questionDTO.setListCandidateAnswersDTO(options); - questionDTO.setMark(mark); - - questionDTOs = AuthoringUtil.reorderUpdateQuestionDtos(questionDTOs, questionDTO, - editableQuestionIndex); + questionDto.setQuestion(newQuestion); + questionDto.setFeedback(feedback); + questionDto.setDisplayOrder(questionIndex); + questionDto.setOptionDtos(options); + questionDto.setMark(mark); } } else { // entry blank, not adding } - mcGeneralAuthoringDTO.setMarkValue(mark); + request.setAttribute(McAppConstants.QUESTION_DTOS, questionDTOs); + sessionMap.put(McAppConstants.QUESTION_DTOS, questionDTOs); - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - return (mapping.findForward("itemList")); } @@ -294,17 +460,14 @@ @SuppressWarnings({ "unchecked", "rawtypes" }) public ActionForward saveQTI(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - // big part of code was taken from addSingleQuestion() and saveSingleQuestion() methods - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + // big part of code was taken from addSingleQuestion() and saveQuestion() methods String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); + List questionDtos = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); // proper parsing Question[] questions = QuestionParser.parseQuestionChoiceForm(request); @@ -319,7 +482,7 @@ questionText = QuestionParser.processHTMLField(questionText, false, contentFolderID, question.getResourcesFolderPath()); - if (AuthoringUtil.checkDuplicateQuestions(questionDTOs, questionText)) { + if (AuthoringUtil.checkDuplicateQuestions(questionDtos, questionText)) { LamsDispatchAction.log.warn("Skipping duplicate question: " + questionText); continue; } @@ -372,31 +535,22 @@ } McQuestionDTO questionDto = new McQuestionDTO(); - questionDto.setDisplayOrder(String.valueOf(questionDTOs.size() + 1)); + questionDto.setDisplayOrder(questionDtos.size() + 1); questionDto.setQuestion(questionText); questionDto.setFeedback(QuestionParser.processHTMLField(question.getFeedback(), true, null, null)); - questionDto.setListCandidateAnswersDTO(optionDtos); + questionDto.setOptionDtos(optionDtos); questionDto.setMark(correctAnswerScore.toString()); - questionDTOs.add(questionDto); + questionDtos.add(questionDto); if (LamsDispatchAction.log.isDebugEnabled()) { LamsDispatchAction.log.debug("Added question: " + questionText); } } - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); + sessionMap.put(McAppConstants.QUESTION_DTOS, questionDtos); - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - mcAuthoringForm.setTitle(richTextTitle); - mcAuthoringForm.setCurrentTab("1"); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - return mapping.findForward(McAppConstants.LOAD_AUTHORING); + return mapping.findForward("itemList"); } /** @@ -410,10 +564,10 @@ .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); + List questionDtos = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); List questions = new LinkedList(); - for (McQuestionDTO mcQuestion : questionDTOs) { + for (McQuestionDTO mcQuestion : questionDtos) { Question question = new Question(); question.setType(Question.QUESTION_TYPE_MULTIPLE_CHOICE); @@ -422,7 +576,7 @@ question.setFeedback(mcQuestion.getFeedback()); List answers = new ArrayList(); - for (McOptionDTO mcAnswer : mcQuestion.getListCandidateAnswersDTO()) { + for (McOptionDTO mcAnswer : mcQuestion.getOptionDtos()) { Answer answer = new Answer(); answer.setText(mcAnswer.getCandidateAnswer()); answer.setScore( @@ -433,7 +587,7 @@ } // put the question in the right place - questions.add(Integer.parseInt(mcQuestion.getDisplayOrder()) - 1, question); + questions.add(mcQuestion.getDisplayOrder() - 1, question); } String title = request.getParameter("title"); @@ -443,767 +597,108 @@ return null; } - public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - McQuestionDTO newQuestionDTO = (McQuestionDTO) sessionMap.get(McAppConstants.NEW_QUESTION_DTO); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - - int listSize = questionDTOs.size(); - - String newQuestionParam = request.getParameter("newQuestion"); - - String feedback = request.getParameter("feedback"); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - String passmark = request.getParameter("passmark"); - mcGeneralAuthoringDTO.setPassMarkValue(passmark); - - List optionDtos = McAction.repopulateOptionDTOs(request, false); - optionDtos = AuthoringUtil.removeBlankOptions(optionDtos); - - if ((newQuestionParam != null) && (newQuestionParam.length() > 0)) { - boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, newQuestionParam); - - if (!duplicates) { - McQuestionDTO questionDto = new McQuestionDTO(); - questionDto.setDisplayOrder(new Long(listSize + 1).toString()); - questionDto.setFeedback(feedback); - questionDto.setQuestion(newQuestionParam); - questionDto.setMark(mark); - - questionDto.setListCandidateAnswersDTO(optionDtos); - - questionDTOs.add(questionDto); - } else { - // entry duplicate, not adding - } - } else { - // entry blank, not adding - } - - mcGeneralAuthoringDTO.setMarkValue(mark); - - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestionParam); - mcAuthoringForm.setFeedback(feedback); - - mcGeneralAuthoringDTO.setMarkValue(mark); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("itemList")); - } - - /** - * opens up an new screen within the current page for adding a new question - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - mcAuthoringForm.setTitle(richTextTitle); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - //prepare question for adding new question page - McQuestionDTO newQuestionDTO = new McQuestionDTO(); - List newOptions = new ArrayList(); - McOptionDTO newOption1 = new McOptionDTO(); - newOption1.setCorrect("Correct"); - McOptionDTO newOption2 = new McOptionDTO(); - newOptions.add(newOption1); - newOptions.add(newOption2); - newQuestionDTO.setListCandidateAnswersDTO(newOptions); - sessionMap.put(NEW_QUESTION_DTO, newQuestionDTO); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - String newQuestionParam = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestionParam); - - String feedback = request.getParameter("feedback"); - mcAuthoringForm.setFeedback(feedback); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - return (mapping.findForward("newQuestionBox")); - } - - /** - * opens up an new screen within the current page for editing a question - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndex = request.getParameter("questionIndex"); - mcAuthoringForm.setQuestionIndex(questionIndex); - - request.setAttribute(McAppConstants.CURRENT_EDITABLE_QUESTION_INDEX, questionIndex); - - mcAuthoringForm.setEditableQuestionIndex(questionIndex); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - String editableQuestion = ""; - String editableFeedback = ""; - String editableMark = ""; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = (McQuestionDTO) iter.next(); - String displayOrder = questionDto.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(questionIndex)) { - editableFeedback = questionDto.getFeedback(); - editableQuestion = questionDto.getQuestion(); - editableMark = questionDto.getMark(); - - break; - } - } - } - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = (McGeneralAuthoringDTO) request - .getAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO); - - if (mcGeneralAuthoringDTO == null) { - mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - } - - mcGeneralAuthoringDTO.setMarkValue(editableMark); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - mcAuthoringForm.setTitle(richTextTitle); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - mcGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); - mcGeneralAuthoringDTO.setEditableQuestionFeedback(editableFeedback); - mcAuthoringForm.setFeedback(editableFeedback); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - String requestNewEditableQuestionBox = (String) request.getAttribute("requestNewEditableQuestionBox"); - - String newQuestion = request.getParameter("newQuestion"); - String feedback = request.getParameter("feedback"); - if ((requestNewEditableQuestionBox != null) && requestNewEditableQuestionBox.equals("true")) { - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - mcGeneralAuthoringDTO.setEditableQuestionFeedback(feedback); - } - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - return (mapping.findForward("editQuestionBox")); - } - - /** - * removes a question from the questions map - */ - public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndexToDelete = request.getParameter("questionIndex"); - mcAuthoringForm.setQuestionIndex(questionIndexToDelete); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - //exclude Question with questionIndex From List - List listFinalQuestionContentDTO = new LinkedList(); - int queIndex = 0; - for (McQuestionDTO questionDTO : questionDTOs) { - - String questionText = questionDTO.getQuestion(); - String displayOrder = questionDTO.getDisplayOrder(); - if ((questionText != null) && (!questionText.isEmpty()) && !displayOrder.equals(questionIndexToDelete)) { - - ++queIndex; - questionDTO.setDisplayOrder(new Integer(queIndex).toString()); - listFinalQuestionContentDTO.add(questionDTO); - } - if ((questionText != null) && (!questionText.isEmpty()) && displayOrder.equals(questionIndexToDelete)) { - List deletedQuestionDTOs = (List) sessionMap - .get(LIST_DELETED_QUESTION_DTOS); - ; - deletedQuestionDTOs.add(questionDTO); - sessionMap.put(LIST_DELETED_QUESTION_DTOS, deletedQuestionDTOs); - } - } - questionDTOs = listFinalQuestionContentDTO; - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - mcAuthoringForm.setTitle(richTextTitle); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - mcAuthoringForm.setCurrentTab("1"); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("itemList")); - } - - /** - * moves a question down in the list - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - - IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndex = request.getParameter("questionIndex"); - mcAuthoringForm.setQuestionIndex(questionIndex); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - questionDTOs = AuthoringUtil.swapQuestions(questionDTOs, questionIndex, "down"); - - questionDTOs = AuthoringUtil.reorderSimpleQuestionDtos(questionDTOs); - - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - mcAuthoringForm.setTitle(richTextTitle); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - mcAuthoringForm.setCurrentTab("1"); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - return (mapping.findForward("itemList")); - } - - public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndex = request.getParameter("questionIndex"); - mcAuthoringForm.setQuestionIndex(questionIndex); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - questionDTOs = AuthoringUtil.swapQuestions(questionDTOs, questionIndex, "up"); - - questionDTOs = AuthoringUtil.reorderSimpleQuestionDtos(questionDTOs); - - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String richTextTitle = request.getParameter(McAppConstants.TITLE); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - mcAuthoringForm.setTitle(richTextTitle); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - mcAuthoringForm.setCurrentTab("1"); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("itemList")); - } - - /** - * moves a candidate dwn in the list - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndex = request.getParameter("questionIndex"); - request.setAttribute("questionIndex", questionIndex); - request.setAttribute(McAppConstants.CURRENT_EDITABLE_QUESTION_INDEX, questionIndex); - String candidateIndex = request.getParameter("candidateIndex"); request.setAttribute("candidateIndex", candidateIndex); List optionDtos = McAction.repopulateOptionDTOs(request, false); - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); + //moveAddedCandidateUp + McQuestionDTO questionDto = (McQuestionDTO) sessionMap.get(McAppConstants.QUESTION_DTO); + List listCandidates = new LinkedList(); + listCandidates = McAction.swapOptions(optionDtos, candidateIndex, "up"); + questionDto.setOptionDtos(listCandidates); + sessionMap.put(McAppConstants.QUESTION_DTO, questionDto); - List candidates = new LinkedList(); - List listCandidates = new LinkedList(); - String editableQuestion = ""; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = (McQuestionDTO) iter.next(); - - String question = questionDto.getQuestion(); - String displayOrder = questionDto.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(questionIndex)) { - editableQuestion = questionDto.getQuestion(); - - candidates = questionDto.getListCandidateAnswersDTO(); - // candidates found - // but we are using the repopulated optionDtos here - - listCandidates = AuthoringUtil.swapOptions(optionDtos, candidateIndex, "down"); - - questionDto.setListCandidateAnswersDTO(listCandidates); - - break; - } - - } - } - - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - request.setAttribute("requestNewEditableQuestionBox", new Boolean(true).toString()); return (mapping.findForward("candidateAnswersList")); } - /** - * moves a candidate up in the list - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - String questionIndex = request.getParameter("questionIndex"); - request.setAttribute("questionIndex", questionIndex); - request.setAttribute(McAppConstants.CURRENT_EDITABLE_QUESTION_INDEX, questionIndex); - String candidateIndex = request.getParameter("candidateIndex"); request.setAttribute("candidateIndex", candidateIndex); List optionDtos = McAction.repopulateOptionDTOs(request, false); - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); + //moveAddedCandidateDown + McQuestionDTO questionDto = (McQuestionDTO) sessionMap.get(McAppConstants.QUESTION_DTO); + List swapedOptions = new LinkedList(); + swapedOptions = McAction.swapOptions(optionDtos, candidateIndex, "down"); + questionDto.setOptionDtos(swapedOptions); + sessionMap.put(McAppConstants.QUESTION_DTO, questionDto); - List listCandidates = new LinkedList(); - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - McQuestionDTO questionDto = (McQuestionDTO) iter.next(); - - String displayOrder = questionDto.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(questionIndex)) { - - listCandidates = AuthoringUtil.swapOptions(optionDtos, candidateIndex, "up"); - - questionDto.setListCandidateAnswersDTO(listCandidates); - - break; - } - - } - } - - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - request.setAttribute("requestNewEditableQuestionBox", new Boolean(true).toString()); return (mapping.findForward("candidateAnswersList")); } - - /** - * removes a candidate from the list - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException + + /* + * swaps options in the list */ - public ActionForward removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); + private static List swapOptions(List optionDtos, String optionIndex, String direction) { - String questionIndex = request.getParameter("questionIndex"); - request.setAttribute("questionIndex", questionIndex); - request.setAttribute(McAppConstants.CURRENT_EDITABLE_QUESTION_INDEX, questionIndex); + int intOptionIndex = new Integer(optionIndex).intValue(); + int intOriginalOptionIndex = intOptionIndex; - String optionIndexToRemove = request.getParameter("candidateIndex"); - request.setAttribute("candidateIndex", optionIndexToRemove); - - //find question - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - McQuestionDTO questionDto = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - questionDto = (McQuestionDTO) iter.next(); - String displayOrder = questionDto.getDisplayOrder(); - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(questionIndex)) { - break; - } - } + int replacedOptionIndex = 0; + if (direction.equals("down")) { + replacedOptionIndex = ++intOptionIndex; + } else { + replacedOptionIndex = --intOptionIndex; } - //update options - List optionDtos = McAction.repopulateOptionDTOs(request, false); - List listFinalCandidatesDTO = new LinkedList(); - McOptionDTO mcOptionDTO = null; - Iterator listCaIterator = optionDtos.iterator(); - int caIndex = 0; - while (listCaIterator.hasNext()) { - caIndex++; - mcOptionDTO = (McOptionDTO) listCaIterator.next(); - if (caIndex != new Integer(optionIndexToRemove).intValue()) { - listFinalCandidatesDTO.add(mcOptionDTO); - } + McOptionDTO mainOption = AuthoringUtil.getOptionAtDisplayOrder(optionDtos, intOriginalOptionIndex); + McOptionDTO replacedOption = AuthoringUtil.getOptionAtDisplayOrder(optionDtos, replacedOptionIndex); + if ((mainOption == null) || (replacedOption == null)) { + return optionDtos; } - questionDto.setListCandidateAnswersDTO(listFinalCandidatesDTO); + List newOptionDtos = new LinkedList(); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); + int queIndex = 1; + for (McOptionDTO option : optionDtos) { - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - request.setAttribute("requestNewEditableQuestionBox", new Boolean(true).toString()); - return (mapping.findForward("candidateAnswersList")); - } - - /** - * enables adding a new candidate answer - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws IOException - * @throws ServletException - */ - public ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String questionIndex = request.getParameter("questionIndex"); - request.setAttribute("questionIndex", questionIndex); - request.setAttribute(McAppConstants.CURRENT_EDITABLE_QUESTION_INDEX, questionIndex); - - String candidateIndex = request.getParameter("candidateIndex"); - request.setAttribute("candidateIndex", candidateIndex); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - List optionDtos = McAction.repopulateOptionDTOs(request, true); - - String newQuestion = request.getParameter("newQuestion"); - - String mark = request.getParameter("mark"); - - McQuestionDTO mcQuestionContentDTOLocal = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - mcQuestionContentDTOLocal = (McQuestionDTO) iter.next(); - - String question = mcQuestionContentDTOLocal.getQuestion(); - String displayOrder = mcQuestionContentDTOLocal.getDisplayOrder(); - - if ((displayOrder != null) && (!displayOrder.equals(""))) { - if (displayOrder.equals(questionIndex)) { - break; - } - + McOptionDTO tempOption = new McOptionDTO(); + if ((!new Integer(queIndex).toString().equals(new Integer(intOriginalOptionIndex).toString())) + && !new Integer(queIndex).toString().equals(new Integer(replacedOptionIndex).toString())) { + // normal copy + tempOption = option; + } else if (new Integer(queIndex).toString().equals(new Integer(intOriginalOptionIndex).toString())) { + // move type 1 + tempOption = replacedOption; + } else if (new Integer(queIndex).toString().equals(new Integer(replacedOptionIndex).toString())) { + // move type 2 + tempOption = mainOption; } - } - if (mcQuestionContentDTOLocal != null) { - mcQuestionContentDTOLocal.setListCandidateAnswersDTO(optionDtos); + newOptionDtos.add(tempOption); + queIndex++; } - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - request.setAttribute("requestNewEditableQuestionBox", new Boolean(true).toString()); - return (mapping.findForward("candidateAnswersList")); + return newOptionDtos; } - public ActionForward moveAddedCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapId); request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - String candidateIndex = request.getParameter("candidateIndex"); - request.setAttribute("candidateIndex", candidateIndex); - - List optionDtos = McAction.repopulateOptionDTOs(request, false); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - //moveAddedCandidateUp - McQuestionDTO newQuestionDTO = (McQuestionDTO) sessionMap.get(McAppConstants.NEW_QUESTION_DTO); - List listCandidates = new LinkedList(); - listCandidates = AuthoringUtil.swapOptions(optionDtos, candidateIndex, "up"); - newQuestionDTO.setListCandidateAnswersDTO(listCandidates); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - sessionMap.put(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("candidateAnswersAddList")); - - } - - public ActionForward moveAddedCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - - String candidateIndex = request.getParameter("candidateIndex"); - request.setAttribute("candidateIndex", candidateIndex); - - List optionDtos = McAction.repopulateOptionDTOs(request, false); - - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - //moveAddedCandidateDown - McQuestionDTO newQuestionDTO = (McQuestionDTO) sessionMap.get(McAppConstants.NEW_QUESTION_DTO); - List listCandidates = new LinkedList(); - listCandidates = AuthoringUtil.swapOptions(optionDtos, candidateIndex, "down"); - newQuestionDTO.setListCandidateAnswersDTO(listCandidates); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - sessionMap.put(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("candidateAnswersAddList")); - } - - public ActionForward removeAddedCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(sessionMapId); - request.setAttribute(McAppConstants.ATTR_SESSION_MAP_ID, sessionMapId); - String candidateIndexToRemove = request.getParameter("candidateIndex"); request.setAttribute("candidateIndex", candidateIndexToRemove); - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - // removeAddedCandidate - McQuestionDTO newQuestionDTO = (McQuestionDTO) sessionMap.get(McAppConstants.NEW_QUESTION_DTO); + McQuestionDTO questionDto = (McQuestionDTO) sessionMap.get(McAppConstants.QUESTION_DTO); List optionDtos = McAction.repopulateOptionDTOs(request, false); List listFinalCandidatesDTO = new LinkedList(); @@ -1216,31 +711,14 @@ } } - newQuestionDTO.setListCandidateAnswersDTO(listFinalCandidatesDTO); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - sessionMap.put(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); + questionDto.setOptionDtos(listFinalCandidatesDTO); + sessionMap.put(McAppConstants.QUESTION_DTO, questionDto); - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String newQuestion = request.getParameter("newQuestion"); - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - - String mark = request.getParameter("mark"); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("candidateAnswersAddList")); + return (mapping.findForward("candidateAnswersList")); } - public ActionForward newAddedCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; String sessionMapId = request.getParameter(McAppConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapId); @@ -1249,34 +727,14 @@ String candidateIndex = request.getParameter("candidateIndex"); request.setAttribute("candidateIndex", candidateIndex); - List questionDTOs = (List) sessionMap.get(McAppConstants.LIST_QUESTION_DTOS); - List optionDtos = McAction.repopulateOptionDTOs(request, true); - String newQuestion = request.getParameter("newQuestion"); - - String mark = request.getParameter("mark"); - //newAddedCandidateBox - McQuestionDTO newQuestionDTO = (McQuestionDTO) sessionMap.get(McAppConstants.NEW_QUESTION_DTO); - newQuestionDTO.setListCandidateAnswersDTO(optionDtos); - request.setAttribute(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - sessionMap.put(McAppConstants.NEW_QUESTION_DTO, newQuestionDTO); - sessionMap.put(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); + McQuestionDTO questionDto = (McQuestionDTO) sessionMap.get(McAppConstants.QUESTION_DTO); + questionDto.setOptionDtos(optionDtos); + sessionMap.put(McAppConstants.QUESTION_DTO, questionDto); - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); - - setFormProperties(request, mcAuthoringForm, mcGeneralAuthoringDTO); - - request.setAttribute(McAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - mcGeneralAuthoringDTO.setEditableQuestionText(newQuestion); - mcGeneralAuthoringDTO.setMarkValue(mark); - - request.setAttribute(McAppConstants.MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - request.setAttribute(McAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - - return (mapping.findForward("candidateAnswersAddList")); + return (mapping.findForward("candidateAnswersList")); } /** @@ -1293,7 +751,6 @@ } List optionDtos = new LinkedList(); - for (int i = 0; i < McAppConstants.MAX_OPTION_COUNT; i++) { String optionText = request.getParameter("ca" + i); Long optionUid = WebUtil.readLongParam(request, "caUid" + i, true); @@ -1322,44 +779,5 @@ return optionDtos; } - - /** - * - */ - private static void setFormProperties(HttpServletRequest request, McAuthoringForm mcAuthoringForm, - McGeneralAuthoringDTO mcGeneralAuthoringDTO) { - String sln = request.getParameter("sln"); - mcAuthoringForm.setSln(sln); - mcGeneralAuthoringDTO.setSln(sln); - - String questionsSequenced = request.getParameter("questionsSequenced"); - mcAuthoringForm.setQuestionsSequenced(questionsSequenced); - mcGeneralAuthoringDTO.setQuestionsSequenced(questionsSequenced); - - String randomize = request.getParameter("randomize"); - mcAuthoringForm.setRandomize(randomize); - mcGeneralAuthoringDTO.setRandomize(randomize); - - String showMarks = request.getParameter("showMarks"); - mcAuthoringForm.setShowMarks(showMarks); - mcGeneralAuthoringDTO.setShowMarks(showMarks); - - String retries = request.getParameter("retries"); - mcAuthoringForm.setRetries(retries); - mcGeneralAuthoringDTO.setRetries(retries); - - String reflect = request.getParameter(REFLECT); - mcAuthoringForm.setReflect(reflect); - mcGeneralAuthoringDTO.setReflect(reflect); - - String reflectionSubject = request.getParameter(REFLECTION_SUBJECT); - mcAuthoringForm.setReflectionSubject(reflectionSubject); - mcGeneralAuthoringDTO.setReflectionSubject(reflectionSubject); - - String passmark = request.getParameter("passmark"); - mcGeneralAuthoringDTO.setPassMarkValue(passmark); - mcAuthoringForm.setPassmark(passmark); - } - } Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -46,10 +46,9 @@ import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; -import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McComparator; -import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.mc.dto.AnswerDTO; +import org.lamsfoundation.lams.tool.mc.dto.McGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; @@ -58,6 +57,8 @@ import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.util.McComparator; +import org.lamsfoundation.lams.tool.mc.web.form.McLearningForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; @@ -68,7 +69,7 @@ /** * @author Ozgur Demirtas */ -public class McLearningAction extends LamsDispatchAction implements McAppConstants { +public class McLearningAction extends LamsDispatchAction { private static Logger logger = Logger.getLogger(McLearningAction.class.getName()); private static IMcService mcService; @@ -472,7 +473,7 @@ mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, new Integer(user.getQueUsrId().intValue())); + McAppConstants.TOOL_SIGNATURE, new Integer(user.getQueUsrId().intValue())); request.setAttribute("notebookEntry", notebookEntry); if (notebookEntry != null) { mcGeneralLearnerFlowDTO.setNotebookEntry(notebookEntry.getEntry()); @@ -609,14 +610,14 @@ String reflectionEntry = request.getParameter(McAppConstants.ENTRY_TEXT); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, userID.intValue()); + McAppConstants.TOOL_SIGNATURE, userID.intValue()); if (notebookEntry != null) { notebookEntry.setEntry(reflectionEntry); mcService.updateEntry(notebookEntry); } else { mcService.createNotebookEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, userID.intValue(), reflectionEntry); + McAppConstants.TOOL_SIGNATURE, userID.intValue(), reflectionEntry); } return endLearning(mapping, form, request, response); @@ -655,7 +656,7 @@ // attempt getting notebookEntry NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, userID.intValue()); + McAppConstants.TOOL_SIGNATURE, userID.intValue()); if (notebookEntry != null) { String notebookEntryPresentable = notebookEntry.getEntry(); Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -46,15 +46,16 @@ import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.ToolAccessMode; -import org.lamsfoundation.lams.tool.mc.AnswerDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.mc.dto.AnswerDTO; +import org.lamsfoundation.lams.tool.mc.dto.McGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr; import org.lamsfoundation.lams.tool.mc.pojos.McSession; import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.service.McApplicationException; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.web.form.McLearningForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.WebUtil; @@ -68,7 +69,7 @@ * * @author Ozgur Demirtas */ -public class McLearningStarterAction extends Action implements McAppConstants { +public class McLearningStarterAction extends Action { private static Logger logger = Logger.getLogger(McLearningStarterAction.class.getName()); @@ -161,7 +162,7 @@ mcGeneralLearnerFlowDTO.setReflectionSubject(mcContent.getReflectionSubject()); NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, - McAppConstants.MY_SIGNATURE, userID.intValue()); + McAppConstants.TOOL_SIGNATURE, userID.intValue()); if (notebookEntry != null) { // String notebookEntryPresentable = McUtils.replaceNewLines(notebookEntry.getEntry()); @@ -191,11 +192,11 @@ Set groupUsers = mcSession.getMcQueUsers();// mcService.getUsersBySession(new // Long(toolSessionID).longValue()); - request.setAttribute(ATTR_GROUP_USERS, groupUsers); - request.setAttribute(TOOL_SESSION_ID, toolSessionID); - request.setAttribute(ATTR_CONTENT, mcContent); + request.setAttribute(McAppConstants.ATTR_GROUP_USERS, groupUsers); + request.setAttribute(McAppConstants.TOOL_SESSION_ID, toolSessionID); + request.setAttribute(McAppConstants.ATTR_CONTENT, mcContent); - return mapping.findForward(WAIT_FOR_LEADER); + return mapping.findForward(McAppConstants.WAIT_FOR_LEADER); } // check if leader has submitted all answers @@ -210,11 +211,11 @@ } } - sessionMap.put(ATTR_GROUP_LEADER, groupLeader); + sessionMap.put(McAppConstants.ATTR_GROUP_LEADER, groupLeader); boolean isUserLeader = mcSession.isUserGroupLeader(user); - sessionMap.put(ATTR_IS_USER_LEADER, isUserLeader); + sessionMap.put(McAppConstants.ATTR_IS_USER_LEADER, isUserLeader); sessionMap.put(AttributeNames.ATTR_MODE, mode); - sessionMap.put(ATTR_CONTENT, mcContent); + sessionMap.put(McAppConstants.ATTR_CONTENT, mcContent); request.setAttribute("sessionMapID", sessionMap.getSessionID()); /* user has already submitted response once OR it's a monitor - go to viewAnswers page. */ @@ -223,7 +224,7 @@ ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("viewAnswersRedirect")); redirect.addParameter(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionID); redirect.addParameter("userID", userID); - redirect.addParameter(MODE, mode); + redirect.addParameter(McAppConstants.MODE, mode); redirect.addParameter("httpSessionID", sessionMap.getSessionID()); return redirect; } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -48,8 +48,8 @@ import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO; -import org.lamsfoundation.lams.tool.mc.McUserMarkDTO; +import org.lamsfoundation.lams.tool.mc.dto.McGeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.mc.dto.McUserMarkDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; @@ -68,7 +68,7 @@ /** * * @author Ozgur Demirtas */ -public class McMonitoringAction extends LamsDispatchAction implements McAppConstants { +public class McMonitoringAction extends LamsDispatchAction { private static Logger logger = Logger.getLogger(McMonitoringAction.class.getName()); /** @@ -101,7 +101,7 @@ String userName = request.getParameter("userName"); String sessionId = request.getParameter("sessionId"); NotebookEntry notebookEntry = mcService.getEntry(new Long(sessionId), CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(userId)); + McAppConstants.TOOL_SIGNATURE, new Integer(userId)); McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = new McGeneralLearnerFlowDTO(); if (notebookEntry != null) { @@ -110,9 +110,9 @@ mcGeneralLearnerFlowDTO.setUserName(userName); } - request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); + request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO); - return mapping.findForward(LEARNER_NOTEBOOK); + return mapping.findForward(McAppConstants.LEARNER_NOTEBOOK); } /** Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringStarterAction.java (.../McMonitoringStarterAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -43,13 +43,13 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McGeneralMonitoringDTO; -import org.lamsfoundation.lams.tool.mc.ReflectionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McGeneralMonitoringDTO; +import org.lamsfoundation.lams.tool.mc.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.mc.dto.SessionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McSession; import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.service.McApplicationException; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; import org.lamsfoundation.lams.tool.mc.util.McSessionComparator; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; @@ -63,7 +63,7 @@ * * @author Ozgur Demirtas */ -public class McMonitoringStarterAction extends Action implements McAppConstants { +public class McMonitoringStarterAction extends Action { private static Logger logger = Logger.getLogger(McMonitoringStarterAction.class.getName()); private static IMcService service; @@ -100,11 +100,11 @@ sessionDtos.add(sessionDto); } - request.setAttribute(SESSION_DTOS, sessionDtos); + request.setAttribute(McAppConstants.SESSION_DTOS, sessionDtos); // setting up the advanced summary - request.setAttribute(ATTR_CONTENT, mcContent); + request.setAttribute(McAppConstants.ATTR_CONTENT, mcContent); request.setAttribute("questionsSequenced", mcContent.isQuestionsSequenced()); request.setAttribute("showMarks", mcContent.isShowMarks()); request.setAttribute("useSelectLeaderToolOuput", mcContent.isUseSelectLeaderToolOuput()); @@ -143,16 +143,14 @@ boolean isGroupedActivity = service.isGroupedActivity(new Long(mcContent.getMcContentId())); request.setAttribute("isGroupedActivity", isGroupedActivity); - mcGeneralMonitoringDTO.setCurrentTab("1"); - /* this section is needed for Edit Activity screen, from here... */ mcGeneralMonitoringDTO.setDisplayAnswers(new Boolean(mcContent.isDisplayAnswers()).toString()); List reflectionsContainerDTO = service.getReflectionList(mcContent, null); - request.setAttribute(REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); + request.setAttribute(McAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - request.setAttribute(MC_GENERAL_MONITORING_DTO, mcGeneralMonitoringDTO); + request.setAttribute(McAppConstants.MC_GENERAL_MONITORING_DTO, mcGeneralMonitoringDTO); //count users int countSessionComplete = 0; @@ -163,7 +161,7 @@ if (mcSession != null) { - if (mcSession.getSessionStatus().equals(COMPLETED)) { + if (mcSession.getSessionStatus().equals(McAppConstants.COMPLETED)) { countSessionComplete++; } countAllUsers += mcSession.getMcQueUsers().size(); @@ -172,7 +170,7 @@ mcGeneralMonitoringDTO.setCountAllUsers(new Integer(countAllUsers)); mcGeneralMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete)); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); + return (mapping.findForward(McAppConstants.LOAD_MONITORING_CONTENT)); } // ************************************************************************************* Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java (.../McPedagogicalPlannerAction.java) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java (.../McPedagogicalPlannerAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -41,12 +41,13 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.web.form.McPedagogicalPlannerForm; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; Fisheye: Tag 289926a27bdbc9bd2519e3064a85f489fc1845ec refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerForm.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== diff -u -r1555edf007ae13898458700147b51f6909126179 -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 1555edf007ae13898458700147b51f6909126179) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -39,12 +39,12 @@ import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McGeneralAuthoringDTO; -import org.lamsfoundation.lams.tool.mc.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; import org.lamsfoundation.lams.tool.mc.pojos.McContent; import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.service.McApplicationException; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.web.form.McAuthoringForm; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; @@ -54,15 +54,14 @@ * * @author Ozgur Demirtas */ -public class McStarterAction extends Action implements McAppConstants { +public class McStarterAction extends Action { private static Logger logger = Logger.getLogger(McStarterAction.class.getName()); @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, McApplicationException { McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - McGeneralAuthoringDTO mcGeneralAuthoringDTO = new McGeneralAuthoringDTO(); SessionMap sessionMap = new SessionMap(); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); @@ -76,8 +75,6 @@ ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); sessionMap.put(AttributeNames.ATTR_MODE, mode); - mcAuthoringForm.resetRadioBoxes(); - IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); // request is from monitoring module @@ -86,80 +83,39 @@ } if ((strToolContentID == null) || (strToolContentID.equals(""))) { - return (mapping.findForward(ERROR_LIST)); + return (mapping.findForward(McAppConstants.ERROR_LIST)); } McContent mcContent = mcService.getMcContent(new Long(strToolContentID)); // if mcContent does not exist, try to use default content instead. if (mcContent == null) { - long defaultContentID = mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + long defaultContentID = mcService.getToolDefaultContentIdBySignature(McAppConstants.TOOL_SIGNATURE); mcContent = mcService.getMcContent(new Long(defaultContentID)); mcContent = McContent.newInstance(mcContent, new Long(strToolContentID)); } - prepareDTOandForm(request, mapping, mcAuthoringForm, mcContent, mcGeneralAuthoringDTO); - - List questionDtos = AuthoringUtil.buildDefaultQuestions(mcContent); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(questionDtos.size())); - request.setAttribute(LIST_QUESTION_DTOS, questionDtos); - sessionMap.put(LIST_QUESTION_DTOS, questionDtos); - - List listDeletedQuestionDTOs = new ArrayList(); - sessionMap.put(LIST_DELETED_QUESTION_DTOS, listDeletedQuestionDTOs); - - mcGeneralAuthoringDTO.setMarkValue("1"); - - String passMark = " "; - if ((mcContent.getPassMark() != null) && (mcContent.getPassMark().intValue() != 0)) { - passMark = mcContent.getPassMark().toString(); - } - mcGeneralAuthoringDTO.setPassMarkValue(passMark); - - request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - - return (mapping.findForward(LOAD_AUTHORING)); - } - - /** - * prepares the data for presentation purposes. - * - * @param request - * @param mapping - * @param mcAuthoringForm - * @param mapQuestionContent - * @param toolContentID - * @return ActionForward - */ - protected McContent prepareDTOandForm(HttpServletRequest request, ActionMapping mapping, - McAuthoringForm mcAuthoringForm, McContent mcContent, - McGeneralAuthoringDTO mcGeneralAuthoringDTO) { - + // prepare form mcAuthoringForm.setSln(mcContent.isShowReport() ? "1" : "0"); mcAuthoringForm.setQuestionsSequenced(mcContent.isQuestionsSequenced() ? "1" : "0"); mcAuthoringForm.setRandomize(mcContent.isRandomize() ? "1" : "0"); mcAuthoringForm.setDisplayAnswers(mcContent.isDisplayAnswers() ? "1" : "0"); mcAuthoringForm.setShowMarks(mcContent.isShowMarks() ? "1" : "0"); mcAuthoringForm.setUseSelectLeaderToolOuput(mcContent.isUseSelectLeaderToolOuput() ? "1" : "0"); mcAuthoringForm.setPrefixAnswersWithLetters(mcContent.isPrefixAnswersWithLetters() ? "1" : "0"); - mcAuthoringForm.setRetries(mcContent.isRetries() ? "1" : "0"); mcAuthoringForm.setPassmark("" + mcContent.getPassMark()); mcAuthoringForm.setReflect(mcContent.isReflect() ? "1" : "0"); mcAuthoringForm.setReflectionSubject(mcContent.getReflectionSubject()); - - mcGeneralAuthoringDTO.setSln(mcContent.isShowReport() ? "1" : "0"); - mcGeneralAuthoringDTO.setQuestionsSequenced(mcContent.isQuestionsSequenced() ? "1" : "0"); - mcGeneralAuthoringDTO.setRandomize(mcContent.isRandomize() ? "1" : "0"); - mcGeneralAuthoringDTO.setDisplayAnswers(mcContent.isDisplayAnswers() ? "1" : "0"); - mcGeneralAuthoringDTO.setRetries(mcContent.isRetries() ? "1" : "0"); - mcGeneralAuthoringDTO.setReflect(mcContent.isReflect() ? "1" : "0"); - mcGeneralAuthoringDTO.setReflectionSubject(mcContent.getReflectionSubject()); - mcAuthoringForm.setTitle(mcContent.getTitle()); mcAuthoringForm.setInstructions(mcContent.getInstructions()); - mcAuthoringForm.resetUserAction(); - return mcContent; + List questionDtos = AuthoringUtil.buildDefaultQuestions(mcContent); + sessionMap.put(McAppConstants.QUESTION_DTOS, questionDtos); + + List listDeletedQuestionDTOs = new ArrayList(); + sessionMap.put(McAppConstants.LIST_DELETED_QUESTION_DTOS, listDeletedQuestionDTOs); + + return (mapping.findForward(McAppConstants.LOAD_AUTHORING)); } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McAuthoringForm.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,394 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.web.form; + +/** + * ActionForm for the Authoring environment + * + * @author Ozgur Demirtas + */ +public class McAuthoringForm extends McLearningForm { + /* form controllers */ + + protected String questionIndex; + protected String optionIndex; + + protected String showMarks; + protected String useSelectLeaderToolOuput; + protected String prefixAnswersWithLetters; + protected String randomize; + protected String displayAnswers; + + protected String submitAllContent; + + // dispatch controls which method is called by the Lookup map */ + protected String dispatch; + + protected String submit; + + /* basic content */ + protected String title; + protected String instructions; + + /* advanced content */ + protected String showFeedback; + protected String retries; + protected String sln; + + protected String passmark; + + protected String questionsSequenced; + + protected String reflect; + protected String reflectionSubject; + + protected String edit; + private String feedback; + 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() { + return submitAllContent; + } + + /** + * @param submitAllContent + * The submitAllContent to set. + */ + public void setSubmitAllContent(String submitAllContent) { + this.submitAllContent = submitAllContent; + } + + /** + * @return Returns the instructions. + */ + public String getInstructions() { + return instructions; + } + + /** + * @param instructions + * The instructions to set. + */ + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + + /** + * @param title + * The title to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return Returns the questionsSequenced. + */ + public String getQuestionsSequenced() { + return questionsSequenced; + } + + /** + * @param questionsSequenced + * The questionsSequenced to set. + */ + public void setQuestionsSequenced(String questionsSequenced) { + this.questionsSequenced = questionsSequenced; + } + + /** + * @return Returns the edit. + */ + public String getEdit() { + return edit; + } + + /** + * @param edit + * The edit to set. + */ + public void setEdit(String edit) { + this.edit = edit; + } + + /** + * @return Returns the optionIndex. + */ + public String getOptionIndex() { + return optionIndex; + } + + /** + * @param optionIndex + * The optionIndex to set. + */ + public void setOptionIndex(String optionIndex) { + this.optionIndex = optionIndex; + } + + /** + * @return Returns the retries. + */ + public String getRetries() { + return retries; + } + + /** + * @param retries + * The retries to set. + */ + public void setRetries(String retries) { + this.retries = retries; + } + + /** + * @return Returns the showFeedback. + */ + public String getShowFeedback() { + return showFeedback; + } + + /** + * @param showFeedback + * The showFeedback to set. + */ + public void setShowFeedback(String showFeedback) { + this.showFeedback = showFeedback; + } + + /** + * @return Returns the passmark. + */ + public String getPassmark() { + return passmark; + } + + /** + * @param passmark + * The passmark to set. + */ + public void setPassmark(String passmark) { + this.passmark = passmark; + } + + /** + * @return Returns the sln. + */ + public String getSln() { + return sln; + } + + /** + * @param sln + * The sln to set. + */ + public void setSln(String sln) { + this.sln = sln; + } + + public String getDispatch() { + return dispatch; + } + + public void setDispatch(String buttonValue) { + this.dispatch = buttonValue; + } + + /** + * @return Returns the submit. + */ + public String getSubmit() { + return submit; + } + + /** + * @param submit + * The submit to set. + */ + public void setSubmit(String submit) { + this.submit = submit; + } + + /** + * @return Returns the reflect. + */ + public String getReflect() { + return reflect; + } + + /** + * @param reflect + * The reflect to set. + */ + public void setReflect(String reflect) { + this.reflect = reflect; + } + + /** + * @return Returns the reflectionSubject. + */ + public String getReflectionSubject() { + return reflectionSubject; + } + + /** + * @param reflectionSubject + * The reflectionSubject to set. + */ + public void setReflectionSubject(String reflectionSubject) { + this.reflectionSubject = reflectionSubject; + } + + /** + * @return Returns the feedback. + */ + public String getFeedback() { + return feedback; + } + + /** + * @param feedback + * The feedback to set. + */ + public void setFeedback(String feedback) { + this.feedback = feedback; + } + + /** + * @return Returns the candidateIndex. + */ + public String getCandidateIndex() { + return candidateIndex; + } + + /** + * @param candidateIndex + * The candidateIndex to set. + */ + public void setCandidateIndex(String candidateIndex) { + this.candidateIndex = candidateIndex; + } + + /** + * @return Returns the showMarks. + */ + public String getShowMarks() { + return showMarks; + } + + /** + * @param showMarks + * The showMarks to set. + */ + public void setShowMarks(String showMarks) { + this.showMarks = showMarks; + } + + /** + * @return Returns the useSelectLeaderToolOuput. + */ + public String getUseSelectLeaderToolOuput() { + return useSelectLeaderToolOuput; + } + + /** + * @param useSelectLeaderToolOuput + * The useSelectLeaderToolOuput to set. + */ + public void setUseSelectLeaderToolOuput(String useSelectLeaderToolOuput) { + this.useSelectLeaderToolOuput = useSelectLeaderToolOuput; + } + + /** + * @return Returns the prefixAnswersWithLetters. + */ + public String getPrefixAnswersWithLetters() { + return prefixAnswersWithLetters; + } + + /** + * @param prefixAnswersWithLetters + * The prefixAnswersWithLetters to set. + */ + public void setPrefixAnswersWithLetters(String prefixAnswersWithLetters) { + this.prefixAnswersWithLetters = prefixAnswersWithLetters; + } + + /** + * @return Returns the randomize. + */ + public String getRandomize() { + return randomize; + } + + /** + * @param randomize + * The randomize to set. + */ + public void setRandomize(String randomize) { + this.randomize = randomize; + } + + /** + * @return Returns the displayAnswers. + */ + public String getDisplayAnswers() { + return displayAnswers; + } + + /** + * @param displayAnswers + * The displayAnswers to set. + */ + public void setDisplayAnswers(String displayAnswers) { + this.displayAnswers = displayAnswers; + } + +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McLearningForm.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,447 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.mc.web.form; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.mc.service.IMcService; + +/** + * @author Ozgur Demirtas + * + * ActionForm for the Learning environment + */ +public class McLearningForm extends ActionForm { + protected String continueOptions; + protected String nextOptions; + protected String continueOptionsCombined; + protected String redoQuestions; + protected String viewAnswers; + protected String learnerFinished; + protected String submitReflection; + protected String forwardtoReflection; + + protected String[] checkedCa; + protected String[] sequentialCheckedCa; + + protected Long userID; + protected String toolContentID; + protected String toolContentUID; + protected String toolSessionID; + + protected String learningMode; + protected String currentQuestionIndex; + + /** put tghese under SessionMap */ + protected String userOverPassMark; + protected String passMarkApplicable; + + protected String entryText; + + protected String questionIndex; + protected String nextQuestionSelected; + protected String httpSessionID; + + protected String sessionId; + + public IMcService mcService; + + public void resetCa(ActionMapping mapping, HttpServletRequest request) { + checkedCa = new String[0]; + } + + public void resetCommands() { + this.setContinueOptions(null); + this.setNextOptions(null); + this.setContinueOptionsCombined(null); + this.setRedoQuestions(null); + this.setViewAnswers(null); + this.setLearnerFinished(null); + } + + public void resetParameters() { + this.setNextQuestionSelected(null); + } + + /** + * @return Returns the continueOptions. + */ + public String getContinueOptions() { + return continueOptions; + } + + /** + * @param continueOptions + * The continueOptions to set. + */ + public void setContinueOptions(String continueOptions) { + this.continueOptions = continueOptions; + } + + /** + * @return Returns the continueOptionsCombined. + */ + public String getContinueOptionsCombined() { + return continueOptionsCombined; + } + + /** + * @param continueOptionsCombined + * The continueOptionsCombined to set. + */ + public void setContinueOptionsCombined(String continueOptionsCombined) { + this.continueOptionsCombined = continueOptionsCombined; + } + + /** + * @return Returns the redoQuestions. + */ + public String getRedoQuestions() { + return redoQuestions; + } + + /** + * @param redoQuestions + * The redoQuestions to set. + */ + public void setRedoQuestions(String redoQuestions) { + this.redoQuestions = redoQuestions; + } + + /** + * @return Returns the viewAnswers. + */ + public String getViewAnswers() { + return viewAnswers; + } + + /** + * @param viewAnswers + * The viewAnswers to set. + */ + public void setViewAnswers(String viewAnswers) { + this.viewAnswers = viewAnswers; + } + + /** + * @return Returns the nextOptions. + */ + public String getNextOptions() { + return nextOptions; + } + + /** + * @param nextOptions + * The nextOptions to set. + */ + public void setNextOptions(String nextOptions) { + this.nextOptions = nextOptions; + } + + /** + * @return Returns the learnerFinished. + */ + public String getLearnerFinished() { + return learnerFinished; + } + + /** + * @param learnerFinished + * The learnerFinished to set. + */ + public void setLearnerFinished(String learnerFinished) { + this.learnerFinished = learnerFinished; + } + + /** + * @return Returns the userOverPassMark. + */ + public String getUserOverPassMark() { + return userOverPassMark; + } + + /** + * @param userOverPassMark + * The userOverPassMark to set. + */ + public void setUserOverPassMark(String userOverPassMark) { + this.userOverPassMark = userOverPassMark; + } + + /** + * @return Returns the passMarkApplicable. + */ + public String getPassMarkApplicable() { + return passMarkApplicable; + } + + /** + * @param passMarkApplicable + * The passMarkApplicable to set. + */ + public void setPassMarkApplicable(String passMarkApplicable) { + this.passMarkApplicable = passMarkApplicable; + } + + /** + * @return Returns the checkedCa. + */ + public String[] getCheckedCa() { + return checkedCa; + } + + /** + * @param checkedCa + * The checkedCa to set. + */ + public void setCheckedCa(String[] checkedCa) { + this.checkedCa = checkedCa; + } + + /** + * @return Returns the learningMode. + */ + public String getLearningMode() { + return learningMode; + } + + /** + * @param learningMode + * The learningMode to set. + */ + public void setLearningMode(String learningMode) { + this.learningMode = learningMode; + } + + /** + * @return Returns the toolContentUID. + */ + public String getToolContentUID() { + return toolContentUID; + } + + /** + * @param toolContentUID + * The toolContentUID to set. + */ + public void setToolContentUID(String toolContentUID) { + this.toolContentUID = toolContentUID; + } + + /** + * @return Returns the currentQuestionIndex. + */ + public String getCurrentQuestionIndex() { + return currentQuestionIndex; + } + + /** + * @param currentQuestionIndex + * The currentQuestionIndex to set. + */ + public void setCurrentQuestionIndex(String currentQuestionIndex) { + this.currentQuestionIndex = currentQuestionIndex; + } + + /** + * @return Returns the nextQuestionSelected. + */ + public String getNextQuestionSelected() { + return nextQuestionSelected; + } + + /** + * @param nextQuestionSelected + * The nextQuestionSelected to set. + */ + public void setNextQuestionSelected(String nextQuestionSelected) { + this.nextQuestionSelected = nextQuestionSelected; + } + + /** + * @return Returns the questionIndex. + */ + public String getQuestionIndex() { + return questionIndex; + } + + /** + * @param questionIndex + * The questionIndex to set. + */ + public void setQuestionIndex(String questionIndex) { + this.questionIndex = questionIndex; + } + + /** + * @return Returns the toolContentID. + */ + public String getToolContentID() { + return toolContentID; + } + + /** + * @param toolContentID + * The toolContentID to set. + */ + public void setToolContentID(String toolContentID) { + this.toolContentID = toolContentID; + } + + /** + * @return Returns the toolSessionID. + */ + public String getToolSessionID() { + return toolSessionID; + } + + /** + * @param toolSessionID + * The toolSessionID to set. + */ + public void setToolSessionID(String toolSessionID) { + this.toolSessionID = toolSessionID; + } + + /** + * @return Returns the httpSessionID. + */ + public String getHttpSessionID() { + return httpSessionID; + } + + /** + * @param httpSessionID + * The httpSessionID to set. + */ + public void setHttpSessionID(String httpSessionID) { + this.httpSessionID = httpSessionID; + } + + /** + * @return Returns the sequentialCheckedCa. + */ + public String[] getSequentialCheckedCa() { + return sequentialCheckedCa; + } + + /** + * @param sequentialCheckedCa + * The sequentialCheckedCa to set. + */ + public void setSequentialCheckedCa(String[] sequentialCheckedCa) { + this.sequentialCheckedCa = sequentialCheckedCa; + } + + /** + * @return Returns the mcService. + */ + public IMcService getMcService() { + return mcService; + } + + /** + * @param mcService + * The mcService to set. + */ + public void setMcService(IMcService mcService) { + this.mcService = mcService; + } + + /** + * @return Returns the userID. + */ + public Long getUserID() { + return userID; + } + + /** + * @param userID + * The userID to set. + */ + public void setUserID(Long userID) { + this.userID = userID; + } + + /** + * @return Returns the submitReflection. + */ + public String getSubmitReflection() { + return submitReflection; + } + + /** + * @param submitReflection + * The submitReflection to set. + */ + public void setSubmitReflection(String submitReflection) { + this.submitReflection = submitReflection; + } + + /** + * @return Returns the forwardtoReflection. + */ + public String getForwardtoReflection() { + return forwardtoReflection; + } + + /** + * @param forwardtoReflection + * The forwardtoReflection to set. + */ + public void setForwardtoReflection(String forwardtoReflection) { + this.forwardtoReflection = forwardtoReflection; + } + + /** + * @return Returns the entryText. + */ + public String getEntryText() { + return entryText; + } + + /** + * @param entryText + * The entryText to set. + */ + public void setEntryText(String entryText) { + this.entryText = entryText; + } + + /** + * @return Returns the sessionId. + */ + public String getSessionId() { + return sessionId; + } + + /** + * @param sessionId + * The sessionId to set. + */ + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } +} Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McPedagogicalPlannerForm.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McPedagogicalPlannerForm.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/form/McPedagogicalPlannerForm.java (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -0,0 +1,238 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.mc.web.form; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.mc.McAppConstants; +import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; +import org.lamsfoundation.lams.tool.mc.dto.McQuestionDTO; +import org.lamsfoundation.lams.tool.mc.pojos.McContent; +import org.lamsfoundation.lams.tool.mc.service.IMcService; +import org.lamsfoundation.lams.tool.mc.web.AuthoringUtil; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; + +public class McPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { + private static Logger logger = Logger.getLogger(McPedagogicalPlannerForm.class); + + private List question; + private List candidateAnswerCount; + private String candidateAnswersString; + private List correct; + + public ActionMessages validate(HttpServletRequest request) { + ActionMessages errors = new ActionMessages(); + boolean allEmpty = true; + + if (question != null && !question.isEmpty()) { + int questionIndex = 1; + for (String item : question) { + if (item != null || !StringUtils.isEmpty(item)) { + try { + List candidateAnswerList = extractCandidateAnswers(request, questionIndex); + if (candidateAnswerList != null) { + boolean answersEmpty = true; + ActionMessage correctAnswerBlankError = null; + for (McOptionDTO answer : candidateAnswerList) { + if (answer != null && !StringUtils.isEmpty(answer.getCandidateAnswer())) { + allEmpty = false; + answersEmpty = false; + } else if (McAppConstants.CORRECT.equals(answer.getCorrect())) { + correctAnswerBlankError = new ActionMessage( + "error.pedagogical.planner.empty.answer.selected", questionIndex); + } + } + if (!answersEmpty && correctAnswerBlankError != null) { + errors.add(ActionMessages.GLOBAL_MESSAGE, correctAnswerBlankError); + } + } + } catch (UnsupportedEncodingException e) { + McPedagogicalPlannerForm.logger.error(e.getMessage()); + return errors; + } + questionIndex++; + } + } + } + if (allEmpty) { + ActionMessage error = new ActionMessage("questions.none.submitted"); + errors.clear(); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + question = null; + setCandidateAnswersString(""); + } else if (!errors.isEmpty()) { + StringBuilder candidateAnswersBuilder = new StringBuilder(); + Map paramMap = request.getParameterMap(); + setCandidateAnswerCount(new ArrayList(getQuestionCount())); + for (String key : paramMap.keySet()) { + if (key.startsWith(McAppConstants.CANDIDATE_ANSWER_PREFIX)) { + String[] param = paramMap.get(key); + String answer = param[0]; + candidateAnswersBuilder.append(key).append('=').append(answer).append('&'); + } + } + setCandidateAnswersString(candidateAnswersBuilder.toString()); + for (int questionIndex = 1; questionIndex <= getQuestionCount(); questionIndex++) { + Object param = paramMap.get(McAppConstants.CANDIDATE_ANSWER_COUNT + questionIndex); + int count = NumberUtils.toInt(((String[]) param)[0]); + getCandidateAnswerCount().add(count); + } + } + + setValid(errors.isEmpty()); + return errors; + } + + public void fillForm(McContent mcContent, IMcService mcService) { + if (mcContent != null) { + List questionDtos = AuthoringUtil.buildDefaultQuestions(mcContent); + + StringBuilder candidateAnswersBuilder = new StringBuilder(); + setCandidateAnswerCount(new ArrayList(questionDtos.size())); + for (int questionIndex = 1; questionIndex <= questionDtos.size(); questionIndex++) { + McQuestionDTO item = questionDtos.get(questionIndex - 1); + int questionDisplayOrder = item.getDisplayOrder(); + String questionText = item.getQuestion(); + setQuestion(questionDisplayOrder - 1, questionText); + List candidateAnswers = item.getOptionDtos(); + + for (int candidateAnswerIndex = 1; candidateAnswerIndex <= candidateAnswers + .size(); candidateAnswerIndex++) { + + McOptionDTO candidateAnswer = candidateAnswers.get(candidateAnswerIndex - 1); + + candidateAnswersBuilder.append(McAppConstants.CANDIDATE_ANSWER_PREFIX).append(questionDisplayOrder) + .append('-').append(candidateAnswerIndex).append('=') + .append(candidateAnswer.getCandidateAnswer()).append('&'); + if (candidateAnswer.getCorrect().equals(McAppConstants.CORRECT)) { + setCorrect(questionDisplayOrder - 1, String.valueOf(candidateAnswerIndex)); + } + getCandidateAnswerCount().add(candidateAnswers.size()); + } + } + setCandidateAnswersString(candidateAnswersBuilder.toString()); + } + } + + public void setQuestion(int number, String Questions) { + if (question == null) { + question = new ArrayList(); + } + while (number >= question.size()) { + question.add(null); + } + question.set(number, Questions); + } + + public String getQuestion(int number) { + if (question == null || number >= question.size()) { + return null; + } + return question.get(number); + } + + public Integer getQuestionCount() { + return question == null ? 0 : question.size(); + } + + public boolean removeQuestion(int number) { + if (question == null || number >= question.size()) { + return false; + } + question.remove(number); + return true; + } + + public String getCandidateAnswersString() { + return candidateAnswersString; + } + + public void setCandidateAnswersString(String candidateAnswers) { + candidateAnswersString = candidateAnswers; + } + + public List extractCandidateAnswers(HttpServletRequest request, int questionIndex) + throws UnsupportedEncodingException { + Map paramMap = request.getParameterMap(); + String[] param = paramMap.get(McAppConstants.CANDIDATE_ANSWER_COUNT + questionIndex); + + int count = NumberUtils.toInt(param[0]); + int correct = Integer.parseInt(getCorrect(questionIndex - 1)); + List candidateAnswerList = new ArrayList(); + for (int index = 1; index <= count; index++) { + param = paramMap.get(McAppConstants.CANDIDATE_ANSWER_PREFIX + questionIndex + "-" + index); + String answer = param[0]; + if (answer != null) { + McOptionDTO candidateAnswer = new McOptionDTO(); + candidateAnswer.setCandidateAnswer(answer); + if (index == correct) { + candidateAnswer.setCorrect(McAppConstants.CORRECT); + } + candidateAnswerList.add(candidateAnswer); + } + } + return candidateAnswerList; + } + + public String getCorrect(int number) { + if (correct == null || number >= correct.size()) { + return null; + } + return correct.get(number); + } + + public void setCorrect(int number, String correct) { + if (this.correct == null) { + this.correct = new ArrayList(); + } + while (number >= this.correct.size()) { + this.correct.add(null); + } + this.correct.set(number, correct); + } + + public List getCandidateAnswerCount() { + + return candidateAnswerCount; + } + + public void setCandidateAnswerCount(List candidateAnswerCount) { + + this.candidateAnswerCount = candidateAnswerCount; + } + + public List getQuestionList() { + return question; + } +} \ No newline at end of file Index: lams_tool_lamc/web/WEB-INF/struts-config.xml =================================================================== diff -u -r463f7b3dbb88ee41210f7170dc19dc25360cd26f -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 463f7b3dbb88ee41210f7170dc19dc25360cd26f) +++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -4,9 +4,9 @@ - - - + + + @@ -58,12 +58,6 @@ path="/authoring/AuthoringTabsHolder.jsp" redirect="false" /> - - - - Index: lams_tool_lamc/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r7db22881fda5bae3aaedb73407b1589e71c0404a -r289926a27bdbc9bd2519e3064a85f489fc1845ec --- lams_tool_lamc/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 7db22881fda5bae3aaedb73407b1589e71c0404a) +++ lams_tool_lamc/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 289926a27bdbc9bd2519e3064a85f489fc1845ec) @@ -72,7 +72,7 @@