Index: lams_tool_laqa/.classpath =================================================================== diff -u -r4148b35337096058f50c22fa950f64aa77294a4f -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/.classpath (.../.classpath) (revision 4148b35337096058f50c22fa950f64aa77294a4f) +++ lams_tool_laqa/.classpath (.../.classpath) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -20,6 +20,7 @@ + Index: lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -ra7690b14578fa656e8782755c2f45b9ee7aa00db -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision a7690b14578fa656e8782755c2f45b9ee7aa00db) +++ lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -225,6 +225,9 @@ outcome.authoring.existing.none =none outcome.authoring.remove.confirm =Are you sure you want to remove this learning outcome? label.question.bank =Question bank +label.no.added.questions =Add at least one question +label.title =Title +label.title.required =Title required +warning.msg.authoring.do.you.want.to.delete =Do you really want to delete this question? - #======= End labels: Exported 217 labels for en AU ===== Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -40,28 +40,21 @@ public static final String MY_SIGNATURE = "laqa11"; public static final String TOOL_CONTENT_ID = "toolContentID"; - public static final String ACTIVITY_TITLE_KEY = "activityTitleKey"; - public static final String ACTIVITY_INSTRUCTIONS_KEY = "activityInstructionsKey"; - public static final String LIST_QUESTION_DTOS = "questionDTOs"; - public static final String LIST_DELETED_QUESTION_DTOS = "deletedQuestionDTOs"; + public static final String LIST_QUESTIONS = "questions"; + public static final String LIST_DELETED_QUESTIONS = "deletedQuestions"; public static final String QUESTION_DTO = "questionDTO"; public static final String RESPONSES = "responses"; public static final String TOOL_SERVICE = "toolService"; - public static final String AUTHORING_STARTER = "starter"; public static final String TITLE = "title"; public static final String INSTRUCTIONS = "instructions"; public static final String LOAD_LEARNER = "learning/AnswersContent"; - public static final String LEARNING_STARTER = "learningStarter"; - public static final String MONITORING_STARTER = "monitoringStarter"; public static final String VIEW_ALL_RESULTS = "viewAllResults"; public static final String INDIVIDUAL_LEARNER_RESULTS = "learning/IndividualLearnerResults"; public static final String MAP_ALL_RESULTS_KEY = "mapAllResultsKey"; public static final String SOURCE_QA_STARTER = "sourceQaStarter"; - public static final String EDITABLE_RESPONSE_ID = "editableResponseId"; public static final String RESPONSE_UID = "responseUid"; public static final String IS_HIDE_ITEM = "isHideItem"; - public static final String COPY_TOOL_CONTENT = "copyToolContent"; public static final String MAP_SEQUENTIAL_ANSWERS_KEY = "mapSequentialAnswersKey"; public static final String TOOL_SESSION_ID = "toolSessionID"; public static final String NOTEBOOK = "notebook"; @@ -75,29 +68,18 @@ public static final String REMOVABLE_QUESTION_INDEX = "removableQuestionIndex"; public static final String DEFINE_LATER = "defineLater"; public static final String WAIT_FOR_LEADER = "waitForLeader"; - public static final String USERNAME_VISIBLE = "usernameVisible"; - public static final String ALLOW_RATE_ANSWERS = "allowRateAnswers"; - public static final String NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT = "notifyTeachersOnResponseSubmit"; - public static final String QUESTIONS_SEQUENCED = "questionsSequenced"; - public static final String MAXIMUM_RATES = "maximumRates"; - public static final String MINIMUM_RATES = "minimumRates"; public static final String SOURCE_MC_STARTER = "sourceMcStarter"; - public static final Integer MAX_QUESTION_COUNT = new Integer(50); + public static final Integer MAX_QUESTION_COUNT = 50; - public static final String REFLECT = "reflect"; - public static final String REFLECTION_SUBJECT = "reflectionSubject"; - public static final String GENERAL_LEARNER_FLOW_DTO = "generalLearnerFlowDTO"; - public static final Long INITIAL_QUESTION_COUNT = new Long(1); + public static final Long INITIAL_QUESTION_COUNT = 1L; /* * Struts level constants */ public static final String LOAD_MONITORING = "loadMonitoring"; - public static final String LOAD_QUESTIONS = "load"; - public static final String LOAD_STARTER = "starter"; public static final String LEARNING_MODE = "learningMode"; public static final String SUCCESS = "success"; @@ -129,26 +111,6 @@ public static final String MAP_TOOL_SESSIONS = "mapToolSessions"; public static final Integer MAX_TOOL_SESSION_COUNT = new Integer(500); - public static final String USER_EXCEPTION_WRONG_FORMAT = "userExceptionWrongFormat"; - public static final String USER_EXCEPTION_UNCOMPATIBLE_IDS = "userExceptionUncompatibleIds"; - public static final String USER_EXCEPTION_NUMBERFORMAT = "userExceptionNumberFormat"; - // public static final String USER_EXCEPTION_CONTENT_DOESNOTEXIST - // ="userExceptionContentDoesNotExist"; - public static final String USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST = "userExceptionToolSessionDoesNotExist"; - public static final String USER_EXCEPTION_CONTENTID_REQUIRED = "userExceptionContentIdRequired"; - public static final String USER_EXCEPTION_TOOLSESSIONID_REQUIRED = "userExceptionToolSessionIdRequired"; - public static final String USER_EXCEPTION_USERID_NOTAVAILABLE = "userExceptionUserIdNotAvailable"; - public static final String USER_EXCEPTION_USERID_NOTNUMERIC = "userExceptionUserIdNotNumeric"; - public static final String USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS = "userExceptionOnlyContentAndNoSessions"; - public static final String USER_EXCEPTION_USERID_EXISTING = "userExceptionUserIdExisting"; - public static final String USER_EXCEPTION_USER_DOESNOTEXIST = "userExceptionUserDoesNotExist"; - public static final String USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED = "userExceptionMonitoringTabContentIdRequired"; - public static final String USER_EXCEPTION_NO_TOOL_SESSIONS = "userExceptionNoToolSessions"; - public static final String USER_EXCEPTION_NO_STUDENT_ACTIVITY = "userExceptionNoStudentActivity"; - public static final String USER_EXCEPTION_CONTENT_IN_USE = "userExceptionContentInUse"; - public static final String USER_EXCEPTION_MODE_REQUIRED = "userExceptionModeRequired"; - public static final String USER_EXCEPTION_MODE_INVALID = "userExceptionModeInvalid"; - public static final String USER_EXCEPTION_QUESTIONS_DUPLICATE = "userExceptionQuestionsDuplicate"; public static final String COUNT_SESSION_COMPLETE = "countSessionComplete"; public static final String COUNT_ALL_USERS = "countAllUsers"; @@ -187,10 +149,6 @@ public static final String TO_TOOL_CONTENT_ID = "toToolContentId"; public static final String LEARNER_REPORT = "learnerRep"; public static final String LEARNER_REP = "individualLearnerRep"; - public static final String REQUEST_LEARNING_REPORT = "requestLearningReport"; - public static final String REQUEST_LEARNING_REPORT_PROGRESS = "requestLearningReportProgress"; - public static final String REQUEST_PREVIEW = "requestPreview"; - public static final String REQUEST_LEARNING_REPORT_VIEWONLY = "requestLearningReportViewOnly"; public static final String REVISITED_LEARNER_REP = "revisitedLearnerRep"; public static final String IS_DISABLED = "isDisabled"; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java (.../IQaContentDAO.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java (.../IQaContentDAO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -34,10 +34,6 @@ void saveOrUpdateQa(QaContent qa); - void saveQa(QaContent qa); - - void updateQa(QaContent qa); - void removeQa(Long qaContentId); void deleteQa(QaContent qa); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java =================================================================== diff -u -raa4a5ab8f694b3d018eba8f51eee5576086ae653 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (.../QaContentDAO.java) (revision aa4a5ab8f694b3d018eba8f51eee5576086ae653) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java (.../QaContentDAO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -53,24 +53,10 @@ } @Override - public void updateQa(QaContent qa) { - getSession().update(qa); - } - - @Override - public void saveQa(QaContent qa) { - getSession().save(qa); - } - - @Override public void saveOrUpdateQa(QaContent qa) { getSession().saveOrUpdate(qa); } - public void createQa(QaContent qa) { - getSession().save(qa); - } - @Override public void removeAllQaSession(QaContent qaContent) { deleteAll(qaContent.getQaSessions()); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java =================================================================== diff -u -r2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision 2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -113,9 +113,9 @@ return filteredSearchString; } - private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_AVG_RATING_SELECT = "SELECT resp.*, AVG(rating.rating) avg_rating "; + private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_AVG_RATING_SELECT = "SELECT resp.*, ans.*, AVG(rating.rating) avg_rating "; private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_AVG_RATING_FROM = " FROM tl_laqa11_usr_resp resp "; - private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_AVG_RATING_JOIN = " JOIN lams_qb_tool_answer ans ON ans.uid = resp.uid " + private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_AVG_RATING_JOIN = " JOIN lams_qb_tool_answer ans ON ans.answer_uid = resp.uid " + " AND ans.answer IS NOT NULL AND ans.tool_question_uid = :questionId JOIN tl_laqa11_que_usr usr" + " ON resp.que_usr_id = usr.uid AND usr.que_usr_id!=:excludeUserId " + " JOIN tl_laqa11_session sess ON usr.qa_session_id = sess.uid AND sess.qa_session_id = :qaSessionId"; @@ -125,9 +125,9 @@ + " ON rat.rating_criteria_id = crit.rating_criteria_id AND crit.tool_content_id = :toolContentId" + " ) rating ON rating.item_id = resp.uid GROUP BY resp.uid ORDER BY "; - private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_SELECT = "SELECT resp.*, COUNT(rating_comment.item_id) count_comment "; + private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_SELECT = "SELECT resp.*, ans.*, COUNT(rating_comment.item_id) count_comment "; private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_FROM = " FROM tl_laqa11_usr_resp resp "; - private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_JOIN = " JOIN lams_qb_tool_answer ans ON ans.uid = resp.uid " + private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_JOIN = " JOIN lams_qb_tool_answer ans ON ans.answer_uid = resp.uid " + " AND ans.answer IS NOT NULL AND ans.tool_question_uid = :questionId " + " JOIN tl_laqa11_que_usr usr ON resp.que_usr_id = usr.uid AND usr.que_usr_id!=:excludeUserId " + " JOIN tl_laqa11_session sess " @@ -138,9 +138,9 @@ private static final String SQL_LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_COMMENT_COUNT_ORDER_BY = " GROUP BY resp.uid ORDER BY count_comment ASC, " + "resp.uid ASC"; - private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_SELECT = "SELECT resp.* "; + private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_SELECT = "SELECT resp.*, ans.* "; private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_FROM = " FROM tl_laqa11_usr_resp resp "; - private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_JOIN1 = " JOIN lams_qb_tool_answer ans ON ans.uid = resp.uid " + private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_WITH_NAME_SEARCH_JOIN1 = " JOIN lams_qb_tool_answer ans ON ans.answer_uid = resp.uid " + " AND ans.answer IS NOT NULL AND ans.tool_question_uid = :questionId JOIN tl_laqa11_que_usr usr" + " ON resp.que_usr_id = usr.uid " + " AND usr.que_usr_id!=:excludeUserId " + " JOIN tl_laqa11_session sess " Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -52,7 +52,7 @@ protected String toolSessionID; - protected String httpSessionID; + protected String sessionMapID; protected String toolContentID; @@ -384,18 +384,18 @@ } /** - * @return Returns the httpSessionID. + * @return Returns the sessionMapID. */ - public String getHttpSessionID() { - return httpSessionID; + public String getSessionMapID() { + return sessionMapID; } /** - * @param httpSessionID - * The httpSessionID to set. + * @param sessionMapID + * The sessionMapID to set. */ - public void setHttpSessionID(String httpSessionID) { - this.httpSessionID = httpSessionID; + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; } /** Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -28,10 +28,10 @@ import org.lamsfoundation.lams.learningdesign.dto.TextSearchConditionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; import org.lamsfoundation.lams.tool.qa.model.QaQueContent; -import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionComparator; public class QaConditionDTO extends TextSearchConditionDTO { - private Set questions = new TreeSet<>(new QaQueContentComparator()); + private Set questions = new TreeSet<>(new QaQuestionComparator()); public QaConditionDTO(QaCondition condition, Integer toolActivityUIID) { super(condition, toolActivityUIID); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -38,13 +38,13 @@ private boolean required; private int minWordsLimit; - public QaQuestionDTO(QaQueContent que) { - this.question = que.getQbQuestion().getName(); - this.displayOrder = String.valueOf(que.getDisplayOrder()); - this.feedback = que.getQbQuestion().getFeedback() != null ? que.getQbQuestion().getFeedback() : ""; - this.required = que.getQbQuestion().isAnswerRequired(); - this.minWordsLimit = que.getQbQuestion().getMinWordsLimit(); - this.uid = que.getUid(); + public QaQuestionDTO(QaQueContent qaQuestion) { + this.question = qaQuestion.getQbQuestion().getName(); + this.displayOrder = String.valueOf(qaQuestion.getDisplayOrder()); + this.feedback = qaQuestion.getQbQuestion().getFeedback() != null ? qaQuestion.getQbQuestion().getFeedback() : ""; + this.required = qaQuestion.getQbQuestion().isAnswerRequired(); + this.minWordsLimit = qaQuestion.getQbQuestion().getMinWordsLimit(); + this.uid = qaQuestion.getUid(); } public QaQuestionDTO(String question, String displayOrder, String feedback, boolean required, int minWordsLimit) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaCondition.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaCondition.java (.../QaCondition.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaCondition.java (.../QaCondition.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -44,9 +44,7 @@ import org.lamsfoundation.lams.tool.ToolOutputFormatException; import org.lamsfoundation.lams.tool.ToolOutputValue; import org.lamsfoundation.lams.tool.qa.dto.QaConditionDTO; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; -import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; -import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionComparator; import org.lamsfoundation.lams.util.WebUtil; /** @@ -67,18 +65,18 @@ @Cascade({ CascadeType.SAVE_UPDATE }) @JoinTable(name = "tl_laqa11_condition_questions", joinColumns = @JoinColumn(name = "condition_id"), inverseJoinColumns = @JoinColumn(name = "question_uid")) @OrderBy("uid ASC") - private Set questions = new TreeSet<>(new QaQueContentComparator()); + private Set questions = new TreeSet<>(new QaQuestionComparator()); @Transient - public SortedSet temporaryQuestionDTOSet; + public SortedSet temporaryQaQuestions; public QaCondition() { - this.temporaryQuestionDTOSet = new TreeSet<>(new QaQuestionContentDTOComparator()); + this.temporaryQaQuestions = new TreeSet<>(new QaQuestionComparator()); } public QaCondition(QaConditionDTO conditionDTO) { super(conditionDTO); - this.temporaryQuestionDTOSet = new TreeSet<>(new QaQuestionContentDTOComparator()); + this.temporaryQaQuestions = new TreeSet<>(new QaQuestionComparator()); for (QaQueContent question : conditionDTO.getQuestions()) { QaQueContent questionCopy = new QaQueContent(question.getQbQuestion(), question.getDisplayOrder(), null); getQuestions().add(questionCopy); @@ -89,7 +87,7 @@ String allWords, String phrase, String anyWords, String excludedWords, Set questions) { super(conditionId, conditionUIID, orderId, name, displayName, BranchCondition.OUTPUT_TYPE_COMPLEX, null, null, null, allWords, phrase, anyWords, excludedWords); - this.temporaryQuestionDTOSet = new TreeSet<>(new QaQuestionContentDTOComparator()); + this.temporaryQaQuestions = new TreeSet<>(new QaQuestionComparator()); setQuestions(questions); } @@ -133,7 +131,7 @@ */ @Override public Object clone() { - Set questionsCopy = new TreeSet<>(new QaQueContentComparator()); + Set questionsCopy = new TreeSet<>(new QaQuestionComparator()); questionsCopy.addAll(questions); return new QaCondition(null, null, orderId, name, displayName, allWords, phrase, anyWords, excludedWords, questionsCopy); @@ -148,7 +146,7 @@ @Override public QaCondition clone(int uiidOffset) { Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset); - Set questionsCopy = new TreeSet<>(new QaQueContentComparator()); + Set questionsCopy = new TreeSet<>(new QaQuestionComparator()); for (QaQueContent question : getQuestions()) { QaQueContent questionCopy = new QaQueContent(question.getQbQuestion(), question.getDisplayOrder(), null); @@ -165,7 +163,7 @@ */ public QaCondition clone(QaContent qaContent) { - Set questionsCopy = new TreeSet<>(new QaQueContentComparator()); + Set questionsCopy = new TreeSet<>(new QaQuestionComparator()); for (QaQueContent conditionQuestion : getQuestions()) { for (QaQueContent contentQuestion : qaContent.getQaQueContents()) { if (conditionQuestion.getDisplayOrder() == contentQuestion.getDisplayOrder()) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaContent.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaContent.java (.../QaContent.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaContent.java (.../QaContent.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -26,6 +26,7 @@ import java.io.Serializable; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; @@ -48,18 +49,16 @@ import org.lamsfoundation.lams.rating.model.LearnerItemRatingCriteria; /** - * QaContent Value Object The value object that maps to our model database table: tl_laqa11_content The relevant - * hibernate mapping resides in: QaContent.hbm.xml - * * Holds content representation for the tool. Default content is made available to the tool by the database. * * @author Ozgur Demirtas */ -@SuppressWarnings("serial") @Entity @Table(name = "tl_laqa11_content") public class QaContent implements Serializable { + private static final long serialVersionUID = 7300602981184988326L; + @Id @Column @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -140,7 +139,7 @@ @OrderBy("displayOrder") private Set qaQueContents; - @OneToMany(mappedBy = "qaContent", cascade = CascadeType.ALL, orphanRemoval = true) + @OneToMany(mappedBy = "qaContent", cascade = CascadeType.ALL) private Set qaSessions; @OneToMany(cascade = CascadeType.ALL) Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java =================================================================== diff -u -r2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java (.../QaQueContent.java) (revision 2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java (.../QaQueContent.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -37,13 +37,9 @@ import org.lamsfoundation.lams.qb.model.QbToolQuestion; /** + * Holds question content within a particular content * * @author Ozgur Demirtas - * - * The value object that maps to our model database table: tl_laqa11_que_content The relevant hibernate mapping - * resides in: QaQueContent.hbm.xml - * - * Holds question content within a particular content */ @Entity @Table(name = "tl_laqa11_que_content") Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueUsr.java =================================================================== diff -u -r1ee503e3d0e0228ea8a45025fddf15d9623c0377 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueUsr.java (.../QaQueUsr.java) (revision 1ee503e3d0e0228ea8a45025fddf15d9623c0377) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueUsr.java (.../QaQueUsr.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -45,13 +45,10 @@ import org.lamsfoundation.lams.tool.qa.Nullable; /** - * + * + * Represents tool users. + * * @author Ozgur Demirtas - * - * The value object that maps to our model database table: - * tl_laqa11_que_usr The relevant hibernate mapping resides in: QaQueUsr.hbm.xml - * - * Represents tool users. */ @Entity @Table(name = "tl_laqa11_que_usr") Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaSession.java =================================================================== diff -u -r1ee503e3d0e0228ea8a45025fddf15d9623c0377 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaSession.java (.../QaSession.java) (revision 1ee503e3d0e0228ea8a45025fddf15d9623c0377) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaSession.java (.../QaSession.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -46,14 +46,10 @@ import org.lamsfoundation.lams.tool.qa.Nullable; /** + * Holds tool sessions * * @author Ozgur Demirtas - * - * QaSession Value Object The value object that maps to our model database - * table: tl_laqa11_session The relevant hibernate mapping resides in: - * QaSession.hbm.xml - * - * Holds tool sessions + * */ @Entity @Table(name = "tl_laqa11_session") Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaUsrResp.java =================================================================== diff -u -r2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaUsrResp.java (.../QaUsrResp.java) (revision 2b3d3b2f61d37cf2fa7cccc0cf4565e5dfc4b88e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaUsrResp.java (.../QaUsrResp.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -43,13 +43,8 @@ /** * Holds user responses to questions * - * QaUsrResp Value Object The value object that maps to our model database - * table: tl_laqa11_usr_resp The relevant hibernate mapping resides in: - * QaQueResp.hbm.xml - * * @author Ozgur Demirtas */ - @Entity @Table(name = "tl_laqa11_usr_resp") //in this entity's table primary key is "uid", but it references "answer_uid" in lams_qb_tool_answer Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -25,15 +25,13 @@ import java.util.Collection; import java.util.List; -import java.util.Set; import org.lamsfoundation.lams.logevent.service.ILogEventService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.rating.ToolRatingManager; import org.lamsfoundation.lams.tool.Tool; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; import org.lamsfoundation.lams.tool.qa.model.QaContent; import org.lamsfoundation.lams.tool.qa.model.QaQueContent; @@ -73,7 +71,7 @@ */ void copyAnswersFromLeader(QaQueUsr user, QaQueUsr leader); - void setDefineLater(String strToolContentID, boolean value); + void setDefineLater(Long toolContentID, boolean value); /** * Get users by given toolSessionID. @@ -94,6 +92,8 @@ QaContent getQaContent(long toolContentId); void saveOrUpdateQaContent(QaContent qa); + + void releaseFromCache(Object object); void updateUser(QaQueUsr qaQueUsr); @@ -155,10 +155,6 @@ void updateSession(QaSession qaSession); - void updateQaContent(QaContent qa); - - void createQaContent(QaContent qa); - void updateResponseVisibility(Long responseUid, boolean visible); boolean isRatingsEnabled(QaContent qaContent); @@ -169,9 +165,6 @@ List getAllQuestionEntries(final Long uid); - void recalculateUserAnswers(QaContent content, Set oldQuestions, List questionDTOs, - List deletedQuestions); - /** * copyToolContent(Long fromContentId, Long toContentId) return void * Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaService.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaService.java (.../QaService.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaService.java (.../QaService.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -26,7 +26,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; @@ -70,7 +69,6 @@ import org.lamsfoundation.lams.tool.qa.dao.IQaQuestionDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaSessionDAO; import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; import org.lamsfoundation.lams.tool.qa.model.QaContent; import org.lamsfoundation.lams.tool.qa.model.QaQueContent; @@ -193,12 +191,12 @@ } @Override - public void setDefineLater(String strToolContentID, boolean value) { - QaContent qaContent = getQaContent(new Long(strToolContentID).longValue()); + public void setDefineLater(Long toolContentID, boolean value) { + QaContent qaContent = getQaContent(toolContentID); if (qaContent != null) { qaContent.setDefineLater(value); - updateQaContent(qaContent); + saveOrUpdateQaContent(qaContent); } } @@ -209,11 +207,6 @@ } @Override - public void createQaContent(QaContent qaContent) { - qaDAO.saveQa(qaContent); - } - - @Override public QaContent getQaContent(long toolContentID) { return qaDAO.getQaByContentId(toolContentID); } @@ -222,6 +215,11 @@ public void saveOrUpdateQaContent(QaContent qa) { qaDAO.saveOrUpdateQa(qa); } + + @Override + public void releaseFromCache(Object object) { + qaQuestionDAO.releaseFromCache(object); + } @Override public QaQueContent getQuestionByContentAndDisplayOrder(Integer displayOrder, Long contentUid) { @@ -362,11 +360,6 @@ } @Override - public void updateQaContent(QaContent qa) { - qaDAO.updateQa(qa); - } - - @Override public void updateSession(QaSession qaSession) { qaSessionDAO.UpdateQaSession(qaSession); } @@ -433,79 +426,14 @@ } @Override - public void recalculateUserAnswers(QaContent content, Set oldQuestions, - List questionDTOs, List deletedQuestions) { - - // create list of modified questions - List modifiedQuestions = new ArrayList<>(); - for (QaQueContent oldQuestion : oldQuestions) { - for (QaQuestionDTO questionDTO : questionDTOs) { - if (oldQuestion.getUid().equals(questionDTO.getUid())) { - - // question is different - if (!oldQuestion.getQbQuestion().getName().equals(questionDTO.getQuestion())) { - modifiedQuestions.add(questionDTO); - } - } - } - } - - Set sessionList = content.getQaSessions(); - for (QaSession session : sessionList) { - Long toolSessionId = session.getQaSessionId(); - Set sessionUsers = session.getQaQueUsers(); - - for (QaQueUsr user : sessionUsers) { - - // get all finished user results - List userAttempts = qaUsrRespDAO.getResponsesByUserUid(user.getUid()); - Iterator iter = userAttempts.iterator(); - while (iter.hasNext()) { - QaUsrResp resp = iter.next(); - - QaQueContent question = resp.getQaQuestion(); - - boolean isRemoveQuestionResult = false; - - // [+] if the question is modified - for (QaQuestionDTO modifiedQuestion : modifiedQuestions) { - if (question.getUid().equals(modifiedQuestion.getUid())) { - isRemoveQuestionResult = true; - break; - } - } - - // [+] if the question was removed - for (QaQuestionDTO deletedQuestion : deletedQuestions) { - if (question.getUid().equals(deletedQuestion.getUid())) { - isRemoveQuestionResult = true; - break; - } - } - - if (isRemoveQuestionResult) { - iter.remove(); - qaUsrRespDAO.removeUserResponse(resp); - } - - // [+] doing nothing if the new question was added - - } - - } - } - - } - - @Override public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException { QaContent qaContent = qaDAO.getQaByContentId(toolContentId.longValue()); if (qaContent == null) { logger.error("throwing DataMissingException: WARNING!: retrieved qaContent is null."); throw new DataMissingException("qaContent is missing"); } qaContent.setDefineLater(false); - updateQaContent(qaContent); + saveOrUpdateQaContent(qaContent); } @Override @@ -539,12 +467,11 @@ for (QaQueContent question : toContent.getQaQueContents()) { qaQuestionDAO.saveOrUpdate(question); } - qaDAO.saveQa(toContent); + saveOrUpdateQaContent(toContent); } } - @SuppressWarnings("unchecked") @Override public void removeToolContent(Long toolContentId) throws ToolException { QaContent qaContent = qaDAO.getQaByContentId(toolContentId.longValue()); @@ -565,7 +492,6 @@ } @Override - @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { if (logger.isDebugEnabled()) { logger.debug("Removing Q&A answers for user ID " + userId + " and toolContentId " + toolContentId); Fisheye: Tag 86c25c80d92701a94c3161575c76c363891402ad refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/AuthoringUtil.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java (.../LearningUtil.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java (.../LearningUtil.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -53,8 +53,8 @@ String userID = request.getParameter("userID"); qaLearningForm.setUserID(userID); - String httpSessionID = request.getParameter("httpSessionID"); - qaLearningForm.setHttpSessionID(httpSessionID); + String sessionMapID = request.getParameter("sessionMapID"); + qaLearningForm.setSessionMapID(sessionMapID); String totalQuestionCount = request.getParameter("totalQuestionCount"); qaLearningForm.setTotalQuestionCount(totalQuestionCount); Fisheye: Tag 86c25c80d92701a94c3161575c76c363891402ad refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionComparator.java =================================================================== diff -u --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionComparator.java (revision 0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionComparator.java (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -0,0 +1,25 @@ +package org.lamsfoundation.lams.tool.qa.util; + +import java.util.Comparator; + +import org.lamsfoundation.lams.tool.qa.model.QaQueContent; + +/** + * Comparator for QaQueContent. Only the display order + * is compared. + * + * @author Marcin Cieslak + */ +public class QaQuestionComparator implements Comparator { + + @Override + public int compare(QaQueContent o1, QaQueContent o2) { + if (o1 != null && o2 != null) { + return o1.getDisplayOrder() - o2.getDisplayOrder(); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } +} \ No newline at end of file Fisheye: Tag 86c25c80d92701a94c3161575c76c363891402ad refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -25,64 +25,14 @@ import javax.servlet.http.HttpServletRequest; -import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; -import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm; -import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.web.util.AttributeNames; /** * Common utility functions live here. * * @author Ozgur Demirtas */ -public abstract class QaUtils implements QaAppConstants { - - public static void setFormProperties(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, - String strToolContentID, String httpSessionID) { - - qaAuthoringForm.setHttpSessionID(httpSessionID); - - qaAuthoringForm.setToolContentID(strToolContentID); - - String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE); - qaAuthoringForm.setUsernameVisible(usernameVisible); - - String allowRateAnswers = request.getParameter(QaAppConstants.ALLOW_RATE_ANSWERS); - qaAuthoringForm.setAllowRateAnswers(allowRateAnswers); - - String notifyTeachersOnResponseSubmit = request.getParameter(QaAppConstants.NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT); - qaAuthoringForm.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmit); - - String showOtherAnswers = request.getParameter("showOtherAnswers"); - qaAuthoringForm.setShowOtherAnswers(showOtherAnswers); - - String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED); - qaAuthoringForm.setQuestionsSequenced(questionsSequenced); - - String lockWhenFinished = request.getParameter("lockWhenFinished"); - qaAuthoringForm.setLockWhenFinished(lockWhenFinished); - - int minimumRates = WebUtil.readIntParam(request, QaAppConstants.MINIMUM_RATES, true) == null ? 0 - : WebUtil.readIntParam(request, QaAppConstants.MINIMUM_RATES); - qaAuthoringForm.setMinimumRates(minimumRates); - - int maximumRates = WebUtil.readIntParam(request, QaAppConstants.MAXIMUM_RATES, true) == null ? 0 - : WebUtil.readIntParam(request, QaAppConstants.MAXIMUM_RATES); - qaAuthoringForm.setMaximumRates(maximumRates); - - String reflect = request.getParameter(QaAppConstants.REFLECT); - - qaAuthoringForm.setReflect(reflect); - - String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT); - - qaAuthoringForm.setReflectionSubject(reflectionSubject); - - ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - } - +public abstract class QaUtils { /** * the only attributes kept are TOOL_SESSION and TOOL_CONTENT_ID and ACTIVITY_TITLE ACTIVITY_INSTRUCTIONS * cleanUpSessionAbsolute(HttpServletRequest request) @@ -91,15 +41,7 @@ */ public static void cleanUpSessionAbsolute(HttpServletRequest request) { request.getSession().removeAttribute(QaAppConstants.MY_SIGNATURE); - request.getSession().removeAttribute(QaAppConstants.AUTHORING_STARTER); - request.getSession().removeAttribute(QaAppConstants.LOAD_LEARNER); - request.getSession().removeAttribute(QaAppConstants.LEARNING_STARTER); - request.getSession().removeAttribute(QaAppConstants.MONITORING_STARTER); - request.getSession().removeAttribute(QaAppConstants.EDITABLE_RESPONSE_ID); - request.getSession().removeAttribute(QaAppConstants.COPY_TOOL_CONTENT); request.getSession().removeAttribute(QaAppConstants.TOOL_SESSION_ID); - request.getSession().removeAttribute(QaAppConstants.LOAD_QUESTIONS); - request.getSession().removeAttribute(QaAppConstants.LOAD_STARTER); request.getSession().removeAttribute(QaAppConstants.LEARNING_MODE); request.getSession().removeAttribute(QaAppConstants.IS_ADD_QUESTION); request.getSession().removeAttribute(QaAppConstants.IS_REMOVE_QUESTION); @@ -159,29 +101,6 @@ request.getSession().removeAttribute(QaAppConstants.CURRENT_ANSWER); request.getSession().removeAttribute(QaAppConstants.DEFINE_LATER); request.getSession().removeAttribute(QaAppConstants.SOURCE_MC_STARTER); - request.getSession().removeAttribute(QaAppConstants.REQUEST_LEARNING_REPORT); - request.getSession().removeAttribute(QaAppConstants.REQUEST_LEARNING_REPORT_VIEWONLY); - request.getSession().removeAttribute(QaAppConstants.REQUEST_PREVIEW); - request.getSession().removeAttribute(QaAppConstants.REQUEST_LEARNING_REPORT_PROGRESS); - - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_WRONG_FORMAT); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_UNCOMPATIBLE_IDS); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_NUMBERFORMAT); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_USER_DOESNOTEXIST); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_CONTENTID_REQUIRED); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_TOOLSESSIONID_REQUIRED); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_USERID_NOTAVAILABLE); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_USERID_NOTNUMERIC); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_USERID_EXISTING); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_NO_TOOL_SESSIONS); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_NO_STUDENT_ACTIVITY); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_CONTENT_IN_USE); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_MODE_REQUIRED); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_MODE_INVALID); - request.getSession().removeAttribute(QaAppConstants.USER_EXCEPTION_QUESTIONS_DUPLICATE); } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringConditionController.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringConditionController.java (.../QaAuthoringConditionController.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringConditionController.java (.../QaAuthoringConditionController.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -27,6 +27,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -37,9 +38,10 @@ import org.apache.commons.lang.math.NumberUtils; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; import org.lamsfoundation.lams.tool.qa.QaAppConstants; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; +import org.lamsfoundation.lams.tool.qa.model.QaQueContent; import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionComparator; import org.lamsfoundation.lams.tool.qa.web.form.QaConditionForm; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; @@ -184,7 +186,7 @@ conditionSet.clear(); conditionSet.addAll(conditionList); // add to delList - List deletedList = getDeletedQaConditionList(sessionMap); + List deletedList = QaAuthoringConditionController.getDeletedQaConditionList(sessionMap); deletedList.add(condition); } @@ -254,7 +256,8 @@ * @param request * @return */ - private SortedSet getQaConditionSet(SessionMap sessionMap) { + @SuppressWarnings("unchecked") + private SortedSet getQaConditionSet(SessionMap sessionMap) { SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); if (list == null) { list = new TreeSet<>(new TextSearchConditionComparator()); @@ -269,11 +272,12 @@ * @param request * @return */ - private List getQuestionList(SessionMap sessionMap) { - List list = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); + @SuppressWarnings("unchecked") + private SortedSet getQuestions(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.LIST_QUESTIONS); if (list == null) { - list = new LinkedList<>(); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, list); + list = new TreeSet<>(new QaQuestionComparator()); + sessionMap.put(QaAppConstants.LIST_QUESTIONS, list); } return list; } @@ -285,26 +289,16 @@ * @param request * @return */ - private List getDeletedQaConditionList(SessionMap sessionMap) { - return getListFromSession(sessionMap, QaAppConstants.ATTR_DELETED_CONDITION_LIST); - } - - /** - * Get java.util.List from HttpSession by given name. - * - * @param request - * @param name - * @return - */ - private List getListFromSession(SessionMap sessionMap, String name) { - List list = (List) sessionMap.get(name); + @SuppressWarnings("unchecked") + public static List getDeletedQaConditionList(SessionMap sessionMap) { + List list = (List) sessionMap.get(QaAppConstants.ATTR_DELETED_CONDITION_LIST); if (list == null) { - list = new ArrayList(); - sessionMap.put(name, list); + list = new ArrayList<>(); + sessionMap.put(QaAppConstants.ATTR_DELETED_CONDITION_LIST, list); } return list; } - + /** * This method will populate condition information to its form for edit use. * @@ -333,15 +327,15 @@ HttpServletRequest request) { // get back sessionMAP String sessionMapID = QaConditionForm.getSessionMapID(); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - List questions = getQuestionList(sessionMap); + SortedSet questions = getQuestions(sessionMap); // Initialise the LabelValueBeans in the possibleOptions array. Map possibleItems = new HashMap<>(questions.size()); int i = 0; - for (QaQuestionDTO question : questions) { - String nonHTMLQuestion = question.getQuestion(); + for (QaQueContent question : questions) { + String nonHTMLQuestion = question.getQbQuestion().getName(); if (nonHTMLQuestion != null) { nonHTMLQuestion = WebUtil.removeHTMLtags(nonHTMLQuestion); // we don't want to cite the whole question, so we just leave some first characters; it should be enough @@ -363,8 +357,8 @@ * @throws QaException */ private void extractFormToQaCondition(HttpServletRequest request, QaConditionForm form) throws Exception { - - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(form.getSessionMapID()); // check whether it is "edit(old item)" or "add(new item)" SortedSet conditionSet = getQaConditionSet(sessionMap); int orderId = form.getOrderId(); @@ -388,13 +382,13 @@ } Integer[] selectedItems = form.getSelectedItems(); - List questions = getQuestionList(sessionMap); + SortedSet questions = getQuestions(sessionMap); - condition.temporaryQuestionDTOSet.clear(); + condition.temporaryQaQuestions.clear(); for (Integer selectedItem : selectedItems) { - for (QaQuestionDTO question : questions) { + for (QaQueContent question : questions) { if (selectedItem.equals(new Integer(question.getDisplayOrder()))) { - condition.temporaryQuestionDTOSet.add(question); + condition.temporaryQaQuestions.add(question); } } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java (.../QaAuthoringController.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaAuthoringController.java (.../QaAuthoringController.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -24,11 +24,12 @@ package org.lamsfoundation.lams.tool.qa.web.controller; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.sql.Timestamp; import java.util.ArrayList; -import java.util.Collection; import java.util.Date; import java.util.Iterator; -import java.util.LinkedList; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.SortedSet; @@ -38,25 +39,27 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.math.NumberUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.qb.QbUtils; +import org.lamsfoundation.lams.qb.form.QbQuestionForm; import org.lamsfoundation.lams.qb.model.QbQuestion; import org.lamsfoundation.lams.qb.service.IQbService; import org.lamsfoundation.lams.rating.model.RatingCriteria; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.qa.QaAppConstants; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; import org.lamsfoundation.lams.tool.qa.model.QaContent; import org.lamsfoundation.lams.tool.qa.model.QaQueContent; import org.lamsfoundation.lams.tool.qa.service.IQaService; -import org.lamsfoundation.lams.tool.qa.util.AuthoringUtil; import org.lamsfoundation.lams.tool.qa.util.QaApplicationException; -import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator; -import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator; +import org.lamsfoundation.lams.tool.qa.util.QaQuestionComparator; import org.lamsfoundation.lams.tool.qa.util.QaUtils; import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.CommonConstants; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; @@ -66,8 +69,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -89,413 +90,125 @@ @Autowired private IQbService qbService; + + @Autowired + private IUserManagementService userManagementService; @Autowired @Qualifier("qaMessageService") private MessageService messageService; - @RequestMapping("") - public String unspecified() { - return "authoring/AuthoringTabsHolder"; - } - @RequestMapping("/authoring") - public String execute(@ModelAttribute("authoringForm") QaAuthoringForm authoringForm, HttpServletRequest request) - throws IOException, ServletException, QaApplicationException { - + public String execute(@ModelAttribute("authoringForm") QaAuthoringForm form, HttpServletRequest request, + @RequestParam Long toolContentID) throws IOException, ServletException, QaApplicationException { QaUtils.cleanUpSessionAbsolute(request); + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - authoringForm.setContentFolderID(contentFolderID); + form.setContentFolderID(contentFolderID); - authoringForm.resetRadioBoxes(); + form.setToolContentID(toolContentID.toString()); - validateDefaultContent(request, authoringForm); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - authoringForm.setToolContentID(strToolContentID); - SessionMap sessionMap = new SessionMap<>(); - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, ""); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, ""); sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); - sessionMap.put(AttributeNames.PARAM_TOOL_CONTENT_ID, strToolContentID); - authoringForm.setHttpSessionID(sessionMap.getSessionID()); + sessionMap.put(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentID); + sessionMap.put(AttributeNames.ATTR_MODE, mode); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + form.setSessionMapID(sessionMap.getSessionID()); - if (strToolContentID == null || strToolContentID.equals("")) { - QaUtils.cleanUpSessionAbsolute(request); - throw new ServletException("No Tool Content ID found"); - } - - QaContent qaContent = qaService.getQaContent(new Long(strToolContentID).longValue()); - if (qaContent == null) { + QaContent qa = qaService.getQaContent(toolContentID); + if (qa == null) { /* fetch default content */ long defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); - qaContent = qaService.getQaContent(defaultContentID); - qaContent = QaContent.newInstance(qaContent, new Long(strToolContentID)); + qa = qaService.getQaContent(defaultContentID); + qa = QaContent.newInstance(qa, toolContentID); } - prepareDTOandForm(request, authoringForm, qaContent, qaService, sessionMap); + form.setQa(qa); - ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); - // request is from monitoring module - if (mode.isTeacher()) { - qaService.setDefineLater(strToolContentID, true); - } - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - - SortedSet conditionList = getQaConditionList(sessionMap); - conditionList.clear(); - conditionList.addAll(qaContent.getConditions()); - - authoringForm.setAllowRichEditor(qaContent.isAllowRichEditor()); - authoringForm.setUseSelectLeaderToolOuput(qaContent.isUseSelectLeaderToolOuput()); - - sessionMap.put(QaAppConstants.ATTR_QA_AUTHORING_FORM, authoringForm); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - - // get rating criterias from DB - List ratingCriterias = qaService.getRatingCriterias(qaContent.getQaContentId()); - sessionMap.put(AttributeNames.ATTR_RATING_CRITERIAS, ratingCriterias); - - return "authoring/AuthoringTabsHolder"; - } - - /** - * retrives the existing content information from the db and prepares the data for presentation purposes. - * - * @param request - * @param mapping - * @param authoringForm - * @param mapQuestionContent - * @param toolContentID - * @return ActionForward - */ - protected QaContent prepareDTOandForm(HttpServletRequest request, - @ModelAttribute("authoringForm") QaAuthoringForm authoringForm, QaContent qaContent, IQaService qaService, - SessionMap sessionMap) { - - authoringForm.setUsernameVisible(qaContent.isUsernameVisible() ? "1" : "0"); - authoringForm.setAllowRateAnswers(qaContent.isAllowRateAnswers() ? "1" : "0"); - authoringForm.setNotifyTeachersOnResponseSubmit(qaContent.isNotifyTeachersOnResponseSubmit() ? "1" : "0"); - authoringForm.setShowOtherAnswers(qaContent.isShowOtherAnswers() ? "1" : "0"); - authoringForm.setQuestionsSequenced(qaContent.isQuestionsSequenced() ? "1" : "0"); - authoringForm.setLockWhenFinished(qaContent.isLockWhenFinished() ? "1" : "0"); - authoringForm.setNoReeditAllowed(qaContent.isNoReeditAllowed() ? "1" : "0"); - authoringForm.setMaximumRates(qaContent.getMaximumRates()); - authoringForm.setMinimumRates(qaContent.getMinimumRates()); - authoringForm.setReflect(qaContent.isReflect() ? "1" : "0"); - authoringForm.setReflectionSubject(qaContent.getReflectionSubject()); - authoringForm.setTitle(qaContent.getTitle()); - authoringForm.setInstructions(qaContent.getInstructions()); - authoringForm.setUseSelectLeaderToolOuput(qaContent.isUseSelectLeaderToolOuput()); - authoringForm.setAllowRichEditor(qaContent.isAllowRichEditor()); - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaContent.getTitle()); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); - - List questionDTOs = new LinkedList<>(); - /* * get the existing question content */ - Iterator queIterator = qaContent.getQaQueContents().iterator(); - while (queIterator.hasNext()) { + Set qaQuestions = getQuestions(sessionMap); + qaQuestions.clear(); + qaQuestions.addAll(qa.getQaQueContents()); - QaQueContent qaQuestion = (QaQueContent) queIterator.next(); - if (qaQuestion != null) { - QaQuestionDTO qaQuestionDTO = new QaQuestionDTO(qaQuestion); - questionDTOs.add(qaQuestionDTO); - } + form.resetUserAction(); + + // request is from monitoring module + if (mode.isTeacher()) { + qaService.setDefineLater(toolContentID, true); } + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - SortedSet conditionSet = new TreeSet<>(new TextSearchConditionComparator()); - for (QaCondition condition : qaContent.getConditions()) { - conditionSet.add(condition); - for (QaQuestionDTO dto : questionDTOs) { - for (QaQueContent question : condition.getQuestions()) { - if (dto.getDisplayOrder().equals(String.valueOf(question.getDisplayOrder()))) { - condition.temporaryQuestionDTOSet.add(dto); + //process conditions + for (QaCondition condition : qa.getConditions()) { + for (QaQueContent qaQuestion : qaQuestions) { + for (QaQueContent conditionQuestion : condition.getQuestions()) { + if (qaQuestion.getDisplayOrder() == conditionQuestion.getDisplayOrder()) { + condition.temporaryQaQuestions.add(qaQuestion); } } } } - sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, conditionSet); + SortedSet conditionList = getConditions(sessionMap); + conditionList.clear(); + conditionList.addAll(qa.getConditions()); - List listDeletedQuestionDTOs = new ArrayList<>(); - sessionMap.put(QaAppConstants.LIST_DELETED_QUESTION_DTOS, listDeletedQuestionDTOs); + sessionMap.put(QaAppConstants.ATTR_QA_AUTHORING_FORM, form); - authoringForm.resetUserAction(); + // get rating criterias from DB + List ratingCriterias = qaService.getRatingCriterias(qa.getQaContentId()); + sessionMap.put(AttributeNames.ATTR_RATING_CRITERIAS, ratingCriterias); - return qaContent; + return "authoring/AuthoringTabsHolder"; } /** - * each tool has a signature. QA tool's signature is stored in MY_SIGNATURE. - * The default tool content id and other depending content ids are obtained - * in this method. if all the default content has been setup properly the - * method persists DEFAULT_CONTENT_ID in the session. - * - * @param request - * @param mapping - * @return ActionForward - */ - public boolean validateDefaultContent(HttpServletRequest request, - @ModelAttribute("authoringForm") QaAuthoringForm authoringForm) { - - /* - * retrieve the default content id based on tool signature - */ - long defaultContentID = 0; - try { - defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); - if (defaultContentID == 0) { - QaAuthoringController.logger.debug("default content id has not been setup"); - return false; - } - } catch (Exception e) { - QaAuthoringController.logger.error("error getting the default content id: " + e.getMessage()); - persistError(request, "error.defaultContent.notSetup"); - return false; - } - - /* - * retrieve uid of the content based on default content id determined above - */ - try { - //retrieve uid of the content based on default content id determined above - QaContent qaContent = qaService.getQaContent(defaultContentID); - if (qaContent == null) { - QaAuthoringController.logger.error("Exception occured: No default content"); - persistError(request, "error.defaultContent.notSetup"); - return false; - } - - } catch (Exception e) { - QaAuthoringController.logger.error("Exception occured: No default question content"); - persistError(request, "error.defaultContent.notSetup"); - return false; - } - - return true; - } - - /** - * persists error messages to request scope - * - * @param request - * @param message - */ - public void persistError(HttpServletRequest request, String message) { - MultiValueMap errorMap = new LinkedMultiValueMap<>(); - errorMap.add("GLOBAL", messageService.getMessage(message)); - request.setAttribute("errorMap", errorMap); - } - - private SortedSet getQaConditionList(SessionMap sessionMap) { - SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); - if (list == null) { - list = new TreeSet<>(new TextSearchConditionComparator()); - sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, list); - } - return list; - } - - /** * submits content into the tool database + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalAccessException */ @RequestMapping("/submitAllContent") - public String submitAllContent(@ModelAttribute("authoringForm") QaAuthoringForm authoringForm, - HttpServletRequest request) throws IOException, ServletException { + public String submitAllContent(@ModelAttribute("authoringForm") QaAuthoringForm form, HttpServletRequest request) throws IOException, ServletException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { + SessionMap sessionMap = getSessionMap(form, request); + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + Long toolContentID = form.getQa().getQaContentId(); + QaContent qa = form.getQa(); + QaContent qaPO = qaService.getQaContent(toolContentID); - String httpSessionID = authoringForm.getHttpSessionID(); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + if (qaPO == null) { + // new Scratchie, create it. + qaPO = qa; + qaPO.setCreationDate(new Timestamp(new Date().getTime())); + qaPO.setUpdateDate(new Timestamp(new Date().getTime())); + + } else { + qaPO.getQaQueContents().clear(); + qaPO.getConditions().clear(); + Long uid = qaPO.getUid(); + PropertyUtils.copyProperties(qaPO, qa); + + // set back UID + qaPO.setUid(uid); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - authoringForm.setContentFolderID(contentFolderID); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - Long toolContentID = new Long(strToolContentID); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - MultiValueMap errorMap = new LinkedMultiValueMap<>(); - if (questionDTOs.size() == 0) { - errorMap.add("GLOBAL", messageService.getMessage("questions.none.submitted")); - } - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - authoringForm.setTitle(richTextTitle); - authoringForm.setInstructions(richTextInstructions); - - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - if (!errorMap.isEmpty()) { - request.setAttribute("errorMap", errorMap); - QaAuthoringController.logger.debug("errors saved: " + errorMap); - } - - QaContent qaContent = qaService.getQaContent(toolContentID); - if (errorMap.isEmpty()) { - ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - - List deletedQuestionDTOs = (List) sessionMap.get(LIST_DELETED_QUESTION_DTOS); - - // in case request is from monitoring module - recalculate User Answers + // if it is Teacher (from monitor) - change define later status if (mode.isTeacher()) { - Set oldQuestions = qaContent.getQaQueContents(); - qaService.removeQuestionsFromCache(qaContent); - qaService.setDefineLater(strToolContentID, false); + qaPO.setDefineLater(false); // audit log the teacher has started editing activity in monitor qaService.auditLogStartEditingActivityInMonitor(toolContentID); - // recalculate User Answers - qaService.recalculateUserAnswers(qaContent, oldQuestions, questionDTOs, deletedQuestionDTOs); + // recalculate User Answers - not required, as long as any question modification is minor and does not lead to changing question version or uid } - // remove deleted questions - for (QaQuestionDTO deletedQuestionDTO : deletedQuestionDTOs) { - QaQueContent removeableQuestion = qaService.getQuestionByUid(deletedQuestionDTO.getUid()); - if (removeableQuestion != null) { - qaContent.getQaQueContents().remove(removeableQuestion); - qaService.removeQuestion(removeableQuestion); - } - } - - // store content - SortedSet conditionSet = (SortedSet) sessionMap - .get(QaAppConstants.ATTR_CONDITION_SET); - qaContent = saveOrUpdateQaContent(questionDTOs, request, qaContent, toolContentID, conditionSet); - - //reOrganizeDisplayOrder - List sortedQuestions = qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue()); - Iterator iter = sortedQuestions.iterator(); - int displayOrder = 1; - while (iter.hasNext()) { - QaQueContent question = iter.next(); - - QaQueContent existingQaQueContent = qaService.getQuestionByUid(question.getUid()); - existingQaQueContent.setDisplayOrder(displayOrder); - qaService.saveOrUpdate(existingQaQueContent); - displayOrder++; - } - - // ************************* Handle rating criterias ******************* - List oldCriterias = (List) sessionMap - .get(AttributeNames.ATTR_RATING_CRITERIAS); - qaService.saveRatingCriterias(request, oldCriterias, toolContentID); - - QaUtils.setFormProperties(request, authoringForm, strToolContentID, httpSessionID); - - request.setAttribute(CommonConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); - - } else { - if (qaContent != null) { - QaUtils.setFormProperties(request, authoringForm, strToolContentID, httpSessionID); - } + qaPO.setUpdateDate(new Timestamp(new Date().getTime())); } - - List delConditionList = getDeletedQaConditionList(sessionMap); - Iterator iter = delConditionList.iterator(); - while (iter.hasNext()) { - QaCondition condition = iter.next(); - iter.remove(); - qaService.deleteCondition(condition); - } - - authoringForm.resetUserAction(); - authoringForm.setToolContentID(strToolContentID); - authoringForm.setHttpSessionID(httpSessionID); - authoringForm.setCurrentTab("1"); - - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - request.getSession().setAttribute(httpSessionID, sessionMap); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - return "authoring/AuthoringTabsHolder"; - } - - private QaContent saveOrUpdateQaContent(List questionDTOs, HttpServletRequest request, - QaContent qaContent, Long toolContentId, Set conditions) { + + // *******************************Handle user******************* UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE); - String allowRateQuestions = request.getParameter(QaAppConstants.ALLOW_RATE_ANSWERS); - String notifyTeachersOnResponseSubmit = request.getParameter(QaAppConstants.NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT); - String showOtherAnswers = request.getParameter("showOtherAnswers"); - String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED); - String lockWhenFinished = request.getParameter("lockWhenFinished"); - String noReeditAllowed = request.getParameter("noReeditAllowed"); - String allowRichEditor = request.getParameter("allowRichEditor"); - String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput"); - String reflect = request.getParameter(QaAppConstants.REFLECT); - String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT); - int minimumRates = WebUtil.readIntParam(request, "minimumRates"); - int maximumRates = WebUtil.readIntParam(request, "maximumRates"); - - boolean questionsSequencedBoolean = false; - boolean lockWhenFinishedBoolean = false; - boolean noReeditAllowedBoolean = false; - boolean usernameVisibleBoolean = false; - boolean allowRateQuestionsBoolean = false; - boolean notifyTeachersOnResponseSubmitBoolean = false; - boolean showOtherAnswersBoolean = false; - boolean reflectBoolean = false; - boolean allowRichEditorBoolean = false; - boolean useSelectLeaderToolOuputBoolean = false; - - if (questionsSequenced != null && questionsSequenced.equalsIgnoreCase("1")) { - questionsSequencedBoolean = true; - } - - if (lockWhenFinished != null && lockWhenFinished.equalsIgnoreCase("1")) { - lockWhenFinishedBoolean = true; - } - - if (noReeditAllowed != null && noReeditAllowed.equalsIgnoreCase("1")) { - noReeditAllowedBoolean = true; - lockWhenFinishedBoolean = true; - } - - if (usernameVisible != null && usernameVisible.equalsIgnoreCase("1")) { - usernameVisibleBoolean = true; - } - - if (showOtherAnswers != null && showOtherAnswers.equalsIgnoreCase("1")) { - showOtherAnswersBoolean = true; - } - - if (allowRateQuestions != null && allowRateQuestions.equalsIgnoreCase("1") && showOtherAnswersBoolean) { - allowRateQuestionsBoolean = true; - } - - if (notifyTeachersOnResponseSubmit != null && notifyTeachersOnResponseSubmit.equalsIgnoreCase("1")) { - notifyTeachersOnResponseSubmitBoolean = true; - } - - if (allowRichEditor != null && allowRichEditor.equalsIgnoreCase("true")) { - allowRichEditorBoolean = true; - } - - if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("true")) { - useSelectLeaderToolOuputBoolean = true; - } - - if (reflect != null && reflect.equalsIgnoreCase("1")) { - reflectBoolean = true; - } long userId = 0; if (toolUser != null) { userId = toolUser.getUserID().longValue(); @@ -508,724 +221,401 @@ userId = 0; } } - - boolean newContent = false; - if (qaContent == null) { - qaContent = new QaContent(); - newContent = true; + qaPO.setCreatedBy(userId); + qaService.saveOrUpdateQaContent(qaPO); + + // ************************* Handle Q&A conditions ******************* + Set newItems = getQuestions(sessionMap); + SortedSet conditions = getConditions(sessionMap); + for (QaCondition condition : conditions) { + condition.setQuestions(new TreeSet<>(new QaQuestionComparator())); + for (QaQueContent qaQuestion : condition.temporaryQaQuestions) { + //TODO check how conditions get saved + + for (QaQueContent question : newItems) { + if (qaQuestion.getDisplayOrder() == question.getDisplayOrder()) { + condition.getQuestions().add(question); + } + } + } } - - qaContent.setQaContentId(toolContentId); - qaContent.setTitle(richTextTitle); - qaContent.setInstructions(richTextInstructions); - qaContent.setUpdateDate(new Date(System.currentTimeMillis())); - /** keep updating this one */ - qaContent.setCreatedBy(userId); - /** make sure we are setting the userId from the User object above */ - - qaContent.setUsernameVisible(usernameVisibleBoolean); - qaContent.setAllowRateAnswers(allowRateQuestionsBoolean); - qaContent.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmitBoolean); - qaContent.setShowOtherAnswers(showOtherAnswersBoolean); - qaContent.setQuestionsSequenced(questionsSequencedBoolean); - qaContent.setLockWhenFinished(lockWhenFinishedBoolean); - qaContent.setNoReeditAllowed(noReeditAllowedBoolean); - qaContent.setReflect(reflectBoolean); - qaContent.setReflectionSubject(reflectionSubject); - qaContent.setAllowRichEditor(allowRichEditorBoolean); - qaContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean); - qaContent.setMinimumRates(minimumRates); - qaContent.setMaximumRates(maximumRates); - - qaContent.setConditions(new TreeSet(new TextSearchConditionComparator())); - if (newContent) { - qaService.createQaContent(qaContent); - } else { - qaService.updateQaContent(qaContent); + qaPO.setConditions(conditions); + + // ************************* Handle Q&A questions ******************* + Set items = new LinkedHashSet<>(); + Iterator iter = newItems.iterator(); + int displayOrder = 1; + while (iter.hasNext()) { + QaQueContent question = iter.next(); + if (question != null) { + question.setQaContent(qaPO); + question.setToolContentId(qaPO.getQaContentId()); + question.setDisplayOrder(displayOrder++); + qaService.saveOrUpdate(question); + items.add(question); + } } + qaPO.setQaQueContents(items); + + qaService.saveOrUpdateQaContent(qaPO); - qaContent = qaService.getQaContent(toolContentId); + // ************************* Handle rating criterias ******************* + List oldCriterias = (List) sessionMap.get(AttributeNames.ATTR_RATING_CRITERIAS); + qaService.saveRatingCriterias(request, oldCriterias, toolContentID); - // persist questions - int displayOrder = 0; - for (QaQuestionDTO questionDTO : questionDTOs) { - - String questionText = questionDTO.getQuestion(); - - // skip empty questions - if (questionText.isEmpty()) { - continue; + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + request.setAttribute(CommonConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // remove deleted questions + List deletedQuestions = getDeletedQuestions(sessionMap); + for (QaQueContent deletedQuestion : deletedQuestions) { + QaQueContent removeableQuestion = qaService.getQuestionByUid(deletedQuestion.getUid()); + if (removeableQuestion != null) { + qaService.removeQuestion(removeableQuestion); } - - ++displayOrder; - - QaQueContent question = qaService.getQuestionByUid(questionDTO.getUid()); - - // in case question doesn't exist - if (question == null) { - QbQuestion qbQuestion = new QbQuestion(); - qbQuestion.setType(QbQuestion.TYPE_ESSAY); - qbQuestion.setQuestionId(qbService.generateNextQuestionId()); - qbQuestion.setVersion(1); - - qbQuestion.setName(questionText); - qbQuestion.setFeedback(questionDTO.getFeedback()); - qbQuestion.setAnswerRequired(questionDTO.isRequired()); - qbQuestion.setMinWordsLimit(questionDTO.getMinWordsLimit()); - - qaService.saveOrUpdate(qbQuestion); - - question = new QaQueContent(qbQuestion, displayOrder, qaContent); - qaContent.getQaQueContents().add(question); - question.setQaContent(qaContent); - - // in case question exists already - } else { - QbQuestion qbQuestion = question.getQbQuestion(); - qbQuestion.setName(questionText); - qbQuestion.setFeedback(questionDTO.getFeedback()); - qbQuestion.setAnswerRequired(questionDTO.isRequired()); - qbQuestion.setMinWordsLimit(questionDTO.getMinWordsLimit()); - } - - qaService.saveOrUpdate(question); } - for (QaCondition condition : conditions) { - condition.setQuestions(new TreeSet<>(new QaQueContentComparator())); - for (QaQuestionDTO dto : condition.temporaryQuestionDTOSet) { - for (QaQueContent queContent : qaContent.getQaQueContents()) { - if (dto.getDisplayOrder().equals(String.valueOf(queContent.getDisplayOrder()))) { - condition.getQuestions().add(queContent); - } - } - } + // delete conditions from database + List delConditionList = QaAuthoringConditionController.getDeletedQaConditionList(sessionMap); + Iterator delIter = delConditionList.iterator(); + while (delIter.hasNext()) { + QaCondition condition = delIter.next(); + delIter.remove(); + qaService.deleteCondition(condition); } - qaContent.setConditions(conditions); - qaService.updateQaContent(qaContent); - return qaContent; + form.resetUserAction(); + return "authoring/AuthoringTabsHolder"; } /** * Adds QbQuestion, selected in the question bank, to the current question list. */ - @SuppressWarnings("unchecked") @RequestMapping(value = "/importQbQuestion", method = RequestMethod.POST) - private String importQbQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm authoringForm, - HttpServletRequest request, @RequestParam String httpSessionID, @RequestParam Long qbQuestionUid) { - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + private String importQbQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm form, HttpServletRequest request, + @RequestParam String sessionMapID, @RequestParam Long qbQuestionUid) { + SessionMap sessionMap = getSessionMap(form, request); + SortedSet qaQuestions = getQuestions(sessionMap); //get QbQuestion from DB QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid); - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, qbQuestion.getName()); - if (!duplicates) { - String displayOrder = String.valueOf(questionDTOs.size() + 1); - boolean requiredBoolean = false; - int minWordsLimit = 0; - QaQuestionDTO qaQuestionDTO = new QaQuestionDTO(qbQuestion.getName(), displayOrder, - qbQuestion.getFeedback(), requiredBoolean, minWordsLimit); - questionDTOs.add(qaQuestionDTO); - } else { - //entry duplicate, not adding + //create new ScratchieItem and assign imported qbQuestion to it + QaQueContent item = new QaQueContent(); + item.setQbQuestion(qbQuestion); + int maxSeq = 1; + if (qaQuestions != null && qaQuestions.size() > 0) { + QaQueContent last = qaQuestions.last(); + maxSeq = last.getDisplayOrder() + 1; } + item.setDisplayOrder(maxSeq); + qaQuestions.add(item); - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); - String toolContentID = (String) sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID); - authoringForm.setContentFolderID(contentFolderID); - authoringForm.setHttpSessionID(httpSessionID); - authoringForm.setToolContentID(toolContentID); - request.setAttribute("authoringForm", authoringForm); return "authoring/itemlist"; } /** - * saveSingleQuestion + * saveQuestion */ - @RequestMapping("/saveSingleQuestion") - public String saveSingleQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, - HttpServletRequest request) throws IOException, ServletException { + @RequestMapping("/saveQuestion") + public String saveQuestion(@ModelAttribute("newQuestionForm") QbQuestionForm form, HttpServletRequest request) + throws IOException, ServletException { + SessionMap sessionMap = getSessionMap(form, request); + SortedSet qaQuestions = getQuestions(sessionMap); + int itemIdx = NumberUtils.toInt(form.getItemIndex(), -1); - String httpSessionID = newQuestionForm.getHttpSessionID(); + // check whether it is "edit(old Question)" or "add(new Question)" + QbQuestion qbQuestion; + QaQueContent qaQuestion; + final boolean isAddingQuestion = itemIdx == -1; + if (isAddingQuestion) { // add - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + String title = form.getTitle(); + boolean duplicates = checkDuplicateQuestions(qaQuestions, title); + if (duplicates) { + return "authoring/itemlist"; + } - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - newQuestionForm.setContentFolderID(contentFolderID); + qbQuestion = new QbQuestion(); + qbQuestion.setType(QbQuestion.TYPE_ESSAY); - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - String editQuestionBoxRequest = request.getParameter("editQuestionBoxRequest"); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - String newQuestion = request.getParameter("newQuestion"); - - String feedback = request.getParameter("feedback"); - - String editableQuestionIndex = request.getParameter("editableQuestionIndex"); - - boolean requiredBoolean = newQuestionForm.isRequired(); - - int minWordsLimit = WebUtil.readIntParam(request, "minWordsLimit"); - - if (newQuestion != null && newQuestion.length() > 0) { - if (editQuestionBoxRequest != null && editQuestionBoxRequest.equals("false")) { - //request for add and save - boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, newQuestion); - - if (!duplicates) { - QaQuestionDTO qaQuestionDTO = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - qaQuestionDTO = iter.next(); - - String displayOrder = qaQuestionDTO.getDisplayOrder(); - if (displayOrder != null && !displayOrder.equals("")) { - if (displayOrder.equals(editableQuestionIndex)) { - break; - } - - } - } - - qaQuestionDTO.setQuestion(newQuestion); - qaQuestionDTO.setFeedback(feedback); - qaQuestionDTO.setDisplayOrder(editableQuestionIndex); - qaQuestionDTO.setRequired(requiredBoolean); - qaQuestionDTO.setMinWordsLimit(minWordsLimit); - - questionDTOs = AuthoringUtil.reorderUpdateQuestionDTOs(questionDTOs, qaQuestionDTO, - editableQuestionIndex); - } else { - //duplicate question entry, not adding - } - } else { - //request for edit and save - QaQuestionDTO qaQuestionDTO = null; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - qaQuestionDTO = iter.next(); - - String displayOrder = qaQuestionDTO.getDisplayOrder(); - - if (displayOrder != null && !displayOrder.equals("")) { - if (displayOrder.equals(editableQuestionIndex)) { - break; - } - - } - } - - qaQuestionDTO.setQuestion(newQuestion); - qaQuestionDTO.setFeedback(feedback); - qaQuestionDTO.setDisplayOrder(editableQuestionIndex); - qaQuestionDTO.setRequired(requiredBoolean); - qaQuestionDTO.setMinWordsLimit(minWordsLimit); - - questionDTOs = AuthoringUtil.reorderUpdateQuestionDTOs(questionDTOs, qaQuestionDTO, - editableQuestionIndex); + qaQuestion = new QaQueContent(); + int maxSeq = 1; + if (qaQuestions != null && qaQuestions.size() > 0) { + QaQueContent last = qaQuestions.last(); + maxSeq = last.getDisplayOrder() + 1; } + qaQuestion.setDisplayOrder(maxSeq); + qaQuestions.add(qaQuestion); + + // edit } else { - //entry blank, not adding + List rList = new ArrayList<>(qaQuestions); + qaQuestion = rList.get(itemIdx); + qbQuestion = qbService.getQuestionByUid(qaQuestion.getQbQuestion().getUid()); + qbService.releaseFromCache(qbQuestion); } - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); + QbQuestion oldQbQuestion = qbQuestion.clone(); + // evict everything manually as we do not use DTOs, just real entities + // without eviction changes would be saved immediately into DB + qaService.releaseFromCache(oldQbQuestion); - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); + qbQuestion.setName(form.getTitle()); + qbQuestion.setDescription(form.getDescription()); + qbQuestion.setAnswerRequired(form.isAnswerRequired()); + qbQuestion.setMinWordsLimit(form.getMinWordsLimit()); + qbQuestion.setFeedback(form.getFeedback()); - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - newQuestionForm.setToolContentID(strToolContentID); - newQuestionForm.setHttpSessionID(httpSessionID); - newQuestionForm.setCurrentTab("1"); - - request.getSession().setAttribute(httpSessionID, sessionMap); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - - return "authoring/AuthoringTabsHolder"; - } - - /** - * addSingleQuestion - */ - @RequestMapping("/addSingleQuestion") - public String addSingleQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, - HttpServletRequest request) throws IOException, ServletException { - - String httpSessionID = newQuestionForm.getHttpSessionID(); - - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - newQuestionForm.setContentFolderID(contentFolderID); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - String newQuestion = request.getParameter("newQuestion"); - String feedback = request.getParameter("feedback"); - boolean requiredBoolean = newQuestionForm.isRequired(); - int minWordsLimit = WebUtil.readIntParam(request, "minWordsLimit"); - - int listSize = questionDTOs.size(); - - if (newQuestion != null && newQuestion.length() > 0) { - boolean duplicates = AuthoringUtil.checkDuplicateQuestions(questionDTOs, newQuestion); - - if (!duplicates) { - QaQuestionDTO qaQuestionDTO = new QaQuestionDTO(newQuestion, new Long(listSize + 1).toString(), - feedback, requiredBoolean, minWordsLimit); - questionDTOs.add(qaQuestionDTO); - } else { - //entry duplicate, not adding + int isQbQuestionModified = qbQuestion.isQbQuestionModified(oldQbQuestion); + QbQuestion updatedQuestion = null; + switch (isQbQuestionModified) { + case IQbService.QUESTION_MODIFIED_VERSION_BUMP: { + // impossible scenario as long as ESSAY question type can't have version + throw new RuntimeException("Impossible scenario as long as ESSAY question type can't have version"); } - } else { - //entry blank, not adding + case IQbService.QUESTION_MODIFIED_ID_BUMP: { + // new question gets created + updatedQuestion = qbQuestion.clone(); + updatedQuestion.clearID(); + updatedQuestion.setQuestionId(qbService.generateNextQuestionId()); + updatedQuestion.setVersion(1); + updatedQuestion.setCreateDate(new Date()); + } + break; + case IQbService.QUESTION_MODIFIED_NONE: { + // save the old question anyway, as it may contain some minor changes (like title or description change) + updatedQuestion = qbQuestion; + } + break; } + userManagementService.save(updatedQuestion); + qaQuestion.setQbQuestion(updatedQuestion); + request.setAttribute("qbQuestionModified", isQbQuestionModified); - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); + //take care about question's collections. add to collection first + Long oldCollectionUid = form.getOldCollectionUid(); + Long newCollectionUid = form.getNewCollectionUid(); + if (isAddingQuestion || !newCollectionUid.equals(oldCollectionUid)) { + qbService.addQuestionToCollection(newCollectionUid, updatedQuestion.getQuestionId(), false); + } + //remove from the old collection, if needed + if (!isAddingQuestion && !newCollectionUid.equals(oldCollectionUid)) { + qbService.removeQuestionFromCollectionByQuestionId(oldCollectionUid, updatedQuestion.getQuestionId(), + false); + } - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - newQuestionForm.setToolContentID(strToolContentID); - newQuestionForm.setHttpSessionID(httpSessionID); - newQuestionForm.setCurrentTab("1"); - - request.getSession().setAttribute(httpSessionID, sessionMap); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - return "authoring/AuthoringTabsHolder"; + return "authoring/itemlist"; } - + /** - * opens up an new screen within the current page for adding a new question + * Ajax call, will add one more input line for new resource item instruction. */ @RequestMapping("/newQuestionBox") - public String newQuestionBox(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, - HttpServletRequest request) throws IOException, ServletException { + private String newQuestionBox(@ModelAttribute("newQuestionForm") QbQuestionForm form, HttpServletRequest request, + @RequestParam String sessionMapID, @RequestParam String contentFolderID) { + form.setSessionMapID(sessionMapID); + form.setContentFolderID(contentFolderID); + + QbUtils.fillFormWithUserCollections(qbService, form, null); - String httpSessionID = newQuestionForm.getHttpSessionID(); - - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - - newQuestionForm.setContentFolderID(contentFolderID); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - Collection questionDTOs = (Collection) sessionMap - .get(QaAppConstants.LIST_QUESTION_DTOS); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); return "authoring/newQuestionBox"; } /** - * opens up an new screen within the current page for editing a question + * Display edit page for existed scratchie item. */ @RequestMapping("/newEditableQuestionBox") - public String newEditableQuestionBox(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, - HttpServletRequest request) throws IOException, ServletException { - - String httpSessionID = newQuestionForm.getHttpSessionID(); - + private String newEditableQuestionBox(@ModelAttribute("newQuestionForm") QbQuestionForm form, + HttpServletRequest request, @RequestParam String sessionMapID, @RequestParam Integer questionIndex) { + // get back sessionMAP SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); + String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); + Set qaQuestions = getQuestions(sessionMap); + + List rList = new ArrayList<>(qaQuestions); + QaQueContent qaQuestion = rList.get(questionIndex); + QbQuestion qbQuestion = qaQuestion.getQbQuestion(); - String questionIndex = request.getParameter("questionIndex"); - - newQuestionForm.setEditableQuestionIndex(questionIndex); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - String editableQuestion = ""; - String editableFeedback = ""; - boolean requiredBoolean = false; - int minWordsLimit = 0; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - QaQuestionDTO qaQuestionDTO = iter.next(); - String displayOrder = qaQuestionDTO.getDisplayOrder(); - - if (displayOrder != null && !displayOrder.equals("")) { - if (displayOrder.equals(questionIndex)) { - editableFeedback = qaQuestionDTO.getFeedback(); - editableQuestion = qaQuestionDTO.getQuestion(); - requiredBoolean = qaQuestionDTO.isRequired(); - minWordsLimit = qaQuestionDTO.getMinWordsLimit(); - break; - } - - } + form.setTitle(qbQuestion.getName()); + form.setDescription(qbQuestion.getDescription()); + if (questionIndex >= 0) { + form.setItemIndex(String.valueOf(questionIndex)); } + form.setAnswerRequired(qbQuestion.isAnswerRequired()); + form.setMinWordsLimit(qbQuestion.getMinWordsLimit()); + form.setFeedback(qbQuestion.getFeedback()); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - newQuestionForm.setContentFolderID(contentFolderID); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - newQuestionForm.setRequired(requiredBoolean); - newQuestionForm.setMinWordsLimit(minWordsLimit); - newQuestionForm.setEditableQuestionText(editableQuestion); - newQuestionForm.setFeedback(editableFeedback); - - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - + form.setContentFolderID(contentFolderID); + form.setSessionMapID(sessionMapID); + QbUtils.fillFormWithUserCollections(qbService, form, qbQuestion.getUid()); + + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); return "authoring/newQuestionBox"; } /** * removes a question from the questions map */ @RequestMapping("/removeQuestion") - public String removeQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, - HttpServletRequest request) throws IOException, ServletException { + public String removeQuestion(@ModelAttribute("newQuestionForm") QaAuthoringForm form, HttpServletRequest request) + throws IOException, ServletException { + SessionMap sessionMap = getSessionMap(form, request); + int questionIndex = NumberUtils.toInt(request.getParameter("questionIndex"), -1); + Set qaQuestions = getQuestions(sessionMap); + + if (questionIndex != -1) { + List rList = new ArrayList<>(qaQuestions); + QaQueContent questionToDelete = rList.remove(questionIndex); + qaQuestions.clear(); + qaQuestions.addAll(rList); - String httpSessionID = newQuestionForm.getHttpSessionID(); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); - - String questionIndexToDelete = request.getParameter("questionIndex"); - QaQuestionDTO questionToDelete = null; - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - List listFinalQuestionDTO = new LinkedList<>(); - int queIndex = 0; - for (QaQuestionDTO questionDTO : questionDTOs) { - - String questionText = questionDTO.getQuestion(); - String displayOrder = questionDTO.getDisplayOrder(); - - if (questionText != null && !questionText.equals("") && (!displayOrder.equals(questionIndexToDelete))) { - - ++queIndex; - questionDTO.setDisplayOrder(new Integer(queIndex).toString()); - listFinalQuestionDTO.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); - questionToDelete = questionDTO; - } - } - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, listFinalQuestionDTO); - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, listFinalQuestionDTO); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(listFinalQuestionDTO.size())); - - SortedSet conditions = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); - Iterator conditionIter = conditions.iterator(); - while (conditionIter.hasNext()) { - QaCondition condition = conditionIter.next(); - Iterator dtoIter = condition.temporaryQuestionDTOSet.iterator(); - while (dtoIter.hasNext()) { - if (dtoIter.next() == questionToDelete) { - dtoIter.remove(); + // add to delList + List delList = getDeletedQuestions(sessionMap); + delList.add(questionToDelete); + + //take care about conditions + SortedSet conditions = getConditions(sessionMap); + Iterator conditionIter = conditions.iterator(); + while (conditionIter.hasNext()) { + QaCondition condition = conditionIter.next(); + Iterator questionToDeleteIter = condition.temporaryQaQuestions.iterator(); + while (questionToDeleteIter.hasNext()) { + if (questionToDeleteIter.next() == questionToDelete) { + questionToDeleteIter.remove(); + } } + if (condition.temporaryQaQuestions.isEmpty()) { + conditionIter.remove(); + } } - if (condition.temporaryQuestionDTOSet.isEmpty()) { - conditionIter.remove(); - } } - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - newQuestionForm.setContentFolderID(contentFolderID); - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - request.getSession().setAttribute(httpSessionID, sessionMap); - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - newQuestionForm.setToolContentID(strToolContentID); - newQuestionForm.setHttpSessionID(httpSessionID); - newQuestionForm.setCurrentTab("1"); - request.setAttribute("authoringForm", newQuestionForm); - - return "authoring/AuthoringTabsHolder"; + return "authoring/itemlist"; } /** * moves a question down in the list */ @RequestMapping("/moveQuestionDown") - public String moveQuestionDown(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, + public String moveQuestionDown(@ModelAttribute("newQuestionForm") QaAuthoringForm form, HttpServletRequest request) throws IOException, ServletException { + swapQuestions(form, request, "down"); - String httpSessionID = newQuestionForm.getHttpSessionID(); - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); - - String questionIndex = request.getParameter("questionIndex"); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - SortedSet conditionSet = (SortedSet) sessionMap - .get(QaAppConstants.ATTR_CONDITION_SET); - - questionDTOs = QaAuthoringController.swapQuestions(questionDTOs, questionIndex, "down", conditionSet); - - questionDTOs = QaAuthoringController.reorderQuestionDTOs(questionDTOs); - - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - newQuestionForm.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - newQuestionForm.setToolContentID(strToolContentID); - newQuestionForm.setHttpSessionID(httpSessionID); - newQuestionForm.setCurrentTab("1"); - - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - return "authoring/AuthoringTabsHolder"; + return "authoring/itemlist"; } /** * moves a question up in the list */ @RequestMapping("/moveQuestionUp") - public String moveQuestionUp(@ModelAttribute("newQuestionForm") QaAuthoringForm newQuestionForm, + public String moveQuestionUp(@ModelAttribute("newQuestionForm") QaAuthoringForm form, HttpServletRequest request) throws IOException, ServletException { + swapQuestions(form, request, "up"); - String httpSessionID = newQuestionForm.getHttpSessionID(); - - SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); - - String questionIndex = request.getParameter("questionIndex"); - - List questionDTOs = (List) sessionMap.get(QaAppConstants.LIST_QUESTION_DTOS); - - SortedSet conditionSet = (SortedSet) sessionMap - .get(QaAppConstants.ATTR_CONDITION_SET); - questionDTOs = QaAuthoringController.swapQuestions(questionDTOs, questionIndex, "up", conditionSet); - - questionDTOs = QaAuthoringController.reorderQuestionDTOs(questionDTOs); - - sessionMap.put(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - - newQuestionForm.setContentFolderID(contentFolderID); - - String richTextTitle = request.getParameter(QaAppConstants.TITLE); - - String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS); - - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, richTextTitle); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - - String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - - newQuestionForm.setTitle(richTextTitle); - newQuestionForm.setInstructions(richTextInstructions); - - request.getSession().setAttribute(httpSessionID, sessionMap); - - QaUtils.setFormProperties(request, newQuestionForm, strToolContentID, httpSessionID); - - newQuestionForm.setToolContentID(strToolContentID); - newQuestionForm.setHttpSessionID(httpSessionID); - newQuestionForm.setCurrentTab("1"); - - request.setAttribute(QaAppConstants.LIST_QUESTION_DTOS, questionDTOs); - - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - request.setAttribute("authoringForm", newQuestionForm); - return "authoring/AuthoringTabsHolder"; + return "authoring/itemlist"; } - private static List swapQuestions(List questionDTOs, String questionIndex, - String direction, Set conditions) { + private Set swapQuestions(QaAuthoringForm form, HttpServletRequest request, String direction) { + SessionMap sessionMap = getSessionMap(form, request); + Set questions = getQuestions(sessionMap); + SortedSet conditions = getConditions(sessionMap); + int originalQuestionIndex = WebUtil.readIntParam(request, "questionIndex"); + int replacedQuestionIndex = direction.equals("down") ? originalQuestionIndex + 1 : originalQuestionIndex - 1; - int intQuestionIndex = new Integer(questionIndex).intValue(); - int intOriginalQuestionIndex = intQuestionIndex; + List rList = new ArrayList<>(questions); + // get current and the target item, and switch their sequence + QaQueContent originalQuestion = rList.get(originalQuestionIndex); + QaQueContent replacedQuestion = rList.get(replacedQuestionIndex); + + int upSeqId = replacedQuestion.getDisplayOrder(); + replacedQuestion.setDisplayOrder(originalQuestion.getDisplayOrder()); + originalQuestion.setDisplayOrder(upSeqId); - int replacedQuestionIndex = 0; - if (direction.equals("down")) { - // direction down - replacedQuestionIndex = ++intQuestionIndex; - } else { - // direction up - replacedQuestionIndex = --intQuestionIndex; - } + // put back list, it will be sorted again + questions.clear(); + questions.addAll(rList); - QaQuestionDTO mainQuestion = QaAuthoringController.getQuestionAtDisplayOrder(questionDTOs, - intOriginalQuestionIndex); - - QaQuestionDTO replacedQuestion = QaAuthoringController.getQuestionAtDisplayOrder(questionDTOs, - replacedQuestionIndex); - - List newQuestionDtos = new LinkedList<>(); - - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - QaQuestionDTO questionDTO = iter.next(); - QaQuestionDTO tempQuestion = null; - - 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 1 - tempQuestion = mainQuestion; - } - - newQuestionDtos.add(tempQuestion); - } - // references in conditions also need to be changed if (conditions != null) { for (QaCondition condition : conditions) { - SortedSet newQuestionDTOSet = new TreeSet<>(new QaQuestionContentDTOComparator()); - for (QaQuestionDTO dto : newQuestionDtos) { - if (condition.temporaryQuestionDTOSet.contains(dto)) { - newQuestionDTOSet.add(dto); + SortedSet newQuestionSet = new TreeSet<>(new QaQuestionComparator()); + for (QaQueContent question : questions) { + if (condition.temporaryQaQuestions.contains(question)) { + newQuestionSet.add(question); } } - condition.temporaryQuestionDTOSet = newQuestionDTOSet; + condition.temporaryQaQuestions = newQuestionSet; } } - - return newQuestionDtos; + + return questions; } - private static QaQuestionDTO getQuestionAtDisplayOrder(List questionDTOs, - int intOriginalQuestionIndex) { - - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - QaQuestionDTO qaQuestionDTO = iter.next(); - if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionDTO.getDisplayOrder())) { - return qaQuestionDTO; + private boolean checkDuplicateQuestions(Set questions, String newQuestion) { + for (QaQueContent qaQuestion : questions) { + if (qaQuestion.getQbQuestion().getName().equals(newQuestion)) { + return true; } } - return null; + return false; } - - private static List reorderQuestionDTOs(List questionDTOs) { - List listFinalQuestionDTO = new LinkedList<>(); - - int queIndex = 0; - Iterator iter = questionDTOs.iterator(); - while (iter.hasNext()) { - QaQuestionDTO qaQuestionDTO = iter.next(); - - String question = qaQuestionDTO.getQuestion(); - String feedback = qaQuestionDTO.getFeedback(); - boolean required = qaQuestionDTO.isRequired(); - int minWordsLimit = qaQuestionDTO.getMinWordsLimit(); - - if (question != null && !question.equals("")) { - ++queIndex; - - qaQuestionDTO.setQuestion(question); - qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString()); - qaQuestionDTO.setFeedback(feedback); - qaQuestionDTO.setRequired(required); - qaQuestionDTO.setMinWordsLimit(minWordsLimit); - - listFinalQuestionDTO.add(qaQuestionDTO); - } + + /** + * List current Q&A questions. + * + * @param request + * @return + */ + @SuppressWarnings("unchecked") + private SortedSet getQuestions(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.LIST_QUESTIONS); + if (list == null) { + list = new TreeSet<>(new QaQuestionComparator()); + sessionMap.put(QaAppConstants.LIST_QUESTIONS, list); } - return listFinalQuestionDTO; + return list; } - + /** - * Get the deleted condition list, which could be persisted or non-persisted - * items. + * List save deleted scratchie items, which could be persisted or non-persisted items. * * @param request * @return */ - private List getDeletedQaConditionList(SessionMap sessionMap) { - List list = (List) sessionMap.get(QaAppConstants.ATTR_DELETED_CONDITION_LIST); + @SuppressWarnings("unchecked") + private List getDeletedQuestions(SessionMap sessionMap) { + List list = (List) sessionMap.get(QaAppConstants.LIST_DELETED_QUESTIONS); if (list == null) { list = new ArrayList<>(); - sessionMap.put(QaAppConstants.ATTR_DELETED_CONDITION_LIST, list); + sessionMap.put(QaAppConstants.LIST_DELETED_QUESTIONS, list); } return list; } + + @SuppressWarnings("unchecked") + private SortedSet getConditions(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); + if (list == null) { + list = new TreeSet<>(new TextSearchConditionComparator()); + sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, list); + } + return list; + } + + @SuppressWarnings("unchecked") + private SessionMap getSessionMap(QaAuthoringForm form, HttpServletRequest request) { + String sessionMapID = form.getSessionMapID(); + request.setAttribute(QaAppConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return (SessionMap) request.getSession().getAttribute(sessionMapID); + } + + @SuppressWarnings("unchecked") + private SessionMap getSessionMap(QbQuestionForm form, HttpServletRequest request) { + String sessionMapID = form.getSessionMapID(); + request.setAttribute(QaAppConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return (SessionMap) request.getSession().getAttribute(sessionMapID); + } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java (.../QaLearningController.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java (.../QaLearningController.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -183,15 +183,15 @@ Map mapQuestionStrings = new TreeMap(new QaComparator()); Map mapQuestions = new TreeMap<>(); - String httpSessionID = qaLearningForm.getHttpSessionID(); - SessionMap sessionMap = httpSessionID == null ? null - : (SessionMap) request.getSession().getAttribute(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + SessionMap sessionMap = sessionMapID == null ? null + : (SessionMap) request.getSession().getAttribute(sessionMapID); if (sessionMap == null) { sessionMap = new SessionMap<>(); Map mapSequentialAnswers = new HashMap(); sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); + qaLearningForm.setSessionMapID(sessionMap.getSessionID()); sessionMap.put(AttributeNames.ATTR_LEARNER_CONTENT_FOLDER, qaService.getLearnerContentFolder(new Long(toolSessionID), user.getQueUsrId())); @@ -210,7 +210,7 @@ GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaService, qaContent); generalLearnerFlowDTO.setUserUid(user.getQueUsrId().toString()); - generalLearnerFlowDTO.setHttpSessionID(sessionMapId); + generalLearnerFlowDTO.setSessionMapID(sessionMapId); generalLearnerFlowDTO.setToolSessionID(toolSessionID); generalLearnerFlowDTO.setToolContentID(qaContent.getQaContentId().toString()); @@ -492,9 +492,9 @@ String forwardName = QaAppConstants.INDIVIDUAL_LEARNER_RESULTS; - String httpSessionID = qaLearningForm.getHttpSessionID(); + String sessionMapID = qaLearningForm.getSessionMapID(); SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); MultiValueMap errorMap = new LinkedMultiValueMap<>(); /* if the listing mode is QUESTION_LISTING_MODE_COMBINED populate the answers here */ @@ -550,9 +550,9 @@ sessionMap.put(QaAppConstants.MAP_ALL_RESULTS_KEY, mapAnswers); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); + qaLearningForm.setSessionMapID(sessionMap.getSessionID()); qaLearningForm.resetAll(); - generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setSessionMapID(sessionMap.getSessionID()); boolean lockWhenFinished = qaContent.isLockWhenFinished(); generalLearnerFlowDTO.setLockWhenFinished(new Boolean(lockWhenFinished).toString()); @@ -659,13 +659,13 @@ qaLearningForm.setCurrentQuestionIndex(new Integer(1).toString()); - String httpSessionID = qaLearningForm.getHttpSessionID(); + String sessionMapID = qaLearningForm.getSessionMapID(); SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); - generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + qaLearningForm.setSessionMapID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setSessionMapID(sessionMap.getSessionID()); generalLearnerFlowDTO.setToolContentID(qaContent.getQaContentId().toString()); // create mapQuestions @@ -716,11 +716,11 @@ if (qaContent.isShowOtherAnswers()) { GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaService, qaContent); - String httpSessionID = qaLearningForm.getHttpSessionID(); - generalLearnerFlowDTO.setHttpSessionID(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + generalLearnerFlowDTO.setSessionMapID(sessionMapID); /** Set up the data for the view all answers screen */ - QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, httpSessionID, user, + QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapID, user, generalLearnerFlowDTO); generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); @@ -789,17 +789,17 @@ GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaService, qaContent); - String httpSessionID = qaLearningForm.getHttpSessionID(); - qaLearningForm.setHttpSessionID(httpSessionID); - generalLearnerFlowDTO.setHttpSessionID(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + qaLearningForm.setSessionMapID(sessionMapID); + generalLearnerFlowDTO.setSessionMapID(sessionMapID); SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); /* recreate the users and responses */ qaLearningForm.resetUserActions(); qaLearningForm.setSubmitAnswersContent(null); - QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, httpSessionID, user, + QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapID, user, generalLearnerFlowDTO); generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); @@ -857,8 +857,8 @@ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); qaLearningForm.setToolSessionID(toolSessionID); - String httpSessionID = qaLearningForm.getHttpSessionID(); - qaLearningForm.setHttpSessionID(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + qaLearningForm.setSessionMapID(sessionMapID); QaSession qaSession = qaService.getSessionById(new Long(toolSessionID).longValue()); QaContent qaContent = qaSession.getQaContent(); @@ -894,9 +894,9 @@ */ private Object[] storeSequentialAnswer(QaLearningForm qaLearningForm, HttpServletRequest request, GeneralLearnerFlowDTO generalLearnerFlowDTO, boolean getNextQuestion) { - String httpSessionID = qaLearningForm.getHttpSessionID(); + String sessionMapID = qaLearningForm.getSessionMapID(); SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); String currentQuestionIndex = qaLearningForm.getCurrentQuestionIndex(); @@ -959,8 +959,8 @@ sessionMap.put(QaAppConstants.MAP_ALL_RESULTS_KEY, mapAnswers); sessionMap.put(QaAppConstants.MAP_SEQUENTIAL_ANSWERS_KEY, mapSequentialAnswers); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - qaLearningForm.setHttpSessionID(sessionMap.getSessionID()); - generalLearnerFlowDTO.setHttpSessionID(sessionMap.getSessionID()); + qaLearningForm.setSessionMapID(sessionMap.getSessionID()); + generalLearnerFlowDTO.setSessionMapID(sessionMap.getSessionID()); request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); @@ -1018,8 +1018,8 @@ LearningUtil.saveFormRequestData(request, qaLearningForm); - String httpSessionID = qaLearningForm.getHttpSessionID(); - qaLearningForm.setHttpSessionID(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + qaLearningForm.setSessionMapID(sessionMapID); String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); qaLearningForm.setToolSessionID(toolSessionID); QaSession qaSession = qaService.getSessionById(new Long(toolSessionID).longValue()); @@ -1082,9 +1082,9 @@ qaSession.setSession_status(QaAppConstants.COMPLETED); qaService.updateSession(qaSession); - String httpSessionID = qaLearningForm.getHttpSessionID(); - // request.getSession().removeAttribute(httpSessionID); - qaLearningForm.setHttpSessionID(httpSessionID); + String sessionMapID = qaLearningForm.getSessionMapID(); + // request.getSession().removeAttribute(sessionMapID); + qaLearningForm.setSessionMapID(sessionMapID); qaLearningForm.resetAll(); @@ -1112,9 +1112,9 @@ LearningUtil.saveFormRequestData(request, qaLearningForm); - String httpSessionID = qaLearningForm.getHttpSessionID(); + String sessionMapID = qaLearningForm.getSessionMapID(); - qaLearningForm.setHttpSessionID(httpSessionID); + qaLearningForm.setSessionMapID(sessionMapID); String toolSessionIDString = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); qaLearningForm.setToolSessionID(toolSessionIDString); @@ -1159,9 +1159,9 @@ public String forwardtoReflection(@ModelAttribute("qaLearningForm") QaLearningForm qaLearningForm, HttpServletRequest request) throws IOException, ServletException, ToolException { - String httpSessionID = qaLearningForm.getHttpSessionID(); + String sessionMapID = qaLearningForm.getSessionMapID(); - qaLearningForm.setHttpSessionID(httpSessionID); + qaLearningForm.setSessionMapID(sessionMapID); String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -1209,10 +1209,10 @@ * data being analysed is the current user. */ public static void refreshSummaryData(HttpServletRequest request, QaContent qaContent, QaSession qaSession, - IQaService qaService, String httpSessionID, QaQueUsr user, GeneralLearnerFlowDTO generalLearnerFlowDTO) { + IQaService qaService, String sessionMapID, QaQueUsr user, GeneralLearnerFlowDTO generalLearnerFlowDTO) { SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(httpSessionID); + .getAttribute(sessionMapID); Long userId = user.getQueUsrId(); Set questions = qaContent.getQaQueContents(); generalLearnerFlowDTO.setQuestions(questions); @@ -1349,8 +1349,7 @@ ObjectNode responcedata = JsonNodeFactory.instance.objectNode(); ArrayNode rows = JsonNodeFactory.instance.arrayNode(); - responcedata.put("total_rows", qaService.getCountResponsesBySessionAndQuestion(qaSessionId, questionUid, userId, - isOnlyLeadersIncluded, searchString)); + responcedata.put("total_rows", 1); // handle rating criterias - even though we may have searched on ratings earlier we can't use the average ratings // calculated as they may have been averages over more than one criteria. Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaMonitoringController.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaMonitoringController.java (.../QaMonitoringController.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaMonitoringController.java (.../QaMonitoringController.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -111,23 +111,21 @@ throw new ServletException("Data not initialised in Monitoring"); } - qaMonitoringForm.setCurrentTab("1"); - /* this section is related to summary tab. Starts here. */ // SessionMap sessionMap = new SessionMap(); // sessionMap.put(ACTIVITY_TITLE_KEY, qaContent.getTitle()); // sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); // -// qaMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); +// qaMonitoringForm.setSessionMapID(sessionMap.getSessionID()); // request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - List questionDTOs = new LinkedList(); + List questionDTOs = new LinkedList<>(); for (QaQueContent question : qaContent.getQaQueContents()) { QaQuestionDTO questionDTO = new QaQuestionDTO(question); questionDTOs.add(questionDTO); } - request.setAttribute(LIST_QUESTION_DTOS, questionDTOs); -// sessionMap.put(LIST_QUESTION_DTOS, questionDTOs); + request.setAttribute(LIST_QUESTIONS, questionDTOs); +// sessionMap.put(LIST_QUESTIONS, questionDTOs); // request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); //session dto list @@ -208,21 +206,18 @@ Long responseUid = WebUtil.readLongParam(request, QaAppConstants.RESPONSE_UID); String updatedResponse = request.getParameter("updatedResponse"); - QaUsrResp qaUsrResp = qaService.getResponseById(responseUid); + QaUsrResp userResponse = qaService.getResponseById(responseUid); /* * write out the audit log entry. If you move this after the update of the response, then make sure you update * the audit call to use a copy of the original answer */ - Long toolContentId = null; - if (qaUsrResp.getQaQuestion() != null && qaUsrResp.getQaQuestion().getQaContent() != null) { - toolContentId = qaUsrResp.getQaQuestion().getQaContent().getQaContentId(); - } - qaService.getLogEventService().logChangeLearnerContent(qaUsrResp.getQaQueUser().getQueUsrId(), - qaUsrResp.getQaQueUser().getUsername(), toolContentId, qaUsrResp.getAnswer(), updatedResponse); + Long toolContentId = userResponse.getQaQueUser().getQaSession().getQaContent().getQaContentId(); + qaService.getLogEventService().logChangeLearnerContent(userResponse.getQaQueUser().getQueUsrId(), + userResponse.getQaQueUser().getUsername(), toolContentId, userResponse.getAnswer(), updatedResponse); - qaUsrResp.setAnswer(updatedResponse); - qaService.updateUserResponse(qaUsrResp); + userResponse.setAnswer(updatedResponse); + qaService.updateUserResponse(userResponse); return null; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaPedagogicalPlannerController.java =================================================================== diff -u -rf49dd9f6b076828f464fc954bb9c3dc0c87e8b37 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaPedagogicalPlannerController.java (.../QaPedagogicalPlannerController.java) (revision f49dd9f6b076828f464fc954bb9c3dc0c87e8b37) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaPedagogicalPlannerController.java (.../QaPedagogicalPlannerController.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -92,14 +92,15 @@ } else { QaQueContent qaQuestion = new QaQueContent(); qaQuestion.setDisplayOrder(questionIndex + 1); - qaQuestion.setQaContent(qaContent); + qaQuestion.setToolContentId(qaContent.getQaContentId()); QbQuestion qbQuestion = new QbQuestion(); qbQuestion.setAnswerRequired(false); qbQuestion.setName(question); qaService.saveOrUpdate(qbQuestion); qaQuestion.setQbQuestion(qbQuestion); + qaQuestion.setQaContent(qaContent); qaService.saveOrUpdate(qaQuestion); } questionIndex++; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java =================================================================== diff -u -r770fb82629331ca1c70c47845ab63b9528b7bc9e -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java (.../QaAuthoringForm.java) (revision 770fb82629331ca1c70c47845ab63b9528b7bc9e) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaAuthoringForm.java (.../QaAuthoringForm.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -25,27 +25,27 @@ /* ActionForm for the Authoring environment*/ import org.lamsfoundation.lams.tool.qa.QaAppConstants; -import org.lamsfoundation.lams.tool.qa.service.IQaService; +import org.lamsfoundation.lams.tool.qa.model.QaContent; /** * @author Ozgur Demirtas */ public class QaAuthoringForm extends QaLearningForm implements QaAppConstants { + + private QaContent qa; + protected String addContent; protected String removeContent; protected String removeAllContent; protected String submitAllContent; protected String submitTabDone; - protected String currentTab; protected String choice; protected String choiceBasic; protected String choiceAdvanced; protected String choiceInstructions; /* basic content */ - protected String title; - protected String instructions; protected String questionIndex; protected String isRemoveContent; @@ -54,17 +54,6 @@ protected String reportTitle; protected String monitoringReportTitle; protected String endLearningMessage; - protected String usernameVisible; - protected String allowRateAnswers; - protected String notifyTeachersOnResponseSubmit; - protected String showOtherAnswers; - protected String questionsSequenced; - protected String lockWhenFinished; - protected String noReeditAllowed; - protected String reflect; - protected String reflectionSubject; - protected int maximumRates; - protected int minimumRates; /* proxy controllers for Monitoring tabs */ protected String summaryMonitoring; @@ -74,19 +63,7 @@ protected String edit; private String contentFolderID; - private String addSingleQuestion; - private String editableQuestionIndex; - protected String editableQuestionText; - private String feedback; - private boolean required; - private int minWordsLimit; - private String editQuestionBoxRequest; - protected IQaService qaService; - - protected boolean allowRichEditor; - protected boolean useSelectLeaderToolOuput; - public void resetUserAction() { this.addContent = null; this.removeContent = null; @@ -99,57 +76,13 @@ this.editActivityMonitoring = null; this.statsMonitoring = null; this.edit = null; - this.allowRichEditor = false; - this.useSelectLeaderToolOuput = false; } - - public void reset() { - this.addContent = null; - this.removeContent = null; - this.removeAllContent = null; - this.submitAllContent = null; - this.submitTabDone = null; - - this.choice = null; - this.choiceBasic = null; - this.choiceAdvanced = null; - this.choiceInstructions = null; - - this.title = null; - this.instructions = null; - this.questionIndex = null; - this.isRemoveContent = null; - - this.endLearningMessage = null; - this.reportTitle = null; - this.monitoringReportTitle = null; - this.questionsSequenced = null; - this.lockWhenFinished = null; - this.noReeditAllowed = null; - this.reflect = null; - this.allowRichEditor = false; - this.useSelectLeaderToolOuput = false; - - this.summaryMonitoring = null; - this.instructionsMonitoring = null; - this.editActivityMonitoring = null; - this.statsMonitoring = null; - this.edit = null; - this.toolContentID = null; - this.currentTab = null; + + public QaContent getQa() { + return qa; } - - public void resetRadioBoxes() { - this.usernameVisible = OPTION_OFF; - this.allowRateAnswers = OPTION_OFF; - this.notifyTeachersOnResponseSubmit = OPTION_OFF; - this.questionsSequenced = OPTION_OFF; - this.lockWhenFinished = OPTION_OFF; - this.noReeditAllowed = OPTION_OFF; - this.reflect = OPTION_OFF; - this.allowRichEditor = false; - this.required = false; - this.useSelectLeaderToolOuput = false; + public void setQa(QaContent qa) { + this.qa = qa; } /** @@ -245,36 +178,6 @@ } /** - * @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 choiceAdvanced. */ public String getChoiceAdvanced() { @@ -350,51 +253,6 @@ } /** - * @return Returns the usernameVisible. - */ - public String getUsernameVisible() { - return usernameVisible; - } - - /** - * @param usernameVisible - * The usernameVisible to set. - */ - public void setUsernameVisible(String usernameVisible) { - this.usernameVisible = usernameVisible; - } - - /** - * @return Returns the allowRateAnswers. - */ - public String getAllowRateAnswers() { - return allowRateAnswers; - } - - /** - * @param allowRateAnswers - * The allowRateAnswers to set. - */ - public void setAllowRateAnswers(String allowRateAnswers) { - this.allowRateAnswers = allowRateAnswers; - } - - /** - * @return Returns the notifyTeachersOnResponseSubmit. - */ - public String getNotifyTeachersOnResponseSubmit() { - return notifyTeachersOnResponseSubmit; - } - - /** - * @param notifyTeachersOnResponseSubmit - * The notifyTeachersOnResponseSubmit to set. - */ - public void setNotifyTeachersOnResponseSubmit(String notifyTeachersOnResponseSubmit) { - this.notifyTeachersOnResponseSubmit = notifyTeachersOnResponseSubmit; - } - - /** * @return Returns the submitTabDone. */ public String getSubmitTabDone() { @@ -410,43 +268,6 @@ } /** - * @return Returns the questionsSequenced. - */ - public String getQuestionsSequenced() { - return questionsSequenced; - } - - /** - * @param questionsSequenced - * The questionsSequenced to set. - */ - public void setQuestionsSequenced(String questionsSequenced) { - this.questionsSequenced = questionsSequenced; - } - - /** - * @return - */ - public int getMaximumRates() { - return maximumRates; - } - - public void setMaximumRates(int maximumRates) { - this.maximumRates = maximumRates; - } - - /** - * @return - */ - public int getMinimumRates() { - return minimumRates; - } - - public void setMinimumRates(int minimumRates) { - this.minimumRates = minimumRates; - } - - /** * @return Returns the endLearningMessage. */ public String getEndLearningMessage() { @@ -567,66 +388,6 @@ } /** - * @return Returns the currentTab. - */ - public String getCurrentTab() { - return currentTab; - } - - /** - * @param currentTab - * The currentTab to set. - */ - public void setCurrentTab(String currentTab) { - this.currentTab = currentTab; - } - - /** - * @return Returns the qaService. - */ - public IQaService getQaService() { - return qaService; - } - - /** - * @param qaService - * The qaService to set. - */ - public void setQaService(IQaService qaService) { - this.qaService = qaService; - } - - /** - * @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 contentFolderID. */ public String getContentFolderID() { @@ -640,156 +401,4 @@ public void setContentFolderID(String contentFolderID) { this.contentFolderID = contentFolderID; } - - /** - * @return Returns the addSingleQuestion. - */ - public String getAddSingleQuestion() { - return addSingleQuestion; - } - - /** - * @param addSingleQuestion - * The addSingleQuestion to set. - */ - public void setAddSingleQuestion(String addSingleQuestion) { - this.addSingleQuestion = addSingleQuestion; - } - - /** - * @return Returns the editableQuestionIndex. - */ - public String getEditableQuestionIndex() { - return editableQuestionIndex; - } - - /** - * @param editableQuestionIndex - * The editableQuestionIndex to set. - */ - public void setEditableQuestionIndex(String editableQuestionIndex) { - this.editableQuestionIndex = editableQuestionIndex; - } - - /** - * @return Returns the editableQuestionText. - */ - public String getEditableQuestionText() { - return editableQuestionText; - } - - /** - * @param editableQuestionText - * The editableQuestionText to set. - */ - public void setEditableQuestionText(String editableQuestionText) { - this.editableQuestionText = editableQuestionText; - } - - /** - * @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 editQuestionBoxRequest. - */ - public String getEditQuestionBoxRequest() { - return editQuestionBoxRequest; - } - - /** - * @param editQuestionBoxRequest - * The editQuestionBoxRequest to set. - */ - public void setEditQuestionBoxRequest(String editQuestionBoxRequest) { - this.editQuestionBoxRequest = editQuestionBoxRequest; - } - - /** - * @return Returns the lockWhenFinished. - */ - public String getLockWhenFinished() { - return lockWhenFinished; - } - - /** - * @param lockWhenFinished - * The lockWhenFinished to set. - */ - public void setLockWhenFinished(String lockWhenFinished) { - this.lockWhenFinished = lockWhenFinished; - } - - /** - * @return Returns the noReeditAllowed. - */ - public String getNoReeditAllowed() { - return noReeditAllowed; - } - - /** - * @param noReeditAllowed - * The noReeditAllowed to set. - */ - public void setNoReeditAllowed(String noReeditAllowed) { - this.noReeditAllowed = noReeditAllowed; - } - - /** - * @return Returns the showOtherAnswers. - */ - public String getShowOtherAnswers() { - return showOtherAnswers; - } - - /** - * @param showOtherAnswers - * The showOtherAnswers to set. - */ - public void setShowOtherAnswers(String showOtherAnswers) { - this.showOtherAnswers = showOtherAnswers; - } - - public boolean isAllowRichEditor() { - return allowRichEditor; - } - - public void setAllowRichEditor(boolean allowRichEditor) { - this.allowRichEditor = allowRichEditor; - } - - public boolean isUseSelectLeaderToolOuput() { - return useSelectLeaderToolOuput; - } - - public void setUseSelectLeaderToolOuput(boolean useSelectLeaderToolOuput) { - this.useSelectLeaderToolOuput = useSelectLeaderToolOuput; - } - - public boolean isRequired() { - return required; - } - - public void setRequired(boolean required) { - this.required = required; - } - - public void setMinWordsLimit(int minWordsLimit) { - this.minWordsLimit = minWordsLimit; - } - - public int getMinWordsLimit() { - return minWordsLimit; - } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaConditionForm.java =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaConditionForm.java (.../QaConditionForm.java) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaConditionForm.java (.../QaConditionForm.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -24,8 +24,8 @@ import java.util.Map; -import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.model.QaCondition; +import org.lamsfoundation.lams.tool.qa.model.QaQueContent; import org.lamsfoundation.lams.web.form.TextSearchForm; /** @@ -61,10 +61,10 @@ super.populateForm(condition); setOrderId(condition.getOrderId()); setDisplayName(condition.getDisplayName()); - Integer[] selectedItems = new Integer[condition.temporaryQuestionDTOSet.size()]; + Integer[] selectedItems = new Integer[condition.temporaryQaQuestions.size()]; int questionIndex = 0; - for (QaQuestionDTO question : condition.temporaryQuestionDTOSet) { - selectedItems[questionIndex] = new Integer(question.getDisplayOrder()); + for (QaQueContent qaQuestion : condition.temporaryQaQuestions) { + selectedItems[questionIndex] = qaQuestion.getDisplayOrder(); questionIndex++; } setSelectedItems(selectedItems); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaLearningForm.java =================================================================== diff -u -r2c884ed118ba4107ff035886dee97513321183a0 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaLearningForm.java (.../QaLearningForm.java) (revision 2c884ed118ba4107ff035886dee97513321183a0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaLearningForm.java (.../QaLearningForm.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -42,7 +42,7 @@ protected String forwardtoReflection; protected String totalQuestionCount; - protected String httpSessionID; + protected String sessionMapID; protected String toolSessionID; protected String questionIndex; protected String userID; @@ -294,18 +294,18 @@ } /** - * @return Returns the httpSessionID. + * @return Returns the sessionMapID. */ - public String getHttpSessionID() { - return httpSessionID; + public String getSessionMapID() { + return sessionMapID; } /** - * @param httpSessionID - * The httpSessionID to set. + * @param sessionMapID + * The sessionMapID to set. */ - public void setHttpSessionID(String httpSessionID) { - this.httpSessionID = httpSessionID; + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; } /** Index: lams_tool_laqa/web/authoring/AdvancedContent.jsp =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_laqa/web/authoring/AdvancedContent.jsp (.../AdvancedContent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,22 +1,20 @@ <%@ include file="/common/taglibs.jsp"%> + - -
@@ -73,85 +70,83 @@
-
style="display:none;"> - -
- +
style="display:none;"> + +
-
-
- +
Index: lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp =================================================================== diff -u -r72c9800d4076fa450caff0943dd4de41399c83e0 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 72c9800d4076fa450caff0943dd4de41399c83e0) +++ lams_tool_laqa/web/authoring/AuthoringTabsHolder.jsp (.../AuthoringTabsHolder.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -20,70 +20,70 @@ - - + + + - + - - - - - - - - - - - - - - - - - - + + + + + + - - - + + + + + + + + + + + + + + + Index: lams_tool_laqa/web/authoring/BasicContent.jsp =================================================================== diff -u -ra7690b14578fa656e8782755c2f45b9ee7aa00db -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision a7690b14578fa656e8782755c2f45b9ee7aa00db) +++ lams_tool_laqa/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,6 +1,6 @@ <%@ include file="/common/taglibs.jsp"%> - - + +
- - + +
- - + +
@@ -92,9 +87,14 @@ @@ -113,5 +113,3 @@ - -
\ No newline at end of file Index: lams_tool_laqa/web/authoring/conditions.jsp =================================================================== diff -u -r658034e7f07579dd682db62112b9353b3a0d3f65 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/conditions.jsp (.../conditions.jsp) (revision 658034e7f07579dd682db62112b9353b3a0d3f65) +++ lams_tool_laqa/web/authoring/conditions.jsp (.../conditions.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -48,12 +48,12 @@
- + <%@ include file="/authoring/conditionList.jsp"%>
-  
Index: lams_tool_laqa/web/authoring/itemlist.jsp =================================================================== diff -u -ra7690b14578fa656e8782755c2f45b9ee7aa00db -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/itemlist.jsp (.../itemlist.jsp) (revision a7690b14578fa656e8782755c2f45b9ee7aa00db) +++ lams_tool_laqa/web/authoring/itemlist.jsp (.../itemlist.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,6 +1,29 @@ <%@ include file="/common/taglibs.jsp"%> - + + + +<%@ page import="org.lamsfoundation.lams.qb.service.IQbService" %> + +
@@ -9,31 +32,41 @@
- + - - + + + + + Index: lams_tool_laqa/web/authoring/newQuestionBox.jsp =================================================================== diff -u -ra7690b14578fa656e8782755c2f45b9ee7aa00db -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision a7690b14578fa656e8782755c2f45b9ee7aa00db) +++ lams_tool_laqa/web/authoring/newQuestionBox.jsp (.../newQuestionBox.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,50 +1,187 @@ + <%@ include file="/common/taglibs.jsp"%> -
-
-
-
+ + + -
- - - - - - + + + + + + - + + + + + + + + + + + + +
+
+
+ +
- - -
-
- - -
+ +
-
- - -
-
- - -
-
\ No newline at end of file + + + + + + + + + +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + +
+ + +
+
+ +
+ + +
+
+ +
+
+ +
+
+
+ + Collection + + + + + +
+
+
+ + + Index: lams_tool_laqa/web/learning/AnswersContent.jsp =================================================================== diff -u -ree24c96be656069696dc59a7831ea64120531a61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision ee24c96be656069696dc59a7831ea64120531a61) +++ lams_tool_laqa/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -4,7 +4,7 @@ - + @@ -230,7 +230,7 @@ - + Index: lams_tool_laqa/web/learning/IndividualLearnerResults.jsp =================================================================== diff -u -r3bb7e0141ae1cc15ccd737c95d90b5762a34ad61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision 3bb7e0141ae1cc15ccd737c95d90b5762a34ad61) +++ lams_tool_laqa/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,7 +1,7 @@ <%@ include file="/common/taglibs.jsp"%> - + @@ -53,7 +53,7 @@ - + Index: lams_tool_laqa/web/learning/LearnerRep.jsp =================================================================== diff -u -r3bb7e0141ae1cc15ccd737c95d90b5762a34ad61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 3bb7e0141ae1cc15ccd737c95d90b5762a34ad61) +++ lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -4,7 +4,7 @@ - + @@ -324,7 +324,7 @@
- +
@@ -375,7 +375,7 @@

