Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190110.sql =================================================================== diff -u -reb5312af3f0d7ca64ca3b41988129079c7509427 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190110.sql (.../patch20190110.sql) (revision eb5312af3f0d7ca64ca3b41988129079c7509427) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190110.sql (.../patch20190110.sql) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -1,6 +1,5 @@ -- Turn off autocommit, so nothing is committed if there is an error SET AUTOCOMMIT = 0; -SET FOREIGN_KEY_CHECKS=0; ----------------------Put all sql statements below here------------------------- -- LDEV-4746 Create Question Bank table structure and migrate existing data @@ -11,6 +10,7 @@ `type` TINYINT NOT NULL, `question_id` INT NOT NULL, `version` SMALLINT NOT NULL DEFAULT 1, + `create_date` DATETIME NOT NULL DEFAULT NOW(), `name` TEXT NOT NULL, `description` TEXT, `mark` INT, @@ -24,7 +24,10 @@ -- Create a question table from which tools' questions will inherit CREATE TABLE lams_qb_tool_question (`tool_question_uid` BIGINT AUTO_INCREMENT, `qb_question_uid` BIGINT NOT NULL, + `tool_content_id` BIGINT NOT NULL, + `display_order` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (tool_question_uid), + INDEX (tool_content_id), CONSTRAINT FK_lams_qb_tool_question_1 FOREIGN KEY (qb_question_uid) REFERENCES lams_qb_question (uid) ON UPDATE CASCADE); -- create Question Bank option CREATE TABLE lams_qb_option (`uid` BIGINT AUTO_INCREMENT, @@ -59,7 +62,7 @@ CREATE TABLE tmp_question (question_uid BIGINT PRIMARY KEY, content VARCHAR(16000)) AS SELECT q.uid AS question_uid, - GROUP_CONCAT(TRIM(question), TRIM(mc_que_option_text) ORDER BY displayOrder) AS content + GROUP_CONCAT(TRIM(question), TRIM(mc_que_option_text) ORDER BY displayOrder) AS content FROM tl_lamc11_que_content AS q JOIN tl_lamc11_options_content AS o ON q.uid = o.mc_que_content_id GROUP BY q.uid; @@ -80,25 +83,34 @@ -- fill Question Bank question table with unique questions, with manually incremented question ID SET @question_id = (SELECT IF(MAX(question_id) IS NULL, 0, MAX(question_id)) FROM lams_qb_question); -INSERT INTO lams_qb_question SELECT NULL, 1, 1, @question_id:=@question_id + 1, 1, mcq.question, NULL, mcq.mark, mcq.feedback, q.target_uid +INSERT INTO lams_qb_question SELECT NULL, 1, 1, @question_id:=@question_id + 1, 1, c.creation_date, + mcq.question, NULL, mcq.mark, mcq.feedback, q.target_uid FROM (SELECT uid, TRIM(question) AS question, mark, - IF(TRIM(feedback) = '', NULL, TRIM(feedback)) AS feedback + IF(TRIM(feedback) = '', NULL, TRIM(feedback)) AS feedback, + mc_content_id FROM tl_lamc11_que_content) AS mcq JOIN (SELECT DISTINCT target_uid FROM tmp_question_match) AS q - ON mcq.uid = q.target_uid; + ON mcq.uid = q.target_uid + JOIN tl_lamc11_content AS c + ON mcq.mc_content_id = c.uid; -- set up references to QB question UIDs created above INSERT INTO lams_qb_tool_question - SELECT q.question_uid, qb.uid + SELECT q.question_uid, qb.uid, c.content_id, mcq.display_order FROM lams_qb_question AS qb JOIN tmp_question_match AS q - ON qb.tmp_question_id = q.target_uid; + ON qb.tmp_question_id = q.target_uid + JOIN tl_lamc11_que_content AS mcq + ON q.question_uid = mcq.uid + JOIN tl_lamc11_content AS c + ON mcq.mc_content_id = c.uid; -- remove columns from MCQ which are duplicated in Question Bank ALTER TABLE tl_lamc11_que_content DROP COLUMN question, DROP COLUMN mark, + DROP COLUMN display_order, DROP COLUMN feedback; -- fill table with options matching unique QB questions inserted above @@ -121,88 +133,103 @@ SELECT uid, mc_que_content_id, mc_que_option_id FROM tl_lamc11_usr_attempt; -- clean up -DROP TABLE tl_lamc11_options_content; - ALTER TABLE tl_lamc11_usr_attempt DROP FOREIGN KEY FK_tl_lamc11_usr_attempt_2, DROP FOREIGN KEY FK_tl_lamc11_usr_attempt_3, DROP COLUMN mc_que_content_id, DROP COLUMN mc_que_option_id; + +DROP TABLE tl_lamc11_options_content; - -- prepare for Scratchie migration DELETE FROM tmp_question; DELETE FROM tmp_question_match; -- shift Scratchie question UIDs by offset equal to existing UIDs of MCQ in lams_qb_tool_question SET @max_tool_question_id = (SELECT MAX(tool_question_uid) FROM lams_qb_tool_question); UPDATE tl_lascrt11_scratchie_item SET uid = uid + @max_tool_question_id ORDER BY uid DESC; -UPDATE tl_lascrt11_scratchie_answer SET scratchie_item_uid = scratchie_item_uid + @max_tool_question_id ORDER BY scratchie_item_uid DESC; +-- UPDATE tl_lascrt11_scratchie_answer SET scratchie_item_uid = scratchie_item_uid + @max_tool_question_id ORDER BY scratchie_item_uid DESC; -- create a mapping of Scratchie question UID -> its question text + all answers in a single column -- if this column is not *exactly* as in an other row, it means it should be a separate question in QB INSERT INTO tmp_question SELECT q.uid, GROUP_CONCAT(TRIM(q.title), TRIM(o.description) ORDER BY o.order_id) FROM tl_lascrt11_scratchie_item AS q - JOIN tl_lascrt11_scratchie_answer AS o ON q.uid = o.scratchie_item_uid + JOIN tl_lascrt11_scratchie_answer AS o + ON q.uid = o.scratchie_item_uid GROUP BY q.uid; -- create a similar mapping for existing questions in QB CREATE TABLE tmp_qb_question AS SELECT q.uid AS question_uid, GROUP_CONCAT(TRIM(q.name), TRIM(o.name) ORDER BY o.display_order) AS content FROM lams_qb_question AS q - JOIN lams_qb_option AS o ON q.uid = o.qb_question_uid + JOIN lams_qb_option AS o + ON q.uid = o.qb_question_uid WHERE q.type = 1 GROUP BY q.uid; -- create a mapping of Scratchie question UID -> UID of one of Scratchie questions which holds the same content INSERT INTO tmp_question_match SELECT q.question_uid, merged.question_uid FROM (SELECT * FROM tmp_question GROUP BY content) AS merged - JOIN tmp_question AS q USING (content) - LEFT JOIN tmp_qb_question AS qb USING (content) + JOIN tmp_question AS q + USING (content) + LEFT JOIN tmp_qb_question AS qb + USING (content) WHERE qb.question_uid IS NULL; -- reset column for matching QB questions with Scratchie questions UPDATE lams_qb_question SET tmp_question_id = -1; -- fill Question Bank question table with unique questions, with manually incremented question ID -INSERT INTO lams_qb_question SELECT NULL, 1, 1, @question_id:=@question_id + 1, 1, sq.question, sq.description, NULL, NULL, q.target_uid +INSERT INTO lams_qb_question SELECT NULL, 1, 1, @question_id:=@question_id + 1, 1, sq.create_date, + sq.question, sq.description, NULL, NULL, q.target_uid FROM (SELECT uid, TRIM(title) AS question, - TRIM(description) AS description + TRIM(description) AS description, + create_date FROM tl_lascrt11_scratchie_item) AS sq JOIN (SELECT DISTINCT target_uid FROM tmp_question_match) AS q ON sq.uid = q.target_uid; -- set up references to QB question UIDs created above INSERT INTO lams_qb_tool_question - SELECT q.question_uid, qb.uid + SELECT q.question_uid, qb.uid, s.content_id, sq.order_id FROM lams_qb_question AS qb JOIN tmp_question_match AS q - ON qb.tmp_question_id = q.target_uid; + ON qb.tmp_question_id = q.target_uid + JOIN tl_lascrt11_scratchie_item AS sq + ON q.question_uid = sq.uid + JOIN tl_lascrt11_scratchie AS s + ON sq.scratchie_uid = s.uid; -- set up references to QB question UIDs for existing questions INSERT INTO lams_qb_tool_question - SELECT q.question_uid, qb.question_uid + SELECT q.question_uid, qb.question_uid, s.content_id, sq.order_id FROM tmp_question AS q JOIN tmp_qb_question qb - USING (content); + USING (content) + JOIN tl_lascrt11_scratchie_item AS sq + ON q.question_uid = sq.uid + JOIN tl_lascrt11_scratchie AS s + ON sq.scratchie_uid = s.uid; -- delete obsolete columns ALTER TABLE tl_lascrt11_scratchie_item DROP FOREIGN KEY FK_NEW_610529188_F52D1F93EC0D3147, DROP COLUMN title, DROP COLUMN description, DROP COLUMN create_date, DROP COLUMN create_by_author, - DROP COLUMN session_uid; + DROP COLUMN session_uid, + DROP COLUMN order_id; -- fill table with options matching unique QB questions inserted above INSERT INTO lams_qb_option (qb_question_uid, display_order, name, correct) SELECT q.uid, o.order_id + 1, TRIM(o.description), o.correct FROM tl_lascrt11_scratchie_answer AS o - JOIN lams_qb_question AS q ON o.scratchie_item_uid = q.tmp_question_id + JOIN lams_qb_question AS q + ON o.scratchie_item_uid = q.tmp_question_id ORDER BY o.order_id; @@ -241,5 +268,4 @@ -- If there were no errors, commit and restore autocommit to on COMMIT; -SET AUTOCOMMIT = 1; -SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file +SET AUTOCOMMIT = 1; \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/qb/model/QbQuestion.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_common/src/java/org/lamsfoundation/lams/qb/model/QbQuestion.java (.../QbQuestion.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_common/src/java/org/lamsfoundation/lams/qb/model/QbQuestion.java (.../QbQuestion.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -2,6 +2,7 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.persistence.CascadeType; @@ -57,6 +58,9 @@ @Column private Integer version = 1; + @Column(name = "create_date") + private Date createDate = new Date(); + // text of the question @Column private String name; @@ -157,6 +161,14 @@ this.version = version; } + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + public String getName() { return name; } Index: lams_common/src/java/org/lamsfoundation/lams/qb/model/QbToolQuestion.java =================================================================== diff -u -rc87bb47eb670934f10192c08922f83367bc36230 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_common/src/java/org/lamsfoundation/lams/qb/model/QbToolQuestion.java (.../QbToolQuestion.java) (revision c87bb47eb670934f10192c08922f83367bc36230) +++ lams_common/src/java/org/lamsfoundation/lams/qb/model/QbToolQuestion.java (.../QbToolQuestion.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -36,6 +36,12 @@ @JoinColumn(name = "qb_question_uid") protected QbQuestion qbQuestion; + @Column(name = "tool_content_id") + protected Long toolContentId; + + @Column(name = "display_order") + protected int displayOrder = 1; + public Long getUid() { return this.uid; } @@ -47,4 +53,20 @@ public void setQbQuestion(QbQuestion qbQuestion) { this.qbQuestion = qbQuestion; } -} + + public Long getToolContentId() { + return toolContentId; + } + + public void setToolContentId(Long toolContentId) { + this.toolContentId = toolContentId; + } + + public int getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(int displayOrder) { + this.displayOrder = displayOrder; + } +} \ No newline at end of file Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java =================================================================== diff -u -rc87bb47eb670934f10192c08922f83367bc36230 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java (.../McQueContent.java) (revision c87bb47eb670934f10192c08922f83367bc36230) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java (.../McQueContent.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -59,12 +59,9 @@ @Column(name = "question_hash") private String questionHash; - @Column(name = "display_order") - private Integer displayOrder; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "mc_content_id") - private org.lamsfoundation.lams.tool.mc.model.McContent mcContent; + private McContent mcContent; //DTO fields @Transient @@ -114,20 +111,13 @@ this.questionHash = questionHash; } - public Integer getDisplayOrder() { - return this.displayOrder; - } - - public void setDisplayOrder(Integer displayOrder) { - this.displayOrder = displayOrder; - } - public org.lamsfoundation.lams.tool.mc.model.McContent getMcContent() { return this.mcContent; } - public void setMcContent(org.lamsfoundation.lams.tool.mc.model.McContent mcContent) { + public void setMcContent(McContent mcContent) { this.mcContent = mcContent; + this.toolContentId = mcContent.getMcContentId(); } /** Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java =================================================================== diff -u -rf24a82ae2ef1cbaa92dfd356226f6c3edcd5e404 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision f24a82ae2ef1cbaa92dfd356226f6c3edcd5e404) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -315,12 +315,14 @@ // new version of the old question gets created qbQuestion = qbQuestionClone; qbQuestion.setVersion(qbService.getMaxQuestionVersion(qbQuestion.getQuestionId())); + qbQuestion.setCreateDate(new Date()); break; case IQbService.QUESTION_MODIFIED_ID_BUMP: // new question gets created qbQuestion = qbQuestionClone; qbQuestion.setVersion(1); qbQuestion.setQuestionId(qbService.getMaxQuestionId()); + qbQuestion.setCreateDate(new Date()); break; } @@ -563,7 +565,7 @@ } answerDto.setQuestion(question.getQuestion()); - answerDto.setDisplayOrder(question.getDisplayOrder().toString()); + answerDto.setDisplayOrder(String.valueOf(question.getDisplayOrder())); answerDto.setQuestionUid(question.getUid()); answerDto.setMark(question.getMark()); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McLearningController.java =================================================================== diff -u -rc87bb47eb670934f10192c08922f83367bc36230 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McLearningController.java (.../McLearningController.java) (revision c87bb47eb670934f10192c08922f83367bc36230) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McLearningController.java (.../McLearningController.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -340,7 +340,7 @@ AnswerDTO answerDto = new AnswerDTO(); answerDto.setQuestion(question.getQuestion()); - answerDto.setDisplayOrder(question.getDisplayOrder().toString()); + answerDto.setDisplayOrder(String.valueOf(question.getDisplayOrder())); answerDto.setQuestionUid(question.getUid()); answerDto.setFeedback(question.getFeedback() != null ? question.getFeedback() : ""); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java (.../Scratchie.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/Scratchie.java (.../Scratchie.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -35,7 +35,6 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; -import javax.persistence.OrderBy; import javax.persistence.Table; import org.apache.commons.lang.builder.EqualsBuilder; @@ -83,9 +82,8 @@ private Date submissionDeadline; @OneToMany - @OrderBy("order_id ASC") @JoinColumn(name = "scratchie_uid") - private Set scratchieItems = new HashSet<>();; + private Set scratchieItems = new HashSet<>(); @Column(name = "extra_point") private boolean extraPoint; Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -27,7 +27,6 @@ import java.util.LinkedList; import java.util.List; -import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; @@ -52,9 +51,6 @@ private static final Logger log = Logger.getLogger(ScratchieItem.class); - @Column(name = "order_id") - private Integer orderId; - // ************************ DTO fields *********************** @Transient private boolean isUnraveled; @@ -65,6 +61,10 @@ @Transient private int qbQuestionModified = IQbService.QUESTION_MODIFIED_NONE; + public ScratchieItem() { + + } + @Override public Object clone() { ScratchieItem item = null; @@ -93,14 +93,6 @@ this.answers = answers; } - public Integer getOrderId() { - return orderId; - } - - public void setOrderId(Integer orderId) { - this.orderId = orderId; - } - public boolean isUnraveled() { return isUnraveled; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -reb5312af3f0d7ca64ca3b41988129079c7509427 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision eb5312af3f0d7ca64ca3b41988129079c7509427) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -971,6 +971,8 @@ BurningQuestionItemDTO generalBurningQuestionItemDto = new BurningQuestionItemDTO(); ScratchieItem generalDummyItem = new ScratchieItem(); generalDummyItem.setQbQuestion(new QbQuestion()); + releaseFromCache(generalDummyItem); + releaseFromCache(generalDummyItem.getQbQuestion()); // generalDummyItem.setUid(0L); final String generalQuestionMessage = messageService.getMessage("label.general.burning.question"); generalDummyItem.getQbQuestion().setName(generalQuestionMessage); @@ -2300,9 +2302,10 @@ ObjectNode questionData = (ObjectNode) questions.get(i); ScratchieItem item = new ScratchieItem(); - item.setOrderId(JsonUtil.optInt(questionData, RestTags.DISPLAY_ORDER)); + item.setDisplayOrder(JsonUtil.optInt(questionData, RestTags.DISPLAY_ORDER)); item.getQbQuestion().setName(JsonUtil.optString(questionData, RestTags.QUESTION_TITLE)); item.getQbQuestion().setDescription(JsonUtil.optString(questionData, RestTags.QUESTION_TEXT)); + item.setToolContentId(scratchie.getContentId()); newItems.add(item); // set options Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieItemComparator.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieItemComparator.java (.../ScratchieItemComparator.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieItemComparator.java (.../ScratchieItemComparator.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -9,8 +9,8 @@ @Override public int compare(ScratchieItem o1, ScratchieItem o2) { - if (o1 != null && o2 != null & o1.getOrderId() != null && o2.getOrderId() != null) { - if (o1.getOrderId() > o2.getOrderId()) { + if (o1 != null && o2 != null) { + if (o1.getDisplayOrder() > o2.getDisplayOrder()) { return 1; } else { return -1; Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r6de3d240b76c900f96a93ab784838f2153fbe7c5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) @@ -192,8 +192,8 @@ // If there is no order id, set it up int i = 1; for (ScratchieItem scratchieItem : itemList) { - if (scratchieItem.getOrderId() == null || scratchieItem.getOrderId() != i) { - scratchieItem.setOrderId(i); + if (scratchieItem.getDisplayOrder() != i) { + scratchieItem.setDisplayOrder(i); } i++; } @@ -286,6 +286,7 @@ while (iter.hasNext()) { ScratchieItem item = iter.next(); if (item != null) { + item.setToolContentId(scratchiePO.getContentId()); removeNewLineCharacters(item); items.add(item); // modification status was already set in AuthoringController#saveItem() @@ -296,6 +297,7 @@ item.setQbQuestion(qbQuestion); qbQuestion.clearID(); qbQuestion.setVersion(qbService.getMaxQuestionVersion(qbQuestion.getQuestionId())); + qbQuestion.setCreateDate(new Date()); } break; case IQbService.QUESTION_MODIFIED_ID_BUMP: { @@ -305,6 +307,7 @@ qbQuestion.clearID(); qbQuestion.setVersion(1); qbQuestion.setQuestionId(qbService.getMaxQuestionId()); + qbQuestion.setCreateDate(new Date()); } break; } @@ -428,9 +431,9 @@ int maxSeq = 1; if (itemList != null && itemList.size() > 0) { ScratchieItem last = itemList.last(); - maxSeq = last.getOrderId() + 1; + maxSeq = last.getDisplayOrder() + 1; } - item.setOrderId(maxSeq); + item.setDisplayOrder(maxSeq); itemList.add(item); } else { // edit List rList = new ArrayList<>(itemList); @@ -484,9 +487,9 @@ int maxSeq = 1; if (itemList != null && itemList.size() > 0) { ScratchieItem last = itemList.last(); - maxSeq = last.getOrderId() + 1; + maxSeq = last.getDisplayOrder() + 1; } - item.setOrderId(maxSeq); + item.setDisplayOrder(maxSeq); item.getQbQuestion().setName(question.getTitle()); item.getQbQuestion().setDescription(QuestionParser.processHTMLField(question.getText(), false, contentFolderID, question.getResourcesFolderPath())); @@ -665,9 +668,9 @@ repOption = rList.get(++itemIndex); } - int upSeqId = repOption.getOrderId(); - repOption.setOrderId(item.getOrderId()); - item.setOrderId(upSeqId); + int upSeqId = repOption.getDisplayOrder(); + repOption.setDisplayOrder(item.getDisplayOrder()); + item.setDisplayOrder(upSeqId); // put back list, it will be sorted again itemList.clear();