Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20190517.sql =================================================================== diff -u --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20190517.sql (revision 0) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/dbupdates/patch20190517.sql (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -0,0 +1,16 @@ +-- 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-4821 remove obsolete hash field +ALTER TABLE tl_laasse10_assessment_question DROP COLUMN question_hash; + +UPDATE lams_tool SET tool_version='20190517' WHERE tool_signature='laasse10'; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java =================================================================== diff -u -r9c3a64b840753192b333afb73c8fe7bdb54be638 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision 9c3a64b840753192b333afb73c8fe7bdb54be638) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/model/AssessmentQuestion.java (.../AssessmentQuestion.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -53,12 +53,6 @@ private static final long serialVersionUID = -7767327140430305575L; private static final Logger log = Logger.getLogger(AssessmentQuestion.class); - /** - * It stores sha1(question) value that allows us to search for the AssessmentQuestions with the same question - */ - @Column(name = "question_hash") - private String questionHash; - @Column(name = "correct_answers_disclosed") private boolean correctAnswersDisclosed; @@ -133,17 +127,6 @@ this.uid = userID; } - /** - * Returns sha1(question) value that allows us to search for the AssessmentQuestions with the same question - */ - public String getQuestionHash() { - return questionHash; - } - - public void setQuestionHash(String questionHash) { - this.questionHash = questionHash; - } - public boolean isCorrectAnswersDisclosed() { return correctAnswersDisclosed; } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentImportContentVersionFilter.java =================================================================== diff -u -r9c3a64b840753192b333afb73c8fe7bdb54be638 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentImportContentVersionFilter.java (.../AssessmentImportContentVersionFilter.java) (revision 9c3a64b840753192b333afb73c8fe7bdb54be638) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentImportContentVersionFilter.java (.../AssessmentImportContentVersionFilter.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -85,4 +85,11 @@ this.renameField(QuestionReference.class, "defaultGrade", "maxMark"); this.renameField(QuestionReference.class, "sequenceId", "displayOrder"); } + + /** + * Import 20190110 version content to 20190517 version tool server. + */ + public void up20190110To20190517() { + this.removeField(AssessmentQuestion.class, "questionHash"); + } } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -rb76fdcd16012d4a2c05880ce0ed1cd3eea7965d0 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision b76fdcd16012d4a2c05880ce0ed1cd3eea7965d0) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -415,12 +415,7 @@ @Override public void saveOrUpdateAssessment(Assessment assessment) { - for (AssessmentQuestion question : assessment.getQuestions()) { - //update questions' hashes in case questions' titles or descriptions got changed - String newHash = question.getQbQuestion().getDescription() == null ? null - : HashUtil.sha1(question.getQbQuestion().getDescription()); - question.setQuestionHash(newHash); - + for (AssessmentQuestion question : assessment.getQuestions()) { //update only in case QbQuestion was modified, to prevent updating the same QbQuestions received from SesssionMap if (question.getQbQuestionModified() != IQbService.QUESTION_MODIFIED_NONE) { assessmentQuestionDao.saveObject(question.getQbQuestion()); @@ -434,12 +429,6 @@ @Override public void updateAssessmentQuestion(AssessmentQuestion question) { - //update question's hash in case question's title or description got changed - String newHash = question.getQbQuestion().getDescription() == null ? null - : HashUtil.sha1(question.getQbQuestion().getDescription()); - question.setQuestionHash(newHash); - - //store object in DB assessmentQuestionDao.update(question); } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20190517.sql =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20190517.sql (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20190517.sql (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -0,0 +1,16 @@ +-- 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-4821 remove obsolete hash field +ALTER TABLE tl_lamc11_que_content DROP COLUMN question_hash; + +UPDATE lams_tool SET tool_version='20190517' WHERE tool_signature='lamc11'; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java =================================================================== diff -u -r9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java (.../McQueContent.java) (revision 9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/model/McQueContent.java (.../McQueContent.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -53,12 +53,6 @@ public class McQueContent extends QbToolQuestion implements Serializable, Comparable { private static final long serialVersionUID = 4022287106119453962L; - /** - * It stores sha1(questionDescription) value that allows us to search for the McQueContentc with the same questionDescription - */ - @Column(name = "question_hash") - private String questionHash; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "mc_content_id") private McContent mcContent; @@ -67,9 +61,8 @@ @Transient private String escapedDescription; - public McQueContent(QbQuestion qbQuestion, String questionHash, Integer displayOrder, McContent mcContent) { + public McQueContent(QbQuestion qbQuestion, Integer displayOrder, McContent mcContent) { this.qbQuestion = qbQuestion; - this.questionHash = questionHash; this.displayOrder = displayOrder; setMcContent(mcContent); } @@ -87,8 +80,8 @@ * @return the new qa questionDescription content object */ public static McQueContent newInstance(McQueContent question, McContent newMcContent) { - McQueContent newQueContent = new McQueContent(question.getQbQuestion(), question.getQuestionHash(), - question.getDisplayOrder(), newMcContent); + McQueContent newQueContent = new McQueContent(question.getQbQuestion(), question.getDisplayOrder(), + newMcContent); return newQueContent; } @@ -108,17 +101,6 @@ this.qbQuestion.setDescription(description); } - /** - * Returns sha1(questionDescription) value that allows us to search for the McQueContent with the same questionDescription - */ - public String getQuestionHash() { - return questionHash; - } - - public void setQuestionHash(String questionHash) { - this.questionHash = questionHash; - } - public McContent getMcContent() { return this.mcContent; } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McImportContentVersionFilter.java =================================================================== diff -u -ra315972c7e278cf7a0584fcd5fbf7d22957cc4a6 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McImportContentVersionFilter.java (.../McImportContentVersionFilter.java) (revision a315972c7e278cf7a0584fcd5fbf7d22957cc4a6) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McImportContentVersionFilter.java (.../McImportContentVersionFilter.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -57,4 +57,11 @@ public void up20170101To20181202() { this.renameClass("org.lamsfoundation.lams.tool.mc.pojos.", "org.lamsfoundation.lams.tool.mc.model."); } + + /** + * Import 20190110 version content to 20190517 version tool server. + */ + public void up20181202To20190517() { + this.removeField(McQueContent.class, "questionHash"); + } } \ No newline at end of file Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java =================================================================== diff -u -r9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44 -r887cde82a7847b6294b50d242c448f2a575f9c9e --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision 9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision 887cde82a7847b6294b50d242c448f2a575f9c9e) @@ -248,10 +248,6 @@ @Override public void saveOrUpdateMcQueContent(McQueContent question) { - //update questions' hash - String newHash = question.getDescription() == null ? null : HashUtil.sha1(question.getDescription()); - question.setQuestionHash(newHash); - mcQueContentDAO.insertOrUpdate(question.getQbQuestion()); for (QbOption option : question.getQbQuestion().getQbOptions()) { @@ -327,15 +323,15 @@ // in case questionDescription doesn't exist if (question == null) { - question = new McQueContent(qbQuestion, null, new Integer(displayOrder), content); + question = new McQueContent(qbQuestion, displayOrder, content); // adding a new questionDescription to content content.getMcQueContents().add(question); question.setMcContent(content); // in case questionDescription exists already } else { - question.setDisplayOrder(new Integer(displayOrder)); + question.setDisplayOrder(displayOrder); // this is needed, if we took the clone as the new questionDescription question.setQbQuestion(qbQuestion); } @@ -2020,8 +2016,8 @@ qbQuestion.setType(QbQuestion.TYPE_MULTIPLE_CHOICE); qbQuestion.setName(JsonUtil.optString(questionData, RestTags.QUESTION_TEXT)); qbQuestion.setMaxMark(1); - McQueContent question = new McQueContent(qbQuestion, null, - JsonUtil.optInt(questionData, RestTags.DISPLAY_ORDER), mcq); + McQueContent question = new McQueContent(qbQuestion, JsonUtil.optInt(questionData, RestTags.DISPLAY_ORDER), + mcq); ArrayNode optionsData = JsonUtil.optArray(questionData, RestTags.ANSWERS); for (JsonNode optionData : optionsData) {