From 71c02a8a1e6649c69eb194fae7afacfb38fd8bb4 Mon Sep 17 00:00:00 2001 From: Raja Lmsace Date: Wed, 1 Nov 2023 18:09:44 +0530 Subject: [PATCH] Designer 1.5 issues fixed. - Change the order of prerequisites tab setting added. - Backup and restore issues fixed. --- amd/build/designer_section.min.js | 2 +- amd/build/designer_section.min.js.map | 2 +- amd/src/designer_section.js | 6 +- .../restore_format_designer_plugin.class.php | 6 +- classes/output/renderer.php | 90 ++++++++++++++----- lang/en/format_designer.php | 17 +++- lib.php | 59 +++++++++--- settings.php | 21 +++++ styles.css | 90 +++++++++++++++++-- templates/cm/module_layout_cards.mustache | 6 ++ templates/cm/module_layout_default.mustache | 6 ++ templates/cm/module_layout_list.mustache | 7 ++ templates/courseformat/content.mustache | 2 +- templates/section_layout.mustache | 2 +- version.php | 2 +- 15 files changed, 264 insertions(+), 54 deletions(-) diff --git a/amd/build/designer_section.min.js b/amd/build/designer_section.min.js index 617eb75..85a63a1 100644 --- a/amd/build/designer_section.min.js +++ b/amd/build/designer_section.min.js @@ -5,6 +5,6 @@ * @copyright 2021 bdecent gmbh * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -define("format_designer/designer_section",["jquery","core/fragment","core/templates","core/loadingicon","core/ajax","core_course/actions","core_message/toggle_contact_button","theme_boost/popover"],(function($,Fragment,Templates,Loadingicon,Ajax,Actions,Contact){var SELECTOR={ACTIVITYLI:"li.activity",SECTIONLI:"li.section",ACTIVITYACTION:"a.cm-edit-action",SECTIONACTIONMENU:".section_action_menu.designer-menu"};Y.use("moodle-course-coursebase",(function(){var courseformatselector=M.course.format.get_section_selector();courseformatselector&&(SELECTOR.SECTIONLI=courseformatselector)}));let DesignerSection=function(courseId,contextId,popupActivities){var self=this;self.courseId=courseId,self.contextId=contextId,self.popupActivities=popupActivities,$(".course-info-block .carousel .carousel-item:nth-child(1)").addClass("active"),$(".course-info-block #courseStaffinfoControls.carousel").addClass("active"),$("body").delegate(self.SectionController,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.RestrictInfo,"click",self.moduleHandler.bind(this)),$("body").delegate(self.sectionRestricted,"click",this.sectionRestrictHandler.bind(this)),$("body").delegate(self.fullDescription,"click",self.fullmodcontentHandler.bind(this)),$("body").delegate(self.trimDescription,"click",self.trimmodcontentHandler.bind(this)),$("body").delegate(self.goToURL,"click",self.redirectToModule.bind(this)),$("body").delegate(self.goToSectionURL,"click",self.redirectToSection.bind(this)),window.onhashchange=function(){self.expandSection()},this.expandSection(),$(".course-type-flow").length>0&&$(".collapse").on("show.bs.collapse",(function(){$(this).parents("li.section").addClass("stack-header-collapsing");var sectionid=$(this).parents("li.section").attr("id"),distance=document.getElementById(sectionid).offsetTop-document.body.scrollTop;setTimeout((()=>window.scroll(0,distance)),50)})).on("shown.bs.collapse",(function(){$(this).parents("li.section").removeClass("stack-header-collapsing")}));var contactModal=document.getElementsByClassName("toggle-contact-button");Array.from(contactModal).forEach((function(element){element.addEventListener("click",(function(e){e.preventDefault(),null!=e.currentTarget.dataset.userid&&Contact.enhance(e.currentTarget)}))})),$('.progress .progress-bar[data-toggle="popover"]').popover()};return DesignerSection.prototype.goToURL='.designer [data-action="go-to-url"]',DesignerSection.prototype.goToSectionURL='.designer [data-action="go-to-section-url"]',DesignerSection.prototype.SectionController=".designer #section-designer-action .dropdown-menu a",DesignerSection.prototype.RestrictInfo=".designer .designer-section-content .call-action-block",DesignerSection.prototype.moduleBlock=".designer .designer-section-content li.activity",DesignerSection.prototype.loadingElement=".icon-loader-block",DesignerSection.prototype.sectionRestricted=".designer .availability-section-block .section-restricted-action",DesignerSection.prototype.fullDescription=".designer-section-content li .fullcontent-summary .mod-description-action",DesignerSection.prototype.trimDescription=".designer-section-content li .trim-summary .mod-description-action",DesignerSection.prototype.modules=null,DesignerSection.prototype.redirectToModule=function(event){let nodeName=event.target.nodeName,iscircle=event.target.closest("li.activity").classList.contains("circle-layout"),isDescription=event.target.classList.contains("mod-description-action"),isPadlock=event.target.classList.contains("fa-lock"),ispopupModule=event.target.closest("li.activity").classList.contains("popmodule");if(nodeName in["a","button","form"]||document.body.classList.contains("editing")||iscircle||isDescription||isPadlock||ispopupModule){if(ispopupModule&&!document.body.classList.contains("editing"))event.target.closest("li.activity").querySelector("a[href]").click();return null}let modurl=event.target.closest("[data-action=go-to-url]").getAttribute("data-url");return window.location.href=modurl,!0},DesignerSection.prototype.redirectToSection=function(event){let isPadlock=event.target.classList.contains("fa-lock");if(document.body.classList.contains("editing")||isPadlock)return null;let sectionurl=event.target.closest("[data-action=go-to-section-url]").getAttribute("data-url");return window.location.href=sectionurl,!0},DesignerSection.prototype.expandSection=()=>{var sectionID=window.location.hash;if(sectionID){var id=sectionID.substring(1),section=document.getElementById(id);if(section){var title=section.querySelector(".section-header-content");title&&(title.classList.remove("collapsed"),title.setAttribute("aria-expanded",!0));var content=section.querySelector(".content");content&&content.classList.add("show"),null!==document.getElementById("section-course-accordion")&&(document.getElementById("section-head-0").classList.add("collapsed"),document.getElementById("section-content-0").classList.remove("show")),section.scrollIntoView()}}},DesignerSection.prototype.fullmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");trimcontent.hasClass("summary-hide")&&(trimcontent.removeClass("summary-hide"),fullContent.addClass("summary-hide"))},DesignerSection.prototype.trimmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");fullContent.hasClass("summary-hide")&&(fullContent.removeClass("summary-hide"),trimcontent.addClass("summary-hide"))},DesignerSection.prototype.sectionRestrictHandler=function(event){var sectionRestrictInfo=$(event.currentTarget).prev();sectionRestrictInfo&&(sectionRestrictInfo.hasClass("show")?sectionRestrictInfo.removeClass("show"):sectionRestrictInfo.addClass("show"))},DesignerSection.prototype.moduleHandler=function(event){event.preventDefault();var restrictBlock=$(event.currentTarget).parents(".restrict-block");restrictBlock.length&&(restrictBlock.hasClass("show")?restrictBlock.removeClass("show"):restrictBlock.addClass("show"))},DesignerSection.prototype.sectionLayoutaction=function(event){let sectionId=event.target.closest("li.section").getAttribute("id");var iconBlock="#"+sectionId+" "+this.loadingElement,layout=$(event.currentTarget).data("value"),layouttext=$(event.currentTarget).text();$(event.target).parents(".dropdown").find(".btn").html(layouttext),$(event.target).parents(".dropdown").find(".btn").val(layout),$(event.target).parent().find("a.dropdown-item").each((function(){$(this).removeClass("active")})),$(event.target).addClass("active");let dataid=event.target.closest("li.section").getAttribute("data-id");var args={courseid:this.courseId,sectionid:dataid,options:[{name:$(event.currentTarget).data("option"),value:layout}]},promises=Ajax.call([{methodname:"format_designer_set_section_options",args:args}],!0);$.when.apply($,promises).done((function(){Actions.refreshSection("#"+sectionId,dataid,0).then((()=>"")).catch()})),Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock,promises)},{init:function(courseId,contextId,popupActivities){return new DesignerSection(courseId,contextId,popupActivities)}}})); +define("format_designer/designer_section",["jquery","core/fragment","core/templates","core/loadingicon","core/ajax","core_course/actions","core_message/toggle_contact_button","theme_boost/popover"],(function($,Fragment,Templates,Loadingicon,Ajax,Actions,Contact){var SELECTOR={ACTIVITYLI:"li.activity",SECTIONLI:"li.section",ACTIVITYACTION:"a.cm-edit-action",SECTIONACTIONMENU:".section_action_menu.designer-menu"};Y.use("moodle-course-coursebase",(function(){var courseformatselector=M.course.format.get_section_selector();courseformatselector&&(SELECTOR.SECTIONLI=courseformatselector)}));let DesignerSection=function(courseId,contextId,popupActivities){var self=this;self.courseId=courseId,self.contextId=contextId,self.popupActivities=popupActivities,$(".course-info-block .carousel .carousel-item:nth-child(1)").addClass("active"),$(".course-info-block #courseStaffinfoControls.carousel").addClass("active"),$("body").delegate(self.SectionController,"click",self.sectionLayoutaction.bind(this)),$("body").delegate(self.RestrictInfo,"click",self.moduleHandler.bind(this)),$("body").delegate(self.sectionRestricted,"click",this.sectionRestrictHandler.bind(this)),$("body").delegate(self.fullDescription,"click",self.fullmodcontentHandler.bind(this)),$("body").delegate(self.trimDescription,"click",self.trimmodcontentHandler.bind(this)),$("body").delegate(self.goToURL,"click",self.redirectToModule.bind(this)),$("body").delegate(self.goToSectionURL,"click",self.redirectToSection.bind(this)),window.onhashchange=function(){self.expandSection()},this.expandSection(),$(".course-type-flow").length>0&&$(".collapse").on("show.bs.collapse",(function(){$(this).parents("li.section").addClass("stack-header-collapsing");var sectionid=$(this).parents("li.section").attr("id"),distance=document.getElementById(sectionid).offsetTop-document.body.scrollTop;setTimeout((()=>window.scroll(0,distance)),50)})).on("shown.bs.collapse",(function(){$(this).parents("li.section").removeClass("stack-header-collapsing")}));var contactModal=document.getElementsByClassName("toggle-contact-button");Array.from(contactModal).forEach((function(element){element.addEventListener("click",(function(e){e.preventDefault(),null!=e.currentTarget.dataset.userid&&Contact.enhance(e.currentTarget)}))})),$('.progress .progress-bar[data-toggle="popover"]').popover()};return DesignerSection.prototype.goToURL='.designer [data-action="go-to-url"]',DesignerSection.prototype.goToSectionURL='.designer [data-action="go-to-section-url"]',DesignerSection.prototype.SectionController=".designer #section-designer-action .dropdown-menu a",DesignerSection.prototype.RestrictInfo=".designer .designer-section-content .call-action-block",DesignerSection.prototype.moduleBlock=".designer .designer-section-content li.activity",DesignerSection.prototype.loadingElement=".icon-loader-block",DesignerSection.prototype.sectionRestricted=".designer .availability-section-block .section-restricted-action",DesignerSection.prototype.fullDescription=".designer-section-content li .fullcontent-summary .mod-description-action",DesignerSection.prototype.trimDescription=".designer-section-content li .trim-summary .mod-description-action",DesignerSection.prototype.modules=null,DesignerSection.prototype.redirectToModule=function(event){let nodeName=event.target.nodeName,iscircle=event.target.closest("li.activity").classList.contains("circle-layout"),isDescription=event.target.classList.contains("mod-description-action"),isPadlock=event.target.classList.contains("fa-lock"),ispopupModule=event.target.closest("li.activity").classList.contains("popmodule");if(nodeName in["a","button","form"]||document.body.classList.contains("editing")||iscircle||isDescription||isPadlock||ispopupModule){if(ispopupModule&&!document.body.classList.contains("editing"))if(null==event.target.closest("button[data-action='toggle-manual-completion']")&&null==event.target.closest(".mod-description-action"))event.target.closest("li.activity").querySelector("a[href]").click();return null}let modurl=event.target.closest("[data-action=go-to-url]").getAttribute("data-url");return window.location.href=modurl,!0},DesignerSection.prototype.redirectToSection=function(event){let isPadlock=event.target.classList.contains("fa-lock");if(document.body.classList.contains("editing")||isPadlock)return null;let sectionurl=event.target.closest("[data-action=go-to-section-url]").getAttribute("data-url");return window.location.href=sectionurl,!0},DesignerSection.prototype.expandSection=()=>{var sectionID=window.location.hash;if(sectionID){var id=sectionID.substring(1),section=document.getElementById(id);if(section){var title=section.querySelector(".section-header-content");title&&(title.classList.remove("collapsed"),title.setAttribute("aria-expanded",!0));var content=section.querySelector(".content");content&&content.classList.add("show"),null!==document.getElementById("section-course-accordion")&&(document.getElementById("section-head-0").classList.add("collapsed"),document.getElementById("section-content-0").classList.remove("show")),section.scrollIntoView()}}},DesignerSection.prototype.fullmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");trimcontent.hasClass("summary-hide")&&(trimcontent.removeClass("summary-hide"),fullContent.addClass("summary-hide"))},DesignerSection.prototype.trimmodcontentHandler=function(event){var THIS=$(event.currentTarget);let fullContent=$(THIS).closest("li.activity").find(".fullcontent-summary"),trimcontent=$(THIS).closest("li.activity").find(".trim-summary");fullContent.hasClass("summary-hide")&&(fullContent.removeClass("summary-hide"),trimcontent.addClass("summary-hide"))},DesignerSection.prototype.sectionRestrictHandler=function(event){var sectionRestrictInfo=$(event.currentTarget).prev();sectionRestrictInfo&&(sectionRestrictInfo.hasClass("show")?sectionRestrictInfo.removeClass("show"):sectionRestrictInfo.addClass("show"))},DesignerSection.prototype.moduleHandler=function(event){event.preventDefault();var restrictBlock=$(event.currentTarget).parents(".restrict-block");restrictBlock.length&&(restrictBlock.hasClass("show")?restrictBlock.removeClass("show"):restrictBlock.addClass("show"))},DesignerSection.prototype.sectionLayoutaction=function(event){let sectionId=event.target.closest("li.section").getAttribute("id");var iconBlock="#"+sectionId+" "+this.loadingElement,layout=$(event.currentTarget).data("value"),layouttext=$(event.currentTarget).text();$(event.target).parents(".dropdown").find(".btn").html(layouttext),$(event.target).parents(".dropdown").find(".btn").val(layout),$(event.target).parent().find("a.dropdown-item").each((function(){$(this).removeClass("active")})),$(event.target).addClass("active");let dataid=event.target.closest("li.section").getAttribute("data-id");var args={courseid:this.courseId,sectionid:dataid,options:[{name:$(event.currentTarget).data("option"),value:layout}]},promises=Ajax.call([{methodname:"format_designer_set_section_options",args:args}],!0);$.when.apply($,promises).done((function(){Actions.refreshSection("#"+sectionId,dataid,0).then((()=>"")).catch()})),Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock,promises)},{init:function(courseId,contextId,popupActivities){return new DesignerSection(courseId,contextId,popupActivities)}}})); //# sourceMappingURL=designer_section.min.js.map \ No newline at end of file diff --git a/amd/build/designer_section.min.js.map b/amd/build/designer_section.min.js.map index a10d07a..003639f 100644 --- a/amd/build/designer_section.min.js.map +++ b/amd/build/designer_section.min.js.map @@ -1 +1 @@ -{"version":3,"file":"designer_section.min.js","sources":["../src/designer_section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\r\n//\r\n// Moodle is free software: you can redistribute it and/or modify\r\n// it under the terms of the GNU General Public License as published by\r\n// the Free Software Foundation, either version 3 of the License, or\r\n// (at your option) any later version.\r\n//\r\n// Moodle is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n// GNU General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with Moodle. If not, see .\r\n\r\n/**\r\n * Implemented designer format js.\r\n *\r\n * @module format_designer/designer_section\r\n * @copyright 2021 bdecent gmbh \r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n define(['jquery', 'core/fragment', 'core/templates', 'core/loadingicon', 'core/ajax',\r\n 'core_course/actions', 'core_message/toggle_contact_button', 'theme_boost/popover'],\r\n function($, Fragment, Templates, Loadingicon, Ajax, Actions, Contact) {\r\n\r\n var SELECTOR = {\r\n ACTIVITYLI: 'li.activity',\r\n SECTIONLI: 'li.section',\r\n ACTIVITYACTION: 'a.cm-edit-action',\r\n SECTIONACTIONMENU: '.section_action_menu.designer-menu',\r\n };\r\n\r\n Y.use('moodle-course-coursebase', function() {\r\n var courseformatselector = M.course.format.get_section_selector();\r\n if (courseformatselector) {\r\n SELECTOR.SECTIONLI = courseformatselector;\r\n }\r\n });\r\n\r\n\r\n /**\r\n * Control designer format action\r\n * @param {int} courseId\r\n * @param {int} contextId\r\n * @param {array} popupActivities\r\n */\r\n let DesignerSection = function(courseId, contextId, popupActivities) {\r\n var self = this;\r\n self.courseId = courseId;\r\n self.contextId = contextId;\r\n self.popupActivities = popupActivities;\r\n\r\n $(\".course-info-block .carousel .carousel-item:nth-child(1)\").addClass('active');\r\n $(\".course-info-block #courseStaffinfoControls.carousel\").addClass('active');\r\n\r\n $('body').delegate(self.SectionController, 'click', self.sectionLayoutaction.bind(this));\r\n $(\"body\").delegate(self.RestrictInfo, \"click\", self.moduleHandler.bind(this));\r\n $(\"body\").delegate(self.sectionRestricted, \"click\", this.sectionRestrictHandler.bind(this));\r\n $('body').delegate(self.fullDescription, \"click\", self.fullmodcontentHandler.bind(this));\r\n $('body').delegate(self.trimDescription, \"click\", self.trimmodcontentHandler.bind(this));\r\n $('body').delegate(self.goToURL, \"click\", self.redirectToModule.bind(this));\r\n $('body').delegate(self.goToSectionURL, \"click\", self.redirectToSection.bind(this));\r\n window.onhashchange = function() {\r\n self.expandSection();\r\n };\r\n this.expandSection();\r\n\r\n if ($('.course-type-flow').length > 0) {\r\n $('.collapse').on('show.bs.collapse', function() {\r\n $(this).parents('li.section').addClass('stack-header-collapsing');\r\n var sectionid = $(this).parents('li.section').attr('id');\r\n var section = document.getElementById(sectionid);\r\n var distance = section.offsetTop - document.body.scrollTop;\r\n setTimeout(() => window.scroll(0, distance), 50);\r\n }).on('shown.bs.collapse', function() {\r\n $(this).parents('li.section').removeClass('stack-header-collapsing');\r\n });\r\n }\r\n\r\n var contactModal = document.getElementsByClassName('toggle-contact-button');\r\n Array.from(contactModal).forEach(function(element) {\r\n element.addEventListener('click', function(e) {\r\n e.preventDefault();\r\n if (e.currentTarget.dataset.userid != undefined) {\r\n Contact.enhance(e.currentTarget);\r\n }\r\n });\r\n });\r\n\r\n $('.progress .progress-bar[data-toggle=\"popover\"]').popover();\r\n\r\n };\r\n\r\n /**\r\n * Selector section controller.\r\n */\r\n DesignerSection.prototype.goToURL = '.designer [data-action=\"go-to-url\"]';\r\n\r\n DesignerSection.prototype.goToSectionURL = '.designer [data-action=\"go-to-section-url\"]';\r\n\r\n DesignerSection.prototype.SectionController = \".designer #section-designer-action .dropdown-menu a\";\r\n\r\n DesignerSection.prototype.RestrictInfo = \".designer .designer-section-content .call-action-block\";\r\n\r\n DesignerSection.prototype.moduleBlock = \".designer .designer-section-content li.activity\";\r\n\r\n DesignerSection.prototype.loadingElement = \".icon-loader-block\";\r\n\r\n DesignerSection.prototype.sectionRestricted = \".designer .availability-section-block .section-restricted-action\";\r\n\r\n DesignerSection.prototype.fullDescription = \".designer-section-content li .fullcontent-summary .mod-description-action\";\r\n\r\n DesignerSection.prototype.trimDescription = \".designer-section-content li .trim-summary .mod-description-action\";\r\n\r\n DesignerSection.prototype.modules = null;\r\n\r\n DesignerSection.prototype.redirectToModule = function(event) {\r\n let nodeName = event.target.nodeName;\r\n let preventionNodes = ['a', 'button', 'form'];\r\n let iscircle = event.target.closest('li.activity').classList.contains('circle-layout');\r\n let isDescription = event.target.classList.contains('mod-description-action');\r\n let isPadlock = event.target.classList.contains('fa-lock');\r\n let ispopupModule = event.target.closest('li.activity').classList.contains('popmodule');\r\n if ((nodeName in preventionNodes)\r\n || document.body.classList.contains('editing') || iscircle || isDescription || isPadlock || ispopupModule) {\r\n if (ispopupModule && !document.body.classList.contains('editing')) {\r\n var li = event.target.closest('li.activity');\r\n li.querySelector('a[href]').click();\r\n // event.target.closest('a').click();\r\n }\r\n return null;\r\n }\r\n var card = event.target.closest(\"[data-action=go-to-url]\");\r\n let modurl = card.getAttribute('data-url');\r\n window.location.href = modurl;\r\n return true;\r\n };\r\n\r\n DesignerSection.prototype.redirectToSection = function(event) {\r\n let isPadlock = event.target.classList.contains('fa-lock');\r\n if (document.body.classList.contains('editing') || isPadlock) {\r\n return null;\r\n }\r\n var singlesection = event.target.closest(\"[data-action=go-to-section-url]\")\r\n let sectionurl = singlesection.getAttribute('data-url');\r\n window.location.href = sectionurl;\r\n return true;\r\n }\r\n\r\n DesignerSection.prototype.expandSection = () => {\r\n var sectionID = window.location.hash;\r\n if (sectionID) {\r\n var id = sectionID.substring(1);\r\n var section = document.getElementById(id);\r\n if (section) {\r\n var title = section.querySelector('.section-header-content');\r\n if (title) {\r\n title.classList.remove('collapsed');\r\n title.setAttribute('aria-expanded', true);\r\n }\r\n var content = section.querySelector('.content');\r\n if (content) {\r\n content.classList.add('show');\r\n }\r\n if (document.getElementById('section-course-accordion') !== null) {\r\n document.getElementById('section-head-0').classList.add('collapsed');\r\n document.getElementById('section-content-0').classList.remove('show');\r\n }\r\n section.scrollIntoView();\r\n }\r\n }\r\n };\r\n\r\n DesignerSection.prototype.fullmodcontentHandler = function(event) {\r\n var THIS = $(event.currentTarget);\r\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\r\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\r\n if (trimcontent.hasClass('summary-hide')) {\r\n trimcontent.removeClass('summary-hide');\r\n fullContent.addClass('summary-hide');\r\n }\r\n };\r\n\r\n DesignerSection.prototype.trimmodcontentHandler = function(event) {\r\n var THIS = $(event.currentTarget);\r\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\r\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\r\n if (fullContent.hasClass('summary-hide')) {\r\n fullContent.removeClass('summary-hide');\r\n trimcontent.addClass('summary-hide');\r\n }\r\n };\r\n\r\n DesignerSection.prototype.sectionRestrictHandler = function(event) {\r\n var sectionRestrictInfo = $(event.currentTarget).prev();\r\n if (sectionRestrictInfo) {\r\n if (!sectionRestrictInfo.hasClass('show')) {\r\n sectionRestrictInfo.addClass('show');\r\n } else {\r\n sectionRestrictInfo.removeClass('show');\r\n }\r\n }\r\n };\r\n\r\n DesignerSection.prototype.moduleHandler = function(event) {\r\n event.preventDefault();\r\n var restrictBlock = $(event.currentTarget).parents('.restrict-block');\r\n if (restrictBlock.length) {\r\n if (!restrictBlock.hasClass('show')) {\r\n restrictBlock.addClass('show');\r\n } else {\r\n restrictBlock.removeClass('show');\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Implementaion swith the section layout.\r\n * @param {object} event\r\n */\r\n DesignerSection.prototype.sectionLayoutaction = function(event) {\r\n var self = this;\r\n let sectionId = event.target.closest('li.section').getAttribute('id');\r\n var iconBlock = \"#\" + sectionId + \" \" + self.loadingElement;\r\n var layout = $(event.currentTarget).data('value');\r\n var layouttext = $(event.currentTarget).text();\r\n $(event.target).parents(\".dropdown\").find(\".btn\").html(layouttext);\r\n $(event.target).parents(\".dropdown\").find(\".btn\").val(layout);\r\n $(event.target).parent().find(\"a.dropdown-item\").each(function() {\r\n $(this).removeClass('active');\r\n });\r\n $(event.target).addClass('active');\r\n let dataid = event.target.closest('li.section').getAttribute('data-id');\r\n var args = {\r\n courseid: self.courseId,\r\n sectionid: dataid,\r\n options: [{name: $(event.currentTarget).data('option'), value: layout}]\r\n };\r\n var promises = Ajax.call([{\r\n methodname: 'format_designer_set_section_options',\r\n args: args\r\n }], true);\r\n $.when.apply($, promises)\r\n .done(function() {\r\n const sectionpromise = Actions.refreshSection('#' + sectionId, dataid, 0);\r\n sectionpromise.then(() => {\r\n return '';\r\n }).catch();\r\n });\r\n Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock, promises);\r\n };\r\n\r\n return {\r\n init: function(courseId, contextId, popupActivities) {\r\n return new DesignerSection(courseId, contextId, popupActivities);\r\n }\r\n };\r\n});\r\n"],"names":["define","$","Fragment","Templates","Loadingicon","Ajax","Actions","Contact","SELECTOR","ACTIVITYLI","SECTIONLI","ACTIVITYACTION","SECTIONACTIONMENU","Y","use","courseformatselector","M","course","format","get_section_selector","DesignerSection","courseId","contextId","popupActivities","self","this","addClass","delegate","SectionController","sectionLayoutaction","bind","RestrictInfo","moduleHandler","sectionRestricted","sectionRestrictHandler","fullDescription","fullmodcontentHandler","trimDescription","trimmodcontentHandler","goToURL","redirectToModule","goToSectionURL","redirectToSection","window","onhashchange","expandSection","length","on","parents","sectionid","attr","distance","document","getElementById","offsetTop","body","scrollTop","setTimeout","scroll","removeClass","contactModal","getElementsByClassName","Array","from","forEach","element","addEventListener","e","preventDefault","undefined","currentTarget","dataset","userid","enhance","popover","prototype","moduleBlock","loadingElement","modules","event","nodeName","target","iscircle","closest","classList","contains","isDescription","isPadlock","ispopupModule","querySelector","click","modurl","getAttribute","location","href","sectionurl","sectionID","hash","id","substring","section","title","remove","setAttribute","content","add","scrollIntoView","THIS","fullContent","find","trimcontent","hasClass","sectionRestrictInfo","prev","restrictBlock","sectionId","iconBlock","layout","data","layouttext","text","html","val","parent","each","dataid","args","courseid","options","name","value","promises","call","methodname","when","apply","done","refreshSection","then","catch","addIconToContainerRemoveOnCompletion","init"],"mappings":";;;;;;;AAsBCA,0CAAO,CAAC,SAAU,gBAAiB,iBAAkB,mBAAoB,YACtE,sBAAuB,qCAAsC,wBAChE,SAASC,EAAGC,SAAUC,UAAWC,YAAaC,KAAMC,QAASC,aAEtDC,SAAW,CACXC,WAAY,cACZC,UAAW,aACXC,eAAgB,mBAChBC,kBAAmB,sCAGvBC,EAAEC,IAAI,4BAA4B,eAC1BC,qBAAuBC,EAAEC,OAAOC,OAAOC,uB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A,MAAMX,qBACF8C,cAAgBjH,EAAE8E,MAAMT,eAAetB,QAAQ,mBAC/CkE,cAAcpE,SACToE,cAAcH,SAAS,QAGxBG,cAAcvD,YAAY,QAF1BuD,cAAcxF,SAAS,UAWnCN,gBAAgBuD,UAAU9C,oBAAsB,SAASkD,WAEjDoC,UAAYpC,MAAME,OAAOE,QAAQ,cAAcS,aAAa,UAC5DwB,UAAY,IAAMD,UAAY,IAFvB1F,KAEkCoD,eACzCwC,OAASpH,EAAE8E,MAAMT,eAAegD,KAAK,SACrCC,WAAatH,EAAE8E,MAAMT,eAAekD,OACxCvH,EAAE8E,MAAME,QAAQjC,QAAQ,aAAa6D,KAAK,QAAQY,KAAKF,YACvDtH,EAAE8E,MAAME,QAAQjC,QAAQ,aAAa6D,KAAK,QAAQa,IAAIL,QACtDpH,EAAE8E,MAAME,QAAQ0C,SAASd,KAAK,mBAAmBe,MAAK,WAClD3H,EAAEwB,MAAMkC,YAAY,aAExB1D,EAAE8E,MAAME,QAAQvD,SAAS,cACrBmG,OAAS9C,MAAME,OAAOE,QAAQ,cAAcS,aAAa,eACzDkC,KAAO,CACPC,SAbOtG,KAaQJ,SACf4B,UAAW4E,OACXG,QAAS,CAAC,CAACC,KAAMhI,EAAE8E,MAAMT,eAAegD,KAAK,UAAWY,MAAOb,UAE/Dc,SAAW9H,KAAK+H,KAAK,CAAC,CAClBC,WAAY,sCACZP,KAAMA,QACN,GACJ7H,EAAEqI,KAAKC,MAAMtI,EAAGkI,UACfK,MAAK,WACqBlI,QAAQmI,eAAe,IAAMtB,UAAWU,OAAQ,GACxDa,MAAK,IACV,KACPC,WAEXvI,YAAYwI,qCAAqCxB,UAAWe,WAGzD,CACHU,KAAM,SAASxH,SAAUC,UAAWC,wBACzB,IAAIH,gBAAgBC,SAAUC,UAAWC"} \ No newline at end of file +{"version":3,"file":"designer_section.min.js","sources":["../src/designer_section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\r\n//\r\n// Moodle is free software: you can redistribute it and/or modify\r\n// it under the terms of the GNU General Public License as published by\r\n// the Free Software Foundation, either version 3 of the License, or\r\n// (at your option) any later version.\r\n//\r\n// Moodle is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n// GNU General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with Moodle. If not, see .\r\n\r\n/**\r\n * Implemented designer format js.\r\n *\r\n * @module format_designer/designer_section\r\n * @copyright 2021 bdecent gmbh \r\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r\n */\r\n define(['jquery', 'core/fragment', 'core/templates', 'core/loadingicon', 'core/ajax',\r\n 'core_course/actions', 'core_message/toggle_contact_button', 'theme_boost/popover'],\r\n function($, Fragment, Templates, Loadingicon, Ajax, Actions, Contact) {\r\n\r\n var SELECTOR = {\r\n ACTIVITYLI: 'li.activity',\r\n SECTIONLI: 'li.section',\r\n ACTIVITYACTION: 'a.cm-edit-action',\r\n SECTIONACTIONMENU: '.section_action_menu.designer-menu',\r\n };\r\n\r\n Y.use('moodle-course-coursebase', function() {\r\n var courseformatselector = M.course.format.get_section_selector();\r\n if (courseformatselector) {\r\n SELECTOR.SECTIONLI = courseformatselector;\r\n }\r\n });\r\n\r\n\r\n /**\r\n * Control designer format action\r\n * @param {int} courseId\r\n * @param {int} contextId\r\n * @param {array} popupActivities\r\n */\r\n let DesignerSection = function(courseId, contextId, popupActivities) {\r\n var self = this;\r\n self.courseId = courseId;\r\n self.contextId = contextId;\r\n self.popupActivities = popupActivities;\r\n\r\n $(\".course-info-block .carousel .carousel-item:nth-child(1)\").addClass('active');\r\n $(\".course-info-block #courseStaffinfoControls.carousel\").addClass('active');\r\n\r\n $('body').delegate(self.SectionController, 'click', self.sectionLayoutaction.bind(this));\r\n $(\"body\").delegate(self.RestrictInfo, \"click\", self.moduleHandler.bind(this));\r\n $(\"body\").delegate(self.sectionRestricted, \"click\", this.sectionRestrictHandler.bind(this));\r\n $('body').delegate(self.fullDescription, \"click\", self.fullmodcontentHandler.bind(this));\r\n $('body').delegate(self.trimDescription, \"click\", self.trimmodcontentHandler.bind(this));\r\n $('body').delegate(self.goToURL, \"click\", self.redirectToModule.bind(this));\r\n $('body').delegate(self.goToSectionURL, \"click\", self.redirectToSection.bind(this));\r\n window.onhashchange = function() {\r\n self.expandSection();\r\n };\r\n this.expandSection();\r\n\r\n if ($('.course-type-flow').length > 0) {\r\n $('.collapse').on('show.bs.collapse', function() {\r\n $(this).parents('li.section').addClass('stack-header-collapsing');\r\n var sectionid = $(this).parents('li.section').attr('id');\r\n var section = document.getElementById(sectionid);\r\n var distance = section.offsetTop - document.body.scrollTop;\r\n setTimeout(() => window.scroll(0, distance), 50);\r\n }).on('shown.bs.collapse', function() {\r\n $(this).parents('li.section').removeClass('stack-header-collapsing');\r\n });\r\n }\r\n\r\n var contactModal = document.getElementsByClassName('toggle-contact-button');\r\n Array.from(contactModal).forEach(function(element) {\r\n element.addEventListener('click', function(e) {\r\n e.preventDefault();\r\n if (e.currentTarget.dataset.userid != undefined) {\r\n Contact.enhance(e.currentTarget);\r\n }\r\n });\r\n });\r\n\r\n $('.progress .progress-bar[data-toggle=\"popover\"]').popover();\r\n\r\n };\r\n\r\n /**\r\n * Selector section controller.\r\n */\r\n DesignerSection.prototype.goToURL = '.designer [data-action=\"go-to-url\"]';\r\n\r\n DesignerSection.prototype.goToSectionURL = '.designer [data-action=\"go-to-section-url\"]';\r\n\r\n DesignerSection.prototype.SectionController = \".designer #section-designer-action .dropdown-menu a\";\r\n\r\n DesignerSection.prototype.RestrictInfo = \".designer .designer-section-content .call-action-block\";\r\n\r\n DesignerSection.prototype.moduleBlock = \".designer .designer-section-content li.activity\";\r\n\r\n DesignerSection.prototype.loadingElement = \".icon-loader-block\";\r\n\r\n DesignerSection.prototype.sectionRestricted = \".designer .availability-section-block .section-restricted-action\";\r\n\r\n DesignerSection.prototype.fullDescription = \".designer-section-content li .fullcontent-summary .mod-description-action\";\r\n\r\n DesignerSection.prototype.trimDescription = \".designer-section-content li .trim-summary .mod-description-action\";\r\n\r\n DesignerSection.prototype.modules = null;\r\n\r\n DesignerSection.prototype.redirectToModule = function(event) {\r\n let nodeName = event.target.nodeName;\r\n let preventionNodes = ['a', 'button', 'form'];\r\n let iscircle = event.target.closest('li.activity').classList.contains('circle-layout');\r\n let isDescription = event.target.classList.contains('mod-description-action');\r\n let isPadlock = event.target.classList.contains('fa-lock');\r\n let ispopupModule = event.target.closest('li.activity').classList.contains('popmodule');\r\n if ((nodeName in preventionNodes)\r\n || document.body.classList.contains('editing') || iscircle || isDescription || isPadlock || ispopupModule) {\r\n if (ispopupModule && !document.body.classList.contains('editing')) {\r\n if (event.target.closest(\"button[data-action='toggle-manual-completion']\") == null && event.target.closest(\".mod-description-action\") == null) {\r\n var li = event.target.closest('li.activity');\r\n li.querySelector('a[href]').click();\r\n }\r\n // event.target.closest('a').click();\r\n }\r\n return null;\r\n }\r\n var card = event.target.closest(\"[data-action=go-to-url]\");\r\n let modurl = card.getAttribute('data-url');\r\n window.location.href = modurl;\r\n return true;\r\n };\r\n\r\n DesignerSection.prototype.redirectToSection = function(event) {\r\n let isPadlock = event.target.classList.contains('fa-lock');\r\n if (document.body.classList.contains('editing') || isPadlock) {\r\n return null;\r\n }\r\n var singlesection = event.target.closest(\"[data-action=go-to-section-url]\")\r\n let sectionurl = singlesection.getAttribute('data-url');\r\n window.location.href = sectionurl;\r\n return true;\r\n }\r\n\r\n DesignerSection.prototype.expandSection = () => {\r\n var sectionID = window.location.hash;\r\n if (sectionID) {\r\n var id = sectionID.substring(1);\r\n var section = document.getElementById(id);\r\n if (section) {\r\n var title = section.querySelector('.section-header-content');\r\n if (title) {\r\n title.classList.remove('collapsed');\r\n title.setAttribute('aria-expanded', true);\r\n }\r\n var content = section.querySelector('.content');\r\n if (content) {\r\n content.classList.add('show');\r\n }\r\n if (document.getElementById('section-course-accordion') !== null) {\r\n document.getElementById('section-head-0').classList.add('collapsed');\r\n document.getElementById('section-content-0').classList.remove('show');\r\n }\r\n section.scrollIntoView();\r\n }\r\n }\r\n };\r\n\r\n DesignerSection.prototype.fullmodcontentHandler = function(event) {\r\n var THIS = $(event.currentTarget);\r\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\r\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\r\n if (trimcontent.hasClass('summary-hide')) {\r\n trimcontent.removeClass('summary-hide');\r\n fullContent.addClass('summary-hide');\r\n }\r\n };\r\n\r\n DesignerSection.prototype.trimmodcontentHandler = function(event) {\r\n var THIS = $(event.currentTarget);\r\n let fullContent = $(THIS).closest('li.activity').find('.fullcontent-summary');\r\n let trimcontent = $(THIS).closest('li.activity').find('.trim-summary');\r\n if (fullContent.hasClass('summary-hide')) {\r\n fullContent.removeClass('summary-hide');\r\n trimcontent.addClass('summary-hide');\r\n }\r\n };\r\n\r\n DesignerSection.prototype.sectionRestrictHandler = function(event) {\r\n var sectionRestrictInfo = $(event.currentTarget).prev();\r\n if (sectionRestrictInfo) {\r\n if (!sectionRestrictInfo.hasClass('show')) {\r\n sectionRestrictInfo.addClass('show');\r\n } else {\r\n sectionRestrictInfo.removeClass('show');\r\n }\r\n }\r\n };\r\n\r\n DesignerSection.prototype.moduleHandler = function(event) {\r\n event.preventDefault();\r\n var restrictBlock = $(event.currentTarget).parents('.restrict-block');\r\n if (restrictBlock.length) {\r\n if (!restrictBlock.hasClass('show')) {\r\n restrictBlock.addClass('show');\r\n } else {\r\n restrictBlock.removeClass('show');\r\n }\r\n }\r\n };\r\n\r\n /**\r\n * Implementaion swith the section layout.\r\n * @param {object} event\r\n */\r\n DesignerSection.prototype.sectionLayoutaction = function(event) {\r\n var self = this;\r\n let sectionId = event.target.closest('li.section').getAttribute('id');\r\n var iconBlock = \"#\" + sectionId + \" \" + self.loadingElement;\r\n var layout = $(event.currentTarget).data('value');\r\n var layouttext = $(event.currentTarget).text();\r\n $(event.target).parents(\".dropdown\").find(\".btn\").html(layouttext);\r\n $(event.target).parents(\".dropdown\").find(\".btn\").val(layout);\r\n $(event.target).parent().find(\"a.dropdown-item\").each(function() {\r\n $(this).removeClass('active');\r\n });\r\n $(event.target).addClass('active');\r\n let dataid = event.target.closest('li.section').getAttribute('data-id');\r\n var args = {\r\n courseid: self.courseId,\r\n sectionid: dataid,\r\n options: [{name: $(event.currentTarget).data('option'), value: layout}]\r\n };\r\n var promises = Ajax.call([{\r\n methodname: 'format_designer_set_section_options',\r\n args: args\r\n }], true);\r\n $.when.apply($, promises)\r\n .done(function() {\r\n const sectionpromise = Actions.refreshSection('#' + sectionId, dataid, 0);\r\n sectionpromise.then(() => {\r\n return '';\r\n }).catch();\r\n });\r\n Loadingicon.addIconToContainerRemoveOnCompletion(iconBlock, promises);\r\n };\r\n\r\n return {\r\n init: function(courseId, contextId, popupActivities) {\r\n return new DesignerSection(courseId, contextId, popupActivities);\r\n }\r\n };\r\n});\r\n"],"names":["define","$","Fragment","Templates","Loadingicon","Ajax","Actions","Contact","SELECTOR","ACTIVITYLI","SECTIONLI","ACTIVITYACTION","SECTIONACTIONMENU","Y","use","courseformatselector","M","course","format","get_section_selector","DesignerSection","courseId","contextId","popupActivities","self","this","addClass","delegate","SectionController","sectionLayoutaction","bind","RestrictInfo","moduleHandler","sectionRestricted","sectionRestrictHandler","fullDescription","fullmodcontentHandler","trimDescription","trimmodcontentHandler","goToURL","redirectToModule","goToSectionURL","redirectToSection","window","onhashchange","expandSection","length","on","parents","sectionid","attr","distance","document","getElementById","offsetTop","body","scrollTop","setTimeout","scroll","removeClass","contactModal","getElementsByClassName","Array","from","forEach","element","addEventListener","e","preventDefault","undefined","currentTarget","dataset","userid","enhance","popover","prototype","moduleBlock","loadingElement","modules","event","nodeName","target","iscircle","closest","classList","contains","isDescription","isPadlock","ispopupModule","querySelector","click","modurl","getAttribute","location","href","sectionurl","sectionID","hash","id","substring","section","title","remove","setAttribute","content","add","scrollIntoView","THIS","fullContent","find","trimcontent","hasClass","sectionRestrictInfo","prev","restrictBlock","sectionId","iconBlock","layout","data","layouttext","text","html","val","parent","each","dataid","args","courseid","options","name","value","promises","call","methodname","when","apply","done","refreshSection","then","catch","addIconToContainerRemoveOnCompletion","init"],"mappings":";;;;;;;AAsBCA,0CAAO,CAAC,SAAU,gBAAiB,iBAAkB,mBAAoB,YACtE,sBAAuB,qCAAsC,wBAChE,SAASC,EAAGC,SAAUC,UAAWC,YAAaC,KAAMC,QAASC,aAEtDC,SAAW,CACXC,WAAY,cACZC,UAAW,aACXC,eAAgB,mBAChBC,kBAAmB,sCAGvBC,EAAEC,IAAI,4BAA4B,eAC1BC,qBAAuBC,EAAEC,OAAOC,OAAOC,uBACvCJ,uBACAP,SAASE,UAAYK,6BAWzBK,gBAAkB,SAASC,SAAUC,UAAWC,qBAC5CC,KAAOC,KACXD,KAAKH,SAAWA,SAChBG,KAAKF,UAAYA,UACjBE,KAAKD,gBAAkBA,gBAEvBtB,EAAE,4DAA4DyB,SAAS,UACvEzB,EAAE,wDAAwDyB,SAAS,UAEnEzB,EAAE,QAAQ0B,SAASH,KAAKI,kBAAmB,QAASJ,KAAKK,oBAAoBC,KAAKL,OAClFxB,EAAE,QAAQ0B,SAASH,KAAKO,aAAc,QAASP,KAAKQ,cAAcF,KAAKL,OACvExB,EAAE,QAAQ0B,SAASH,KAAKS,kBAAmB,QAASR,KAAKS,uBAAuBJ,KAAKL,OACrFxB,EAAE,QAAQ0B,SAASH,KAAKW,gBAAiB,QAASX,KAAKY,sBAAsBN,KAAKL,OAClFxB,EAAE,QAAQ0B,SAASH,KAAKa,gBAAiB,QAASb,KAAKc,sBAAsBR,KAAKL,OAClFxB,EAAE,QAAQ0B,SAASH,KAAKe,QAAS,QAASf,KAAKgB,iBAAiBV,KAAKL,OACrExB,EAAE,QAAQ0B,SAASH,KAAKiB,eAAgB,QAASjB,KAAKkB,kBAAkBZ,KAAKL,OAC7EkB,OAAOC,aAAe,WAClBpB,K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C,SAbOtG,KAaQJ,SACf4B,UAAW4E,OACXG,QAAS,CAAC,CAACC,KAAMhI,EAAE8E,MAAMT,eAAegD,KAAK,UAAWY,MAAOb,UAE/Dc,SAAW9H,KAAK+H,KAAK,CAAC,CAClBC,WAAY,sCACZP,KAAMA,QACN,GACJ7H,EAAEqI,KAAKC,MAAMtI,EAAGkI,UACfK,MAAK,WACqBlI,QAAQmI,eAAe,IAAMtB,UAAWU,OAAQ,GACxDa,MAAK,IACV,KACPC,WAEXvI,YAAYwI,qCAAqCxB,UAAWe,WAGzD,CACHU,KAAM,SAASxH,SAAUC,UAAWC,wBACzB,IAAIH,gBAAgBC,SAAUC,UAAWC"} \ No newline at end of file diff --git a/amd/src/designer_section.js b/amd/src/designer_section.js index 4710061..b3b7aaf 100644 --- a/amd/src/designer_section.js +++ b/amd/src/designer_section.js @@ -125,8 +125,10 @@ if ((nodeName in preventionNodes) || document.body.classList.contains('editing') || iscircle || isDescription || isPadlock || ispopupModule) { if (ispopupModule && !document.body.classList.contains('editing')) { - var li = event.target.closest('li.activity'); - li.querySelector('a[href]').click(); + if (event.target.closest("button[data-action='toggle-manual-completion']") == null && event.target.closest(".mod-description-action") == null) { + var li = event.target.closest('li.activity'); + li.querySelector('a[href]').click(); + } // event.target.closest('a').click(); } return null; diff --git a/backup/moodle2/restore_format_designer_plugin.class.php b/backup/moodle2/restore_format_designer_plugin.class.php index 2633e06..eaba67b 100644 --- a/backup/moodle2/restore_format_designer_plugin.class.php +++ b/backup/moodle2/restore_format_designer_plugin.class.php @@ -170,7 +170,9 @@ protected function after_restore_module() { */ protected function after_restore_section() { - $this->add_related_files('format_designer', 'sectiondesignbackground', null); - $this->add_related_files('format_designer', 'sectiondesigncompletionbackground', null); + $files = \format_designer\options::get_file_areas('section'); + foreach ($files as $file => $component) { + $this->add_related_files($component, $file, 'course_section'); + } } } diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 3d88626..f292758 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -102,7 +102,7 @@ public function render_content($widget) { } $data->startclass = implode(' ', $startclass); $data->startid = $startid; - $data->issectionpageclass = (optional_param('section', null, PARAM_INT)) ? 'section-page-layout' : ''; + $data->issectionpageclass = ($data->initialsection->sectionreturnid != 0) ? 'section-page-layout' : ''; if (!format_designer_has_pro()) { $data->timemanagement = $this->timemanagement_details($course); @@ -832,6 +832,8 @@ public function render_section_data(section_info $section, stdClass $course, $on 'stylerules' => $sectionstylerules, 'flowcourse' => isset($course->coursetype) && $course->coursetype == DESIGNER_TYPE_FLOW ? true : false, 'maskimage' => (isset($section->sectiondesignermaskimage) && $section->sectiondesignermaskimage) ? true : false, + 'flowsizeclass' => (isset($course->flowsize) && $course->coursetype == DESIGNER_TYPE_FLOW && + !$this->page->user_is_editing()) ? $this->get_flow_size($course) : '', ]; $zerotohero = $course->sectionzeroactivities; if ($zerotohero == DESIGNER_HERO_ZERO_HIDE && $section->section == 0 && !$this->page->user_is_editing()) { @@ -848,7 +850,8 @@ public function render_section_data(section_info $section, stdClass $course, $on if (isset($mods[$thismod->modname])) { $mods[$thismod->modname]['name'] = $thismod->modplural; if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.png')) { - $mods[$thismod->modname]['activityimgsvg'] = file_get_contents($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.svg'); + $mods[$thismod->modname]['activityimgsvg'] = file_get_contents($CFG->dirroot.'/mod/'.$thismod->modname. + '/pix/monologo.svg'); } else if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/icon.png')) { $mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/icon.png'; } @@ -856,7 +859,8 @@ public function render_section_data(section_info $section, stdClass $course, $on } else { $mods[$thismod->modname]['name'] = $thismod->modfullname; if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.png')) { - $mods[$thismod->modname]['activityimgsvg'] = file_get_contents($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/monologo.svg'); + $mods[$thismod->modname]['activityimgsvg'] = file_get_contents($CFG->dirroot.'/mod/'.$thismod->modname. + '/pix/monologo.svg'); } else if (file_exists($CFG->dirroot.'/mod/'.$thismod->modname.'/pix/icon.png')) { $mods[$thismod->modname]['img'] = $CFG->wwwroot.'/mod/'.$thismod->modname.'/pix/icon.png'; } @@ -938,6 +942,7 @@ public function render_course_module($mod, $sectionreturn, $displayoptions = [], if (!$mod->is_visible_on_course_page()) { return []; } + $dbman = $DB->get_manager(); $modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses; // Add course type flow animation class. @@ -951,6 +956,7 @@ public function render_course_module($mod, $sectionreturn, $displayoptions = [], $modstyle .= sprintf('animation-duration: %ss;', ($duration) ? $duration : '1'); $this->flowdelay = $this->flowdelay + 0.5; } + $modclasses .= isset($course->flowsize) ? $this->get_flow_size($course) : ''; } $ispopupactivities = isset($course->popupactivities) && $course->popupactivities; @@ -977,48 +983,60 @@ class_exists($class) && // (AFTER any icons). Otherwise it was displayed before. $cmtext = ''; $videotime = $mod->modname == 'videotime'; + $isvideotimelabel = false; + $useactivityimagestatus = false; $useactivityimage = ''; if (format_designer_has_pro()) { - if ($mod->modname == 'videotime') { - if ($videorecord = $DB->get_record('videotime', ['id' => $mod->instance])) { - if (isset($videorecord->label_mod) && $videorecord->label_mode == 2) { + if ($mod->modname == 'videotime' && $dbman->table_exists('videotimeplugin_pro')) { + if ($videorecord = $DB->get_record('videotimeplugin_pro', ['videotime' => $mod->instance])) { + if (isset($videorecord->label_mode) && $videorecord->label_mode == 2) { $useactivityimage = \format_designer\options::get_option($mod->id, 'useactivityimage'); + } else if ($videorecord->label_mode == 1) { + $isvideotimelabel = true; } } } $useactivityimagestatus = ($videotime && $useactivityimage); $enableactivityimage = \format_designer\options::get_option($mod->id, 'useactivityimage'); } - if (!empty($url) || (isset($useactivityimagestatus) && $useactivityimagestatus)) { + if (!empty($url) && !$videotime) { $cmtext = $mod->get_formatted_content(['overflowdiv' => true, 'noclean' => true]); if (isset($videotime) && $videotime) { $videotime = $DB->get_record('videotime', ['id' => $mod->instance]); $cmtext = $videotime->intro; } $cmtextcontent = format_string($cmtext); + $cmtextlength = get_config('format_designer', 'activitydesclength'); $modcontent = ''; if (!empty($cmtextcontent)) { - if (str_word_count($cmtextcontent) >= 23) { - $modcontenthtml = ''; - $modcontenthtml .= html_writer::start_tag('div', ['class' => 'trim-summary']); - $modcontenthtml .= format_designer_modcontent_trim_char($cmtextcontent, 24); - $modcontenthtml .= \html_writer::link('javascript:void(0)', get_string('more'), - ['class' => 'mod-description-action']); - $modcontenthtml .= html_writer::end_tag('div'); - $modcontenthtml .= html_writer::start_tag('div', ['class' => 'fullcontent-summary summary-hide']); - $modcontenthtml .= $cmtextcontent; - $modcontenthtml .= " " .\html_writer::link('javascript:void(0)', get_string('less', 'format_designer'), - ['class' => 'mod-description-action']); - $modcontenthtml .= html_writer::end_tag('div'); - $modcontent = $modcontenthtml; + if ($cmtextlength == DESIGNER_MOD_TEXT_TRIMM) { + $trimlenght = get_config('format_designer', 'modtrimlength'); + if (str_word_count($cmtextcontent) >= 23) { + $modcontenthtml = ''; + $modcontenthtml .= html_writer::start_tag('div', ['class' => 'trim-summary']); + $modcontenthtml .= format_designer_modcontent_trim_char($cmtextcontent, $trimlenght); + $modcontenthtml .= \html_writer::link('javascript:void(0)', get_string('more'), + ['class' => 'mod-description-action']); + $modcontenthtml .= html_writer::end_tag('div'); + $modcontenthtml .= html_writer::start_tag('div', ['class' => 'fullcontent-summary summary-hide']); + $modcontenthtml .= $cmtextcontent; + $modcontenthtml .= " " .\html_writer::link('javascript:void(0)', get_string('less', 'format_designer'), + ['class' => 'mod-description-action']); + $modcontenthtml .= html_writer::end_tag('div'); + $modcontent = $modcontenthtml; + } else { + $modcontent = html_writer::tag('p', $cmtextcontent); + } } else { $modcontent = html_writer::tag('p', $cmtextcontent); } } } else { - $modcontent = $mod->get_formatted_content( - ['overflowdiv' => true, 'noclean' => true] - ); + if (!$useactivityimagestatus) { + $modcontent = $mod->get_formatted_content( + ['overflowdiv' => true, 'noclean' => true] + ); + } } $modvisits = $DB->count_records('logstore_standard_log', ['contextinstanceid' => $mod->id, @@ -1061,9 +1079,15 @@ class_exists($class) && $durationformatted = gmdate('i:s', $videotimeduration); } } + $altcontent = $mod->get_formatted_content( + ['overflowdiv' => true, 'noclean' => true] + ); $cmlist = [ 'id' => 'module-' . $mod->id, + 'hasname' => ($mod->name) ? true : false, 'cm' => $mod, + 'modhiddenfromstudents' => (!$mod->visible) ? true : false, + 'modstealth' => $mod->is_stealth(), 'modtype' => $mod->get_module_type_name(), 'modclasses' => $modclasses, 'colorclass' => $cmcompletion->get_color_class(), @@ -1072,6 +1096,7 @@ class_exists($class) && 'cmcompletionhtml' => $cmcompletionhtml, 'calltoactionhtml' => $calltoactionhtml, 'afterlink' => $mod->afterlink, + 'altcontent' => $altcontent, 'cmtext' => $cmtext, 'isrestricted' => !empty($mod->availableinfo), 'modcontent' => isset($modcontent) ? $modcontent : '', @@ -1276,4 +1301,23 @@ public function course_section_updated_cm_item( } return $this->render_from_template($templatename, $cmlistdata); } + + /** + * Return the flow course type size classes. + * + * @param stdclass $course course. + * @return string $flowsizeclass flow size class. + */ + public function get_flow_size($course) { + $sizeclass = ''; + if ($course->flowsize == 1) { + $sizeclass = 'flow-card-medium'; + } else if ($course->flowsize == 2) { + $sizeclass = 'flow-card-large'; + } else { + $sizeclass = 'flow-card-small'; + } + $flowsizeclass = isset($course->flowsize) ? $sizeclass : ''; + return $flowsizeclass; + } } diff --git a/lang/en/format_designer.php b/lang/en/format_designer.php index 19a5737..f3fd7d5 100644 --- a/lang/en/format_designer.php +++ b/lang/en/format_designer.php @@ -312,7 +312,9 @@ $string['disabled'] = "Disabled"; $string['prerequisitesdesc'] = "Please complete all of the following courses:"; $string['courseprerequisitestitle'] = "Prerequisites title"; -$string['courseprerequisitestitle_help'] = "Prerequisites course title"; +$string['courseprerequisitestitle_help'] = "Prerequisites tab title"; +$string['courseprerequisitestabhead'] = "Display the prerequisites tab title."; +$string['courseprerequisitestabhead_help'] = "Prerequisites course title"; $string['strprerequisiteinfo'] = "Prerequisite info"; $string['strprerequisiteinfo_help'] = "Display the text above the prerequisites."; $string['displayheaderroleusers'] = "Choose the staff role"; @@ -341,6 +343,7 @@ $string['sectionzeroactivities_help'] = ""; $string['heroactivitypos'] = ""; +$string['courseprerequisitepos'] = ""; $string['stravoidduplicateentry'] = "Avoid duplicate entry"; $string['stractivitytype'] = 'Activity type'; $string['stractivitytitle'] = "Activity title"; @@ -360,6 +363,8 @@ This setting works as a default and can be overridden in the activity settings."; $string['heroactivitypos_help'] = "This setting gives you control over the order of the menu items in the secondary navigation menu. Menu items with negative values are added before the course menu item, menu items with positive values are added afterwards. Usually, it makes more sense to use positive numbers. This setting works as a default and can be overridden in the activity settings."; +$string['courseprerequisitepos_help'] = "This setting gives you control over the order of the menu items in the secondary navigation menu. Menu items with negative values are added before the course menu item, menu items with positive values are added afterwards. Usually, it makes more sense to use positive numbers."; + $string['struppercompleted'] = "COMPLETED"; $string['strtodo'] = "TODO"; @@ -431,3 +436,13 @@ // ...Field value fromat. $string['enabled'] = 'Enabled'; $string['disabled'] = 'Disabled'; +// Activity description trim length. +$string['activitydesclength'] = 'Activity description trim'; +$string['activitydesclength_desc'] = 'This global setting determines whether the description for activities is trimmed.
Trim (Default): This option trims the description, displaying it in a condensed form, similar to the current behavior.
+Do Not Trim: Choose this option to display the description exactly as it was entered, without any trimming.'; +$string['modtrimlength'] = "Trim Length"; +$string['modtrimlength_desc'] = 'This is a numeric input field that allows you to specify how much text should be displayed in the collapsed state. Enter the desired character count to control the length of the trimmed description.'; +$string['donottrim'] = 'Do not trim'; +// Flow size. +$string['flowsize'] = 'Flow size'; +$string['flowsize_help'] = 'Flow size is a setting that allows you to customize the width and height of sections and activities within your course.
Small: This option sets the width and height of sections and activities to 320 pixels by 320 pixels.
Medium: Select this option to increase the width and height to 360 pixels by 360 pixels.
Large: If you prefer a spacious layout, choose this option to set the width and height of sections and activities to 400 pixels by 400 pixels. '; diff --git a/lib.php b/lib.php index 7052158..a6f2177 100644 --- a/lib.php +++ b/lib.php @@ -68,6 +68,8 @@ define('DESIGNER_HERO_ACTVITIY_COURSEPAGE', 2); +define('DESIGNER_MOD_TEXT_TRIMM', 0); + /** * Main class for the Designer course format. * @@ -264,8 +266,11 @@ public function course_header() { */ public function page_set_course(moodle_page $page) { global $PAGE; + $course = $this->get_course(); + if ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) { + $PAGE->add_body_class('format-designer-single-section'); + } if (format_designer_has_pro()) { - $course = $this->get_course(); // Fetch classes from pro designer and attach them to the body. $classes = \local_designer\info::create()->generate_body_classes($course, $this); $PAGE->add_body_class($classes); @@ -281,8 +286,6 @@ public function page_set_course(moodle_page $page) { public function extend_course_navigation($navigation, navigation_node $node) { global $PAGE; // If section is specified in course/view.php, make sure it is expanded in navigation. - - if ($navigation->includesectionnum === false) { $selectedsection = optional_param('section', null, PARAM_INT); if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') && @@ -441,6 +444,10 @@ public static function course_format_options_list($foreditform = false) { 'default' => true, 'type' => PARAM_INT, ], + 'flowsize' => [ + 'default' => 0, + 'type' => PARAM_INT, + ], 'accordion' => [ 'default' => 0, 'type' => PARAM_INT, @@ -648,6 +655,22 @@ public static function course_format_options_list($foreditform = false) { ['coursetype', 'neq', DESIGNER_TYPE_FLOW], ], ], + 'flowsize' => [ + 'label' => new lang_string('flowsize', 'format_designer'), + 'element_type' => 'select', + 'element_attributes' => [ + [ + 0 => new lang_string('small', 'format_designer'), + 1 => new lang_string('medium', 'format_designer'), + 2 => new lang_string('large', 'format_designer'), + ], + ], + 'help' => 'flowsize', + 'help_component' => 'format_designer', + 'disabledif' => [ + ['coursetype', 'neq', DESIGNER_TYPE_FLOW], + ], + ], 'courseheader' => [ 'label' => new lang_string('courseheader', 'format_designer'), 'element_type' => 'header', @@ -995,7 +1018,7 @@ public static function section_format_options_list($foreditform) { $widthdefaultvalue = isset($design->$name) ? $design->$name : ''; $sectionoptions[$name] = [ 'default' => (isset($design->$name) && $foreditform || - (isset($course->coursetype) && $course->coursetype != DESIGNER_TYPE_NORMAL)) ? $widthdefaultvalue : 2, + (isset($course->coursetype) && $course->coursetype != DESIGNER_TYPE_NORMAL)) ? $widthdefaultvalue : 2, 'type' => PARAM_INT, 'label' => new lang_string($name, 'format_designer'), 'element_type' => 'select', @@ -1374,18 +1397,26 @@ public function get_section_options(int $sectionid): array { public function get_course() { global $CFG; $course = parent::get_course(); - if (isset($course->prerequisiteinfo) && is_string($course->prerequisiteinfo)) { - $coursecontext = context_course::instance($course->id); - $editoroptions = ['maxfiles' => -1, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true, - ]; - $editoroptions['context'] = $coursecontext; - $editoroptions['subdirs'] = file_area_contains_subdirs($coursecontext, 'local_designer', 'prerequisiteinfo', 0); + + if (!isguestuser()) { + if (isset($course->prerequisiteinfo) && is_string($course->prerequisiteinfo)) { + $coursecontext = context_course::instance($course->id); + $editoroptions = ['maxfiles' => -1, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true, + ]; + $editoroptions['context'] = $coursecontext; + $editoroptions['subdirs'] = file_area_contains_subdirs($coursecontext, 'local_designer', 'prerequisiteinfo', 0); + $course = file_prepare_standard_editor( + $course, 'prerequisiteinfo', $editoroptions, + $coursecontext, 'local_designer', 'prerequisiteinfo', 0 + ); + $course->prerequisiteinfo = $course->prerequisiteinfo_editor; + unset($course->prerequisiteinfo_editor); + } + } else { + $editoroptions['context'] = \context_system::instance(); $course = file_prepare_standard_editor( - $course, 'prerequisiteinfo', $editoroptions, - $coursecontext, 'local_designer', 'prerequisiteinfo', 0 + $course, 'prerequisiteinfo', $editoroptions, null, 'local_designer', 'prerequisiteinfo', null, ); - $course->prerequisiteinfo = $course->prerequisiteinfo_editor; - unset($course->prerequisiteinfo_editor); } // Course fields. if (isset($course->coursefields)) { diff --git a/settings.php b/settings.php index b007536..fb712fb 100644 --- a/settings.php +++ b/settings.php @@ -110,9 +110,30 @@ $activitypage = new admin_settingpage('format_designer_activity', get_string('stractivity', 'format_designer')); + // Activity description length. + $name = 'format_designer/activitydesclength'; + $title = get_string('activitydesclength', 'format_designer'); + $desc = get_string('activitydesclength_desc', 'format_designer'); + $options = [ + 0 => get_string('trimmed', 'format_designer'), + 1 => get_string('donottrim', 'format_designer'), + ]; + $default = 0; + $setting = new admin_setting_configselect($name, $title, $desc, $default, $options); + $activitypage->add($setting); + + // Activity description trim length. + $setting = new admin_setting_configtext( + 'format_designer/modtrimlength', get_string('modtrimlength', 'format_designer'), + get_string('modtrimlength_desc', 'format_designer'), 23, PARAM_INT); + $activitypage->add($setting); + if (format_designer_has_pro() && file_exists($CFG->dirroot.'/local/designer/setting.php')) { require_once($CFG->dirroot.'/local/designer/setting.php'); + } else { + $settingspage->add($activitypage); } + $settings = $settingspage; } diff --git a/styles.css b/styles.css index dcbcc28..77d4a85 100644 --- a/styles.css +++ b/styles.css @@ -14,9 +14,6 @@ .link-layout .img-element .activityiconcontainer.img-block .icon { filter: none; } -html:has([class=""]) { - height: auto; -} @media (min-width: 1200px) { .pagelayout-course.format-designer #page-wrapper #page.drawers .main-inner { @@ -234,7 +231,9 @@ html:has([class=""]) { padding: 0 15px; } .format-designer .course-content .single-section-layout ul.designer.course-type-normal li.section.main .section-header-content { + height: 100%; padding: 15px; + margin-bottom: 15px; } .format-designer .course-content .single-section-layout:not(.section-page-layout) ul.designer.course-type-normal li.section.main .section-content-wrapper { height: 100%; @@ -511,6 +510,9 @@ body.format-designer.editing ul.designer .section .circles-layout .activity .edi left: 0; z-index: -1; } +.format-designer .course-content ul.designer.course-type-flow li.section.main .section-background-style.section-design-whole { + z-index: 0; +} .format-designer .course-content ul.designer li.section.main .section-background-style.section-design-whole .mask-inner-section, .format-designer .course-content ul.designer li.section .section-header-content @@ -1051,6 +1053,9 @@ ul li { .format-designer .designer .section.img-text.list-layout .activity .activityinstance { padding-right: 30px; } +.format-designer .designer .section.img-text.list-layout .activity .activity-altcontent { + margin-top: 15px; +} .format-designer .designer .section.img-text.list-layout .activity .activityinstance .activity-instance { width: 100%; } @@ -2933,7 +2938,8 @@ body.format-designer.editing .designer .section .content .section.card-layout li margin-top: 30px; } .format-designer .course-content ul.course-type-flow.designer .section.main .section-content-wrapper { - display: contents; + /* display: contents; */ + position: relative; } .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity { width: 400px; @@ -2966,8 +2972,8 @@ body.format-designer.editing .designer .section .content .section.card-layout li width: 90%; float: none; position: absolute; - bottom: 20px; - left: 20px; + bottom: 10px; + right: 10px; } .format-designer .course-content ul.designer.course-type-flow li.section .section-header-content .section-progress-info > div:not(.progress-donut) .progress { height: 12px; @@ -3049,7 +3055,7 @@ div:not(.activity-background-style) + .mod-indent-outer .completion-html-card .c position: absolute; top: 0; left: 0; - background-image: linear-gradient(to right, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.01)); + background-image: linear-gradient(to right, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0.01)); z-index: 0; } .format-designer ul.designer.course-type-flow.designer li.activity.videotime .card.card-list.notstarted { @@ -3139,6 +3145,76 @@ li.section.main.section-background-color:not(.section-header-image) background: none; } +@media (min-width: 992px) { + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-small, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-small.flow-stack.collapsed { + width: 320px; + min-height: 320px; + } + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-medium, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-medium.flow-stack.collapsed { + width: 360px; + min-height: 360px; + } + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-large, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-large.flow-stack.collapsed { + width: 400px; + min-height: 400px; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-small { + width: 320px; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-medium { + width: 360px; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-large { + width: 400px; + } + .format-designer .designer.course-type-flow .section .content .section.card-layout li.activity.flow-card-small .card.card-list { + min-height: 320px; + } + .format-designer .designer.course-type-flow .section .content .section.card-layout li.activity.flow-card-medium .card.card-list { + min-height: 360px; + } + .format-designer .designer.course-type-flow .section .content .section.card-layout li.activity.flow-card-large .card.card-list { + min-height: 400px; + } +} + +@media (min-width: 768px) and (max-width: 991px) { + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-small.flow-stack, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-medium.flow-stack, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-large.flow-stack { + width: 46%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-small { + width: 46%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-medium { + width: 46%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-large { + width: 46%; + } +} + +@media (max-width: 767px) { + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-small.flow-stack, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-medium.flow-stack, + .format-designer .course-content ul.course-type-flow.designer .section.main .section-header-content.flow-card-large.flow-stack { + width: 94%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-small { + width: 94%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-medium { + width: 94%; + } + .format-designer .course-content ul.designer.course-type-flow li.section ul.section.img-text li.activity.flow-card-large { + width: 94%; + } +} + .flow-animation { -webkit-animation-duration: 1s; animation-duration: 1s; diff --git a/templates/cm/module_layout_cards.mustache b/templates/cm/module_layout_cards.mustache index a4758a7..41d2ad3 100644 --- a/templates/cm/module_layout_cards.mustache +++ b/templates/cm/module_layout_cards.mustache @@ -91,6 +91,12 @@ {{/modcontent}} + {{#hasname}} + {{$ core_courseformat/local/content/cm/badges }} + {{> core_courseformat/local/content/cm/badges }} + {{/ core_courseformat/local/content/cm/badges }} + {{/hasname}} + {{#useactivityimage}} {{{modiconurl}}} {{/useactivityimage}} diff --git a/templates/cm/module_layout_default.mustache b/templates/cm/module_layout_default.mustache index 8e47d3f..87d79f2 100644 --- a/templates/cm/module_layout_default.mustache +++ b/templates/cm/module_layout_default.mustache @@ -107,6 +107,12 @@ {{/modcontent}} + {{#hasname}} + {{$ core_courseformat/local/content/cm/badges }} + {{> core_courseformat/local/content/cm/badges }} + {{/ core_courseformat/local/content/cm/badges }} + {{/hasname}} + {{^modrestricted}}
{{{calltoactionhtml}}} diff --git a/templates/cm/module_layout_list.mustache b/templates/cm/module_layout_list.mustache index 3b36fa3..bb94400 100644 --- a/templates/cm/module_layout_list.mustache +++ b/templates/cm/module_layout_list.mustache @@ -91,6 +91,13 @@ {{{modcontent}}}
{{/modcontent}} + + {{#hasname}} + {{$ core_courseformat/local/content/cm/badges }} + {{> core_courseformat/local/content/cm/badges }} + {{/ core_courseformat/local/content/cm/badges }} + {{/hasname}} +
diff --git a/templates/courseformat/content.mustache b/templates/courseformat/content.mustache index ff9126d..d1656f3 100644 --- a/templates/courseformat/content.mustache +++ b/templates/courseformat/content.mustache @@ -159,7 +159,7 @@ } } }} -
+
{{{timemanagement}}}

{{{title}}}

{{{completionhelp}}} diff --git a/templates/section_layout.mustache b/templates/section_layout.mustache index e0916a6..69e3953 100644 --- a/templates/section_layout.mustache +++ b/templates/section_layout.mustache @@ -49,7 +49,7 @@
-
version = 2023101900; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2023110100; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2020061500; // Requires this Moodle version. $plugin->component = 'format_designer'; // Full name of the plugin (used for diagnostics). $plugin->release = 'Version 1.5';