Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190722.sql =================================================================== diff -u -r7b01f2faaa0d72d872e4624687e4c269b8bf522a -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190722.sql (.../patch20190722.sql) (revision 7b01f2faaa0d72d872e4624687e4c269b8bf522a) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch20190722.sql (.../patch20190722.sql) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -683,13 +683,6 @@ INSERT INTO lams_qb_tool_answer SELECT uid, assessment_question_uid, submitted_option_uid, answer_string FROM tl_laasse10_question_result; --- fill content_folder_id with real values from learning designs -UPDATE lams_qb_question AS qbque, lams_qb_tool_question AS toolque, lams_learning_activity AS activity, lams_learning_design AS design - SET qbque.content_folder_id = design.content_folder_id - WHERE qbque.uid = toolque.qb_question_uid - AND toolque.tool_content_id = activity.tool_content_id - AND activity.learning_design_id = design.learning_design_id; - -- cleanup ALTER TABLE tl_laasse10_question_result DROP COLUMN assessment_question_uid, DROP COLUMN submitted_option_uid, @@ -792,6 +785,16 @@ INSERT INTO lams_qb_tool_answer SELECT uid, qa_que_content_id, NULL, answer FROM tl_laqa11_usr_resp; +-- fill content_folder_id with real values from learning designs +UPDATE lams_qb_question AS qbque, lams_qb_tool_question AS toolque, lams_learning_activity AS activity, lams_learning_design AS design + SET qbque.content_folder_id = design.content_folder_id + WHERE qbque.uid = toolque.qb_question_uid + AND toolque.tool_content_id = activity.tool_content_id + AND activity.learning_design_id = design.learning_design_id; + +-- add a random, default content folder ID for activities which were not a part of a LD, like template activities +UPDATE lams_qb_question SET content_folder_id = '93b97f99-a9ad-471b-a71a-5cc58ab2196e' WHERE content_folder_id IS NULL; + -- clean up ALTER TABLE tl_laqa11_usr_resp DROP COLUMN qa_que_content_id, DROP COLUMN answer; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java =================================================================== diff -u -r9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44 -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java (.../McQuestionDTO.java) (revision 9ca39edffd0c57ba7deeb38316f5a0f7b0d8fe44) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dto/McQuestionDTO.java (.../McQuestionDTO.java) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -41,6 +41,7 @@ private Integer displayOrder; private String feedback; private String mark; + private String contentFolderId; private List optionDtos; @@ -160,6 +161,16 @@ this.mark = mark; } + + + public String getContentFolderId() { + return contentFolderId; + } + + public void setContentFolderId(String contentFolderId) { + this.contentFolderId = contentFolderId; + } + /** * @return Returns the optionDtos. */ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java =================================================================== diff -u -rbed43f31ad918bbd7f19f6db56fc90fcffcc37bd -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision bed43f31ad918bbd7f19f6db56fc90fcffcc37bd) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McService.java (.../McService.java) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -291,6 +291,7 @@ // set clone's data to current values qbQuestionClone.setName(questionDTO.getName()); qbQuestionClone.setDescription(questionDTO.getDescription()); + qbQuestionClone.setContentFolderId(questionDTO.getContentFolderId()); qbQuestionClone.setMaxMark(Integer.valueOf(currentMark)); qbQuestionClone.setFeedback(currentFeedback); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/AuthoringUtil.java =================================================================== diff -u -r394f403c289f0fd7808c228840bead5c4e7d5d32 -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/AuthoringUtil.java (.../AuthoringUtil.java) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/util/AuthoringUtil.java (.../AuthoringUtil.java) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -240,6 +240,7 @@ questionDto.setFeedback(feedback); String mark = question.getMark() == null ? "1" : question.getMark().toString(); questionDto.setMark(mark); + questionDto.setContentFolderId(question.getQbQuestion().getContentFolderId()); // build candidate dtos List optionDtos = new LinkedList<>(); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java =================================================================== diff -u -rd064905749470c0f9d9ffd8b7d8614529d533a88 -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java (.../McController.java) (revision d064905749470c0f9d9ffd8b7d8614529d533a88) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/controller/McController.java (.../McController.java) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -34,15 +34,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.qb.model.QbOption; import org.lamsfoundation.lams.qb.model.QbQuestion; import org.lamsfoundation.lams.qb.service.IQbService; -import org.lamsfoundation.lams.questions.Answer; -import org.lamsfoundation.lams.questions.Question; -import org.lamsfoundation.lams.questions.QuestionExporter; -import org.lamsfoundation.lams.questions.QuestionParser; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.dto.McOptionDTO; @@ -53,6 +48,7 @@ import org.lamsfoundation.lams.tool.mc.util.AuthoringUtil; import org.lamsfoundation.lams.tool.mc.web.form.McAuthoringForm; import org.lamsfoundation.lams.util.CommonConstants; +import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -80,7 +76,7 @@ @Autowired private IMcService mcService; - + @Autowired private IQbService qbService; @@ -143,7 +139,7 @@ List listDeletedQuestionDTOs = new ArrayList<>(); sessionMap.put(McAppConstants.LIST_DELETED_QUESTION_DTOS, listDeletedQuestionDTOs); - + boolean isMcContentAttempted = mcContent.getUid() == null ? false : mcService.isMcContentAttempted(mcContent.getUid()); sessionMap.put(McAppConstants.ATTR_IS_AUTHORING_RESTRICTED, isMcContentAttempted && mode.isTeacher()); @@ -206,9 +202,10 @@ mcService.removeMcQueContent(removeableQuestion); } } - + // store content - mcContent = AuthoringUtil.saveOrUpdateMcContent(mcService, request, mode, mcContent, toolContentID, questionDTOs); + mcContent = AuthoringUtil.saveOrUpdateMcContent(mcService, request, mode, mcContent, toolContentID, + questionDTOs); // store questions mcContent = mcService.createQuestions(questionDTOs, mcContent); @@ -262,6 +259,10 @@ } else { // prepare questionDescription for adding new questionDescription page questionDto = new McQuestionDTO(); + + String contentFolderID = FileUtil.generateUniqueContentFolderID(); + questionDto.setContentFolderId(contentFolderID); + List newOptions = new ArrayList<>(); McOptionDTO newOption1 = new McOptionDTO(); newOption1.setCorrect("Correct"); @@ -434,7 +435,7 @@ return tempQuestionDtos; } - + /** * Adds QbQuestion, selected in the questionDescription bank, to the current questionDescription list. */ @@ -448,8 +449,8 @@ List questionDtos = (List) sessionMap.get(McAppConstants.QUESTION_DTOS); //get QbQuestion from DB - QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid); - + QbQuestion qbQuestion = qbService.getQuestionByUid(qbQuestionUid); + //find max displayOrder int maxDisplayOrder = 0; for (McQuestionDTO questionDto : questionDtos) { @@ -458,7 +459,7 @@ maxDisplayOrder = displayOrder; } } - + // build candidate dtos List optionDtos = new LinkedList<>(); for (QbOption option : qbQuestion.getQbOptions()) { @@ -477,7 +478,7 @@ questionDto.setMark(qbQuestion.getMaxMark() == null ? "1" : String.valueOf(qbQuestion.getMaxMark())); questionDto.setQbQuestionModified(IQbService.QUESTION_MODIFIED_NONE); questionDtos.add(questionDto); - + return "authoring/itemlist"; } @@ -509,6 +510,7 @@ String name = request.getParameter("name"); String description = request.getParameter("description"); String feedback = request.getParameter("feedback"); + String contentFolderId = request.getParameter("contentFolderId"); Integer questionIndex = WebUtil.readIntParam(request, "questionIndex", true); Long qbQuestionUid = WebUtil.readLongParam(request, "qbQuestionUid", true); mcAuthoringForm.setQuestionIndex(questionIndex); @@ -534,6 +536,7 @@ questionDto.setDisplayOrder(maxDisplayOrder + 1); questionDto.setOptionDtos(options); questionDto.setMark(mark); + questionDto.setContentFolderId(contentFolderId); questionDto.setQbQuestionModified(IQbService.QUESTION_MODIFIED_ID_BUMP); request.setAttribute("qbQuestionModified", questionDto.getQbQuestionModified()); @@ -558,6 +561,7 @@ questionDto.setDisplayOrder(questionIndex); questionDto.setOptionDtos(options); questionDto.setMark(mark); + questionDto.setContentFolderId(contentFolderId); questionDto.setQbQuestionModified(mcService.isQbQuestionModified(questionDto)); request.setAttribute("qbQuestionModified", questionDto.getQbQuestionModified()); } Index: lams_tool_lamc/web/authoring/candidateAnswersList.jsp =================================================================== diff -u -r394f403c289f0fd7808c228840bead5c4e7d5d32 -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) +++ lams_tool_lamc/web/authoring/candidateAnswersList.jsp (.../candidateAnswersList.jsp) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -47,7 +47,7 @@ + contentFolderID="${questionDto.contentFolderId}"> Index: lams_tool_lamc/web/authoring/editQuestionBox.jsp =================================================================== diff -u -r394f403c289f0fd7808c228840bead5c4e7d5d32 -r8e97adb8dda2f984a9b43f71eacd9a5033244bff --- lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 394f403c289f0fd7808c228840bead5c4e7d5d32) +++ lams_tool_lamc/web/authoring/editQuestionBox.jsp (.../editQuestionBox.jsp) (revision 8e97adb8dda2f984a9b43f71eacd9a5033244bff) @@ -147,7 +147,8 @@ - + + @@ -165,7 +166,7 @@ + contentFolderID="${questionDto.contentFolderId}">