${status.count}: - +

@@ -427,7 +427,7 @@ - + Index: lams_tool_laqa/web/learning/Notebook.jsp =================================================================== diff -u -r3bb7e0141ae1cc15ccd737c95d90b5762a34ad61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/Notebook.jsp (.../Notebook.jsp) (revision 3bb7e0141ae1cc15ccd737c95d90b5762a34ad61) +++ lams_tool_laqa/web/learning/Notebook.jsp (.../Notebook.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -23,7 +23,7 @@ - +

Index: lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp =================================================================== diff -u -r3bb7e0141ae1cc15ccd737c95d90b5762a34ad61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 3bb7e0141ae1cc15ccd737c95d90b5762a34ad61) +++ lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -4,7 +4,7 @@ - + @@ -306,7 +306,7 @@

- +
@@ -370,7 +370,7 @@

${status.count}: - +

@@ -468,7 +468,7 @@ - + Index: lams_tool_laqa/web/learning/submissionDeadline.jsp =================================================================== diff -u -r3bb7e0141ae1cc15ccd737c95d90b5762a34ad61 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 3bb7e0141ae1cc15ccd737c95d90b5762a34ad61) +++ lams_tool_laqa/web/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -1,6 +1,6 @@ <%@ include file="/common/taglibs.jsp"%> - + @@ -35,7 +35,7 @@ - + Index: lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp =================================================================== diff -u -r5a0c67fe7b338c1f3ad27b7e309d993feb90a0b5 -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 5a0c67fe7b338c1f3ad27b7e309d993feb90a0b5) +++ lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -3,7 +3,7 @@ <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.qa.QaAppConstants"%> - + @@ -352,7 +352,7 @@ - + Index: lams_tool_laqa/web/monitoring/SummaryContent.jsp =================================================================== diff -u -r69092337b728f903f824a74377bd0ebf9391120c -r86c25c80d92701a94c3161575c76c363891402ad --- lams_tool_laqa/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 69092337b728f903f824a74377bd0ebf9391120c) +++ lams_tool_laqa/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) @@ -48,15 +48,15 @@
- +
- - +
+ dataId="data-session-id='${groupDto.sessionId}' data-question-uid='${questionDto.uid}'">
- + + onclick="javascript:moveQuestion(${status.index},'moveQuestionUp')" /> + onclick="javascript:moveQuestion(${status.index},'moveQuestionDown') "/> " - onclick="javascript:showMessage('authoring/newEditableQuestionBox.do?questionIndex=${status.count}&contentFolderID=${authoringForm.contentFolderID}&httpSessionID=${httpSessionID}&toolContentID=${authoringForm.toolContentID}')"> - " - onclick="removeQuestion(${status.count})"> - + + ?sessionMapID=${sessionMapID}&questionIndex=${status.index}&KeepThis=true&TB_iframe=true&modal=true + + + + + + " + onclick="removeQuestion(${status.index})"> + +