Index: lams_build/3rdParty.userlibraries =================================================================== diff -u -r8bc318f44b193b1d926fcc62211ca1b4b18d9b30 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision 8bc318f44b193b1d926fcc62211ca1b4b18d9b30) +++ lams_build/3rdParty.userlibraries (.../3rdParty.userlibraries) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -11,7 +11,7 @@ - + Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rcf258bae4dd72eab7a6f5bc895b96966caafaf06 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision cf258bae4dd72eab7a6f5bc895b96966caafaf06) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -321,7 +321,7 @@ label.tab.conditions.timelimit.individual = Is this time limit for each individual? label.tab.conditions.enable = Enable label.questions.file.title = Choose IMS QTI file -label.questions.file.missing = Please select a ZIP or XML file with questions in IMS QTIformat. +label.questions.file.missing = Please select an MS Word (.docx), ZIP or XML file with the questions to import. label.questions.choice.title = Choose questions label.questions.choice.select.all = Select all label.questions.choice.missing = Please check at least one question. @@ -977,7 +977,7 @@ label.qb.collection.private = Private collection label.qb.collection.remove = Remove collection label.qb.collection.xml = XML -label.qb.collection.qti = QTI +label.qb.collection.qti = IMS QTI label.qb.collection.questions.none = There are no questions in this collection label.qb.collection.share.title = Share collection with courses label.qb.collection.shared = Shared @@ -1053,9 +1053,10 @@ label.authoring.basic.none = None error.positive.grade.required = One of the answers should have a positive grade label.do.you.want.to.delete.answer = Do you want to delete this answer? -label.choose.word.document = Choose Word file -label.import.word = Import questions from Word document -label.qb.collection.word = Word +label.choose.word.document = Choose Microsoft Word file +label.import.word = Import questions from Microsoft Word document +# Microsoft Word +label.qb.collection.word = MS Word authoring.fla.page.prop.gate.type.password = Password authoring.fla.page.prop.password = Password label.question.bank = Question Bank @@ -1073,7 +1074,9 @@ label.authoring.feeback.correct = Feedback on any correct response label.authoring.feeback.partially.correct = Feedback on any partially correct response label.authoring.feeback.incorrect = Feedback on any incorrect response - -label.choose.word.document =Choose Word file -label.import.word =Import questions from Word document -label.qb.collection.word =Word \ No newline at end of file +error.ld.zip.file = Only zip files allowed +# MS Word file template for importing questions into LAMS +label.download.word.template = Download Microsoft Word template +authoring.tbl.import.questions.from = Import questions from +button.save.new.version = Save as new version +authoring.fla.replace.question.prompt = The question you updated is present in other activities in this learning design. Do you want to update this question also in [0]? Index: lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java =================================================================== diff -u -rcf258bae4dd72eab7a6f5bc895b96966caafaf06 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision cf258bae4dd72eab7a6f5bc895b96966caafaf06) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/template/web/LdTemplateController.java (.../LdTemplateController.java) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -41,6 +41,7 @@ import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.service.AuthoringService; import org.lamsfoundation.lams.authoring.service.IAuthoringFullService; import org.lamsfoundation.lams.authoring.template.AssessMCAnswer; import org.lamsfoundation.lams.authoring.template.Assessment; @@ -58,10 +59,8 @@ import org.lamsfoundation.lams.questions.Question; import org.lamsfoundation.lams.questions.QuestionParser; import org.lamsfoundation.lams.rest.RestTags; -import org.lamsfoundation.lams.rest.ToolRestManager; import org.lamsfoundation.lams.tool.Tool; import org.lamsfoundation.lams.tool.dao.IToolDAO; -import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.service.ILamsCoreToolService; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.AuthoringJsonTags; @@ -662,29 +661,6 @@ return activityJSON; } - /* ************************************** Tool related methods ********************************************** */ - /** General method to create a tool content. All calls to create tool content should go through this method */ - protected Long createToolContent(UserDTO user, String toolSignature, ObjectNode toolContentJSON) - throws IOException { - try { - Tool tool = getTool(toolSignature); - Long toolContentID = authoringService.insertToolContentID(tool.getToolId()); - - // Tools' services implement an interface for processing REST requests - ToolRestManager toolRestService = (ToolRestManager) lamsCoreToolService.findToolService(tool); - toolRestService.createRestToolContent(user.getUserID(), toolContentID, toolContentJSON); - - return toolContentID; - } catch (Exception e) { - log.error("Unable to create tool content for " + toolSignature + " with details " + toolContentJSON - + ". \nThe tool probably threw an exception - check the server logs for more details.\n" - + "If the exception is \"Servlet.service() for servlet ToolContentRestServlet threw exception java.lang.ClassCastException: com.sun.proxy.$ProxyXXX cannot be cast to org.lamsfoundation.lams.rest.ToolRestManager)\"" - + " then the tool doesn't support the LDTemplate service calls (ie has not implemented the ToolRestManager interface / createRestToolContent() method."); - throw new ToolException( - "Unable to create tool content for " + toolSignature + " with details " + toolContentJSON); - } - } - /** * General method to create tool activity. All calls to create an activity relating to a tool should go through this * method @@ -732,87 +708,7 @@ return activityJSON; } - /** Sets up the standard fields that are used by many tools! */ - protected ObjectNode createStandardToolContent(String title, String instructions, String reflectionInstructions, - Boolean lockWhenFinished, Boolean allowRichTextEditor, UserDTO user) { - ObjectNode toolContentJSON = JsonNodeFactory.instance.objectNode(); - toolContentJSON.put(RestTags.TITLE, title != null ? title : ""); - toolContentJSON.put(RestTags.INSTRUCTIONS, instructions != null ? instructions : ""); - - if (reflectionInstructions != null) { - toolContentJSON.put(RestTags.REFLECT_ON_ACTIVITY, true); - toolContentJSON.put(RestTags.REFLECT_INSTRUCTIONS, reflectionInstructions); - } - - toolContentJSON.put(RestTags.LOCK_WHEN_FINISHED, lockWhenFinished); - toolContentJSON.put(RestTags.ALLOW_RICH_TEXT_EDITOR, allowRichTextEditor); - - if (user != null) { - toolContentJSON.put("firstName", user.getFirstName()); - toolContentJSON.put("lastName", user.getLastName()); - toolContentJSON.put("loginName", user.getLogin()); - } - return toolContentJSON; - } - /** - * Helper method to create a Assessment tool content. Assessment is one of the unusuals tool in that it caches - * user's login names and - * first/last names Mandatory fields in toolContentJSON: title, instructions, resources, user fields firstName, - * lastName and loginName. - * - * Required fields in toolContentJSON: "title", "instructions", "questions", "firstName", "lastName", "lastName", - * "questions" and "references". - * - * The questions entry should be ArrayNode containing JSON objects, which in turn must contain - * "questionTitle", "questionText", "displayOrder" (Integer), "type" (Integer). If the type is Multiple Choice, - * Numerical or Matching Pairs - * then a ArrayNode "answers" is required. - * - * The answers entry should be ArrayNode - * containing JSON objects, which in turn must contain "answerText" or "answerFloat", "displayOrder" (Integer), - * "grade" (Integer). - * - * For the templates, all the questions that are created will be set up as references, therefore the questions in - * the assessment == the bank of questions. - * So references entry will be a ArrayNode containing JSON objects, which in turn must contain "displayOrder" - * (Integer), - * "questionDisplayOrder" (Integer - to match to the question). If default grade or random questions are needed then - * this method needs - * to be expanded. - */ - protected Long createAssessmentToolContent(UserDTO user, String title, String instructions, - String reflectionInstructions, boolean selectLeaderToolOutput, boolean enableNumbering, - boolean enableConfidenceLevels, boolean allowDiscloseAnswers, boolean allowAnswerJustification, - ArrayNode questions) throws IOException { - - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, null, null, - user); - toolContentJSON.put(RestTags.USE_SELECT_LEADER_TOOL_OUTPUT, selectLeaderToolOutput); - toolContentJSON.put(RestTags.ENABLE_CONFIDENCE_LEVELS, enableConfidenceLevels); - toolContentJSON.put("numbered", enableNumbering); - toolContentJSON.put("displaySummary", Boolean.TRUE); - toolContentJSON.put("allowDiscloseAnswers", allowDiscloseAnswers); - toolContentJSON.put("allowAnswerJustification", allowAnswerJustification); - - toolContentJSON.set(RestTags.QUESTIONS, questions); - - ArrayNode references = JsonNodeFactory.instance.arrayNode(); - for (int i = 0; i < questions.size(); i++) { - ObjectNode question = (ObjectNode) questions.get(i); - question.put("answerRequired", true); - - Integer questionDisplayOrder = question.get(RestTags.DISPLAY_ORDER).asInt(); - Integer defaultGrade = JsonUtil.optInt(question, "defaultGrade", 1); - references.add(JsonNodeFactory.instance.objectNode().put(RestTags.DISPLAY_ORDER, questionDisplayOrder) - .put("questionDisplayOrder", questionDisplayOrder).put("defaultGrade", defaultGrade)); - } - toolContentJSON.set("references", references); - - return createToolContent(user, LdTemplateController.ASSESSMENT_TOOL_SIGNATURE, toolContentJSON); - } - - /** * Creates a forum activity's JSON details. */ protected ObjectNode createAssessmentActivity(AtomicInteger uiid, int order, Integer[] layoutCoords, @@ -833,10 +729,10 @@ protected Long createChatToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished, String filterKeywords, String reflectionInstructions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, - lockWhenFinished, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, + reflectionInstructions, lockWhenFinished, null, null); toolContentJSON.put("filterKeywords", filterKeywords); - return createToolContent(user, LdTemplateController.CHAT_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.CHAT_TOOL_SIGNATURE, toolContentJSON); } /** @@ -872,8 +768,8 @@ boolean allowRichTextEditor, boolean allowNewTopic, boolean allowRateMessages, boolean allowUpload, boolean limitedMaxCharacters, Integer maxCharacters, ArrayNode topics) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, - allowRichTextEditor, user); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, allowRichTextEditor, user); toolContentJSON.set("topics", topics); toolContentJSON.put("allowNewTopic", allowNewTopic); toolContentJSON.put("allowRateMessages", allowRateMessages); @@ -882,7 +778,7 @@ if (limitedMaxCharacters && maxCharacters != null) { toolContentJSON.put("maxCharacters", maxCharacters); } - return createToolContent(user, LdTemplateController.FORUM_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.FORUM_TOOL_SIGNATURE, toolContentJSON); } /** @@ -903,8 +799,9 @@ */ protected Long createLeaderSelectionToolContent(UserDTO user, String title, String instructions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null); - return createToolContent(user, LdTemplateController.LEADER_TOOL_SIGNATURE, toolContentJSON); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, null, null, + null); + return authoringService.createToolContent(user, LdTemplateController.LEADER_TOOL_SIGNATURE, toolContentJSON); } /** @@ -926,9 +823,9 @@ protected Long createNotebookToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished, boolean allowRichTextEditor) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, - allowRichTextEditor, null); - return createToolContent(user, LdTemplateController.NOTEBOOK_TOOL_SIGNATURE, toolContentJSON); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, allowRichTextEditor, null); + return authoringService.createToolContent(user, LdTemplateController.NOTEBOOK_TOOL_SIGNATURE, toolContentJSON); } /** @@ -950,9 +847,11 @@ protected Long createNoticeboardToolContent(UserDTO user, String title, String content, String reflectionInstructions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, null, reflectionInstructions, null, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, null, reflectionInstructions, + null, null, null); toolContentJSON.put("content", content != null ? content : ""); - return createToolContent(user, LdTemplateController.NOTICEBOARD_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.NOTICEBOARD_TOOL_SIGNATURE, + toolContentJSON); } /** @@ -975,13 +874,13 @@ boolean allowRichTextEditor, boolean oneQuestionPerPage, boolean showOtherLearnersAnswers, boolean showOtherLearnersNames, ArrayNode questions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, - allowRichTextEditor, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, allowRichTextEditor, null); toolContentJSON.set(RestTags.QUESTIONS, questions); toolContentJSON.put("questionsSequenced", oneQuestionPerPage); toolContentJSON.put("showOtherAnswers", showOtherLearnersAnswers); toolContentJSON.put("usernameVisible", showOtherLearnersNames); - return createToolContent(user, LdTemplateController.QA_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.QA_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1002,9 +901,10 @@ protected Long createMindmapToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished, boolean multiUserMode, String reflectionInstruction) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, null, null); toolContentJSON.put("multiUserMode", multiUserMode); - return createToolContent(user, LdTemplateController.MINDMAP_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.MINDMAP_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1031,8 +931,8 @@ boolean notifyInstructors, Integer minResourcesToView, String reflectionInstructions, ArrayNode resources) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, - lockWhenFinished, null, user); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, + reflectionInstructions, lockWhenFinished, null, user); toolContentJSON.put("allowAddFiles", allowLearnerAddFile); toolContentJSON.put("allowAddUrls", allowLearnerAddURL); toolContentJSON.put("notifyTeachersOnAssigmentSumbit", notifyInstructors); @@ -1041,7 +941,8 @@ toolContentJSON.put("minViewResourceNumber", minResourcesToView); } toolContentJSON.set("resources", resources); - return createToolContent(user, LdTemplateController.SHARE_RESOURCES_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.SHARE_RESOURCES_TOOL_SIGNATURE, + toolContentJSON); } // resource type - copied from ResourceConstants @@ -1125,7 +1026,8 @@ boolean useSelectLeaderToolOuput, Integer confidenceLevelsActivityUiid, ArrayNode questions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, null, null, + null); toolContentJSON.set(RestTags.QUESTIONS, questions); if (confidenceLevelsActivityUiid != null) { toolContentJSON.put(RestTags.CONFIDENCE_LEVELS_ACTIVITY_UIID, confidenceLevelsActivityUiid); @@ -1136,7 +1038,7 @@ question.put("answerRequired", true); } - return createToolContent(user, LdTemplateController.SCRATCHIE_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.SCRATCHIE_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1160,12 +1062,12 @@ boolean autoSelectScribe, boolean showAggregatedReports, String reflectionInstructions, ArrayNode questions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, - lockWhenFinished, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, + reflectionInstructions, lockWhenFinished, null, null); toolContentJSON.set(RestTags.QUESTIONS, questions); toolContentJSON.put("autoSelectScribe", autoSelectScribe); toolContentJSON.put("showAggregatedReports", showAggregatedReports); - return createToolContent(user, LdTemplateController.SCRIBE_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.SCRIBE_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1188,13 +1090,13 @@ protected Long createSubmitToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished, Boolean limitUpload, Integer limitUploadNumber, String reflectionInstructions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, - lockWhenFinished, null, user); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, + reflectionInstructions, lockWhenFinished, null, user); if (limitUploadNumber != null) { toolContentJSON.put("limitUpload", limitUpload != null ? limitUpload : true); toolContentJSON.put("limitUploadNumber", limitUploadNumber); } - return createToolContent(user, LdTemplateController.SUBMIT_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.SUBMIT_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1216,9 +1118,10 @@ protected Long createSurveyToolContent(UserDTO user, String title, String instructions, Boolean lockWhenFinished, ArrayNode questions) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, user); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, null, user); toolContentJSON.set("questions", questions); - return createToolContent(user, LdTemplateController.SURVEY_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.SURVEY_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1240,10 +1143,11 @@ protected Long createVoteToolContent(UserDTO user, String title, String instructions, ArrayNode answers, Boolean showResults) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, null, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, null, null, + null); toolContentJSON.set(RestTags.ANSWERS, answers); toolContentJSON.put("showResults", showResults); - return createToolContent(user, LdTemplateController.VOTE_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.VOTE_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1264,9 +1168,10 @@ protected Long createWikiToolContent(UserDTO user, String title, String instructions, boolean lockWhenFinished, String reflectionInstruction, ArrayNode pages) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, null, lockWhenFinished, null, null); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, null, + lockWhenFinished, null, null); toolContentJSON.set("pages", pages); - return createToolContent(user, LdTemplateController.WIKI_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.WIKI_TOOL_SIGNATURE, toolContentJSON); } /** @@ -1291,10 +1196,11 @@ protected Long createPeerReviewToolContent(UserDTO user, String title, String instructions, String reflectionInstructions, ArrayNode criterias) throws IOException { - ObjectNode toolContentJSON = createStandardToolContent(title, instructions, reflectionInstructions, null, null, - user); + ObjectNode toolContentJSON = AuthoringService.createStandardToolContent(title, instructions, + reflectionInstructions, null, null, user); toolContentJSON.set("criterias", criterias); - return createToolContent(user, LdTemplateController.PEER_REVIEW_TOOL_SIGNATURE, toolContentJSON); + return authoringService.createToolContent(user, LdTemplateController.PEER_REVIEW_TOOL_SIGNATURE, + toolContentJSON); } /** @@ -1523,6 +1429,8 @@ } assessment.setDefaultGrade(defaultGrade); + + assessment.setLearningOutcomes(question.getLearningOutcomes()); } return assessments; Index: lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java =================================================================== diff -u -rb5d2a6851ee4797e641081bd5e6a1f28f78c30a6 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java (.../SearchQBController.java) (revision b5d2a6851ee4797e641081bd5e6a1f28f78c30a6) +++ lams_central/src/java/org/lamsfoundation/lams/web/qb/SearchQBController.java (.../SearchQBController.java) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -223,8 +223,7 @@ boolean isScratchie = WebUtil.readBooleanParam(request, "isScratchie", false); request.setAttribute("isScratchie", isScratchie); - List otherVersions = qbService.getQuestionsByQuestionId(qbQuestion.getQuestionId()); - request.setAttribute("otherVersions", otherVersions); + qbService.fillVersionMap(qbQuestion); return "qb/qbQuestionDetails"; } Index: lams_central/web/includes/javascript/authoring/authoringActivity.js =================================================================== diff -u -rad1ff0d36bbc9744c0e0e61aec07c9360faee906 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision ad1ff0d36bbc9744c0e0e61aec07c9360faee906) +++ lams_central/web/includes/javascript/authoring/authoringActivity.js (.../authoringActivity.js) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -1500,38 +1500,16 @@ }); }, - + /** * Open separate window with activity authoring on double click. */ openActivityAuthoring : function(activity){ - // fetch authoring URL for a Tool Activity - if (!activity.authorURL && activity.toolID) { - $.ajax({ - async : true, - cache : false, - url : LAMS_URL + "authoring/createToolContent.do", - dataType : 'json', - data : { - 'toolID' : activity.toolID, - // if toolContentID exists, a new content will not be created, only authorURL will be fetched - 'toolContentID' : activity.toolContentID, - 'contentFolderID' : layout.ld.contentFolderID - }, - success : function(response) { - activity.authorURL = response.authorURL; - if (!activity.toolContentID) { - activity.toolContentID = response.toolContentID; - } - if (!layout.ld.contentFolderID) { - // if LD did not have contentFolderID, it was just generated - // so remember it - layout.ld.contentFolderID = response.contentFolderID; - } - } - }); + if (activity.isAuthoringOpening) { + return; } + activity.isAuthoringOpening = true; if (activity.authorURL) { var dialogID = "dialogActivity" + activity.toolContentID; showDialog(dialogID, { @@ -1568,12 +1546,51 @@ }, true); GeneralLib.setModified(true); + activity.isAuthoringOpening = false; + return; } + + // if there is no authoring URL, fetch it for a Tool Activity + if (activity.toolID) { + $.ajax({ + async : true, + cache : false, + url : LAMS_URL + "authoring/createToolContent.do", + dataType : 'json', + data : { + 'toolID' : activity.toolID, + // if toolContentID exists, a new content will not be created, only authorURL will be fetched + 'toolContentID' : activity.toolContentID, + 'contentFolderID' : layout.ld.contentFolderID + }, + success : function(response) { + // make sure that response contains valid data + if (response.authorURL) { + activity.authorURL = response.authorURL; + activity.toolContentID = response.toolContentID; + // the response should always return a correct content folder ID, + // but just to make sure use it only when it is needed + if (!layout.ld.contentFolderID) { + layout.ld.contentFolderID = response.contentFolderID; + } + + activity.isAuthoringOpening = false; + // this time open it properly + ActivityLib.openActivityAuthoring(activity); + } + }, + complete : function(){ + activity.isAuthoringOpening = false; + } + }); + } else { + activity.isAuthoringOpening = false; + } }, /** - * Draw each of activity's inboud and outbound transitions again. + * Draw each of activity's inbound and outbound transitions again. */ redrawTransitions : function(activity) { if (activity.transitions) { Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js =================================================================== diff -u -rdcb81d1b2bd66f65b38ae9c167bad8d743e03ab0 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision dcb81d1b2bd66f65b38ae9c167bad8d743e03ab0) +++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -1664,6 +1664,39 @@ }, /** + * Check if given question exists in tool activities in this sequence + */ + checkQuestionExistsInToolActivities : function(qbQuestionUid) { + let resultToolContentIds = [], + candidateToolContentIds = []; + + // list all tool activities + $.each(layout.activities, function() { + if (this.toolContentID) { + candidateToolContentIds.push(this.toolContentID); + } + }); + + // ask back end if given activities contain the given question + $.ajax({ + cache : false, + async : false, + url : LAMS_URL + "qb/edit/checkQuestionExistsInToolActivities.do", + dataType : 'json', + data : { + 'toolContentIds' : candidateToolContentIds, + 'qbQuestionUid' : qbQuestionUid + }, + success : function(responseToolContentIds){ + // the response is list of tool content IDs which contain the given question + resultToolContentIds = responseToolContentIds; + } + }); + + return resultToolContentIds; + }, + + /** * Escapes HTML tags to prevent XSS injection. */ escapeHtml : function(unsafe) { @@ -2798,7 +2831,43 @@ }; }, + /** + * Replaces the old question with new question in given tool activities in this sequence + */ + replaceQuestionInToolActivities : function(thisToolContentId, allToolContentIds, oldQbQuestionUid, newQbQuestionUid) { + let activityTitles = '', + questionReplaced = false; + + // list names of all tool activities which contain the old question + $.each(layout.activities, function() { + if (this.toolContentID && this.toolContentID != thisToolContentId && allToolContentIds.indexOf(this.toolContentID) > -1) { + activityTitles += '"' + this.title + '", '; + } + }); + // ask teacher if he wants to update other activities too + if (activityTitles != '' && confirm(LABELS.REPLACE_QUESTION_PROMPT.replace('[0]', activityTitles.substring(0, activityTitles.length - 2)))) { + $.ajax({ + type : 'POST', + cache : false, + async : false, + url : LAMS_URL + "qb/edit/replaceQuestionInToolActivities.do", + dataType : 'text', + data : { + 'toolContentIds' : allToolContentIds, + 'oldQbQuestionUid' : oldQbQuestionUid, + 'newQbQuestionUid' : newQbQuestionUid + }, + success : function(){ + questionReplaced = true; + } + }); + } + + return questionReplaced; + }, + + resizeImportPartFrame : function(svgHeight) { $('#ldStoreDialogImportPartFrame').height(svgHeight + 40); }, Index: lams_central/web/includes/javascript/authoring/authoringProperty.js =================================================================== diff -u -r7a19ceb8e410d05b61f130d3416ee06e36be5dd1 -rc53377c8f651bf0c9eedc5f2d4f26f5e1647caf3 --- lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision 7a19ceb8e410d05b61f130d3416ee06e36be5dd1) +++ lams_central/web/includes/javascript/authoring/authoringProperty.js (.../authoringProperty.js) (revision c53377c8f651bf0c9eedc5f2d4f26f5e1647caf3) @@ -1570,15 +1570,17 @@ optionsFound = true; var suffix = ''; - switch(this.type) { - case 'OUTPUT_BOOLEAN' : - suffix = LABELS.BOOLEAN_OUTPUT_SUFFIX; - break; - - case 'OUTPUT_LONG' : - suffix = LABELS.RANGE_OUTPUT_SUFFIX; - break; - }; + if (!this.showConditionNameOnly) { + switch(this.type) { + case 'OUTPUT_BOOLEAN' : + suffix = LABELS.BOOLEAN_OUTPUT_SUFFIX; + break; + + case 'OUTPUT_LONG' : + suffix = LABELS.RANGE_OUTPUT_SUFFIX; + break; + }; + } var option = $('