diff --git a/public/course/format/amd/build/local/courseeditor/exporter.min.js b/public/course/format/amd/build/local/courseeditor/exporter.min.js index f6a62d56063..a571ce8a31a 100644 --- a/public/course/format/amd/build/local/courseeditor/exporter.min.js +++ b/public/course/format/amd/build/local/courseeditor/exporter.min.js @@ -8,6 +8,6 @@ define("core_courseformat/local/courseeditor/exporter",["exports"],(function(_ex * @copyright 2021 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class{constructor(reactive){this.reactive=reactive,this.COMPLETIONS=["incomplete","complete","complete","fail"]}course(state){var _state$course$highlig;const data={sections:[],editmode:this.reactive.isEditing,highlighted:null!==(_state$course$highlig=state.course.highlighted)&&void 0!==_state$course$highlig?_state$course$highlig:""};return this.listedSectionIds(state).forEach((sectionid=>{var _state$section$get;const sectioninfo=null!==(_state$section$get=state.section.get(sectionid))&&void 0!==_state$section$get?_state$section$get:{},section=this.section(state,sectioninfo);data.sections.push(section)})),data.hassections=0!=data.sections.length,data}listedSectionIds(state){var _state$course$section;return(null!==(_state$course$section=state.course.sectionlist)&&void 0!==_state$course$section?_state$course$section:[]).filter((sectionid=>{var _state$section$get2;return null===(null!==(_state$section$get2=state.section.get(sectionid))&&void 0!==_state$section$get2?_state$section$get2:{}).component}))}section(state,sectioninfo){var _state$course$highlig2,_sectioninfo$cmlist;const section={...sectioninfo,highlighted:null!==(_state$course$highlig2=state.course.highlighted)&&void 0!==_state$course$highlig2?_state$course$highlig2:"",cms:[]};return(null!==(_sectioninfo$cmlist=sectioninfo.cmlist)&&void 0!==_sectioninfo$cmlist?_sectioninfo$cmlist:[]).forEach((cmid=>{const cminfo=state.cm.get(cmid),cm=this.cm(state,cminfo);section.cms.push(cm)})),section.hascms=0!=section.cms.length,section}cm(state,cminfo){const cm={...cminfo,isactive:!1,sectioninfo:!1};if(cminfo.hasdelegatedsection){const sectioninfo=state.section.get(cminfo.delegatesectionid);cm.sectioninfo=this.section(state,sectioninfo)}return cm}cmDraggableData(state,cmid){const cminfo=state.cm.get(cmid);if(!cminfo)return null;let nextcmid;const section=state.section.get(cminfo.sectionid),currentindex=null==section?void 0:section.cmlist.indexOf(cminfo.id);return void 0!==currentindex&&(nextcmid=null==section?void 0:section.cmlist[currentindex+1]),{type:"cm",id:cminfo.id,name:cminfo.name,sectionid:cminfo.sectionid,hasdelegatedsection:cminfo.hasdelegatedsection,nextcmid:nextcmid}}sectionDraggableData(state,sectionid){const sectioninfo=state.section.get(sectionid);return sectioninfo?{type:"section",id:sectioninfo.id,name:sectioninfo.name,number:sectioninfo.number}:null}fileDraggableData(state,dataTransfer){var _dataTransfer$files;const files=[];return(null===(_dataTransfer$files=dataTransfer.files)||void 0===_dataTransfer$files?void 0:_dataTransfer$files.length)>0&&dataTransfer.files.forEach((file=>{files.push(file)})),{type:"files",files:files}}cmCompletion(state,cminfo){const data={statename:"",state:"NaN"};if(void 0!==cminfo.completionstate){var _this$COMPLETIONS$cmi;data.state=cminfo.completionstate,data.hasstate=!0;let statename=null!==(_this$COMPLETIONS$cmi=this.COMPLETIONS[cminfo.completionstate])&&void 0!==_this$COMPLETIONS$cmi?_this$COMPLETIONS$cmi:"NaN";void 0!==cminfo.isoverallcomplete&&!0===cminfo.isoverallcomplete&&(statename="complete"),data["is".concat(statename)]=!0}return data}allItemsArray(state){var _state$course$section2;const items=[];return(null!==(_state$course$section2=state.course.sectionlist)&&void 0!==_state$course$section2?_state$course$section2:[]).forEach((sectionid=>{var _sectioninfo$cmlist2;const sectioninfo=state.section.get(sectionid);if(null!==sectioninfo.component)return;items.push({type:"section",id:sectioninfo.id,url:sectioninfo.sectionurl});(null!==(_sectioninfo$cmlist2=sectioninfo.cmlist)&&void 0!==_sectioninfo$cmlist2?_sectioninfo$cmlist2:[]).forEach((cmid=>{const cmInfo=state.cm.get(cmid);items.push(...this.cmItemsArray(state,cmInfo))}))})),items}cmItemsArray(state,cmInfo){if(cmInfo.hasdelegatedsection){var _delegatedsection$cml;const items=[],delegatedsection=state.section.get(cmInfo.delegatesectionid);items.push({type:"section",id:delegatedsection.id,url:delegatedsection.sectionurl});return(null!==(_delegatedsection$cml=delegatedsection.cmlist)&&void 0!==_delegatedsection$cml?_delegatedsection$cml:[]).forEach((cmid=>{const cmInfo=state.cm.get(cmid);items.push({type:"cm",id:cmInfo.id,url:cmInfo.url})})),items}return[{type:"cm",id:cmInfo.id,url:cmInfo.url}]}canUseStealth(state,cmIds){return cmIds.some((cmId=>{var _cminfo$allowstealth;const cminfo=state.cm.get(cmId);return null!==(_cminfo$allowstealth=null==cminfo?void 0:cminfo.allowstealth)&&void 0!==_cminfo$allowstealth&&_cminfo$allowstealth}))}},_exports.default})); +class{constructor(reactive){this.reactive=reactive,this.COMPLETIONS=["incomplete","complete","complete","fail"]}course(state){var _state$course$highlig;const data={sections:[],editmode:this.reactive.isEditing,highlighted:null!==(_state$course$highlig=state.course.highlighted)&&void 0!==_state$course$highlig?_state$course$highlig:""};return this.listedSectionIds(state).forEach((sectionid=>{var _state$section$get;const sectioninfo=null!==(_state$section$get=state.section.get(sectionid))&&void 0!==_state$section$get?_state$section$get:{},section=this.section(state,sectioninfo);data.sections.push(section)})),data.hassections=0!=data.sections.length,data}listedSectionIds(state){var _state$course$section;return(null!==(_state$course$section=state.course.sectionlist)&&void 0!==_state$course$section?_state$course$section:[]).filter((sectionid=>{var _state$section$get2;return null===(null!==(_state$section$get2=state.section.get(sectionid))&&void 0!==_state$section$get2?_state$section$get2:{}).component}))}section(state,sectioninfo){var _state$course$highlig2,_sectioninfo$cmlist;const section={...sectioninfo,highlighted:null!==(_state$course$highlig2=state.course.highlighted)&&void 0!==_state$course$highlig2?_state$course$highlig2:"",cms:[]};return(null!==(_sectioninfo$cmlist=sectioninfo.cmlist)&&void 0!==_sectioninfo$cmlist?_sectioninfo$cmlist:[]).forEach((cmid=>{const cminfo=state.cm.get(cmid),cm=this.cm(state,cminfo);section.cms.push(cm)})),section.hascms=0!=section.cms.length,section}cm(state,cminfo){const cm={...cminfo,isactive:!1,sectioninfo:!1};if(cminfo.hasdelegatedsection){var _state$section$get3;const sectioninfo=null!==(_state$section$get3=state.section.get(cminfo.delegatesectionid))&&void 0!==_state$section$get3?_state$section$get3:{};cm.sectioninfo=this.section(state,sectioninfo)}return cm}cmDraggableData(state,cmid){const cminfo=state.cm.get(cmid);if(!cminfo)return null;let nextcmid;const section=state.section.get(cminfo.sectionid),currentindex=null==section?void 0:section.cmlist.indexOf(cminfo.id);return void 0!==currentindex&&(nextcmid=null==section?void 0:section.cmlist[currentindex+1]),{type:"cm",id:cminfo.id,name:cminfo.name,sectionid:cminfo.sectionid,hasdelegatedsection:cminfo.hasdelegatedsection,nextcmid:nextcmid}}sectionDraggableData(state,sectionid){const sectioninfo=state.section.get(sectionid);return sectioninfo?{type:"section",id:sectioninfo.id,name:sectioninfo.name,number:sectioninfo.number}:null}fileDraggableData(state,dataTransfer){var _dataTransfer$files;const files=[];return(null===(_dataTransfer$files=dataTransfer.files)||void 0===_dataTransfer$files?void 0:_dataTransfer$files.length)>0&&dataTransfer.files.forEach((file=>{files.push(file)})),{type:"files",files:files}}cmCompletion(state,cminfo){const data={statename:"",state:"NaN"};if(void 0!==cminfo.completionstate){var _this$COMPLETIONS$cmi;data.state=cminfo.completionstate,data.hasstate=!0;let statename=null!==(_this$COMPLETIONS$cmi=this.COMPLETIONS[cminfo.completionstate])&&void 0!==_this$COMPLETIONS$cmi?_this$COMPLETIONS$cmi:"NaN";void 0!==cminfo.isoverallcomplete&&!0===cminfo.isoverallcomplete&&(statename="complete"),data["is".concat(statename)]=!0}return data}allItemsArray(state){var _state$course$section2;const items=[];return(null!==(_state$course$section2=state.course.sectionlist)&&void 0!==_state$course$section2?_state$course$section2:[]).forEach((sectionid=>{var _sectioninfo$cmlist2;const sectioninfo=state.section.get(sectionid);if(null!==sectioninfo.component)return;items.push({type:"section",id:sectioninfo.id,url:sectioninfo.sectionurl});(null!==(_sectioninfo$cmlist2=sectioninfo.cmlist)&&void 0!==_sectioninfo$cmlist2?_sectioninfo$cmlist2:[]).forEach((cmid=>{const cmInfo=state.cm.get(cmid);items.push(...this.cmItemsArray(state,cmInfo))}))})),items}cmItemsArray(state,cmInfo){if(cmInfo.hasdelegatedsection){const items=[],delegatedsection=state.section.get(cmInfo.delegatesectionid);if(delegatedsection){var _delegatedsection$cml;items.push({type:"section",id:delegatedsection.id,url:delegatedsection.sectionurl});(null!==(_delegatedsection$cml=delegatedsection.cmlist)&&void 0!==_delegatedsection$cml?_delegatedsection$cml:[]).forEach((cmid=>{const cmInfo=state.cm.get(cmid);items.push({type:"cm",id:cmInfo.id,url:cmInfo.url})}))}return items}return[{type:"cm",id:cmInfo.id,url:cmInfo.url}]}canUseStealth(state,cmIds){return cmIds.some((cmId=>{var _cminfo$allowstealth;const cminfo=state.cm.get(cmId);return null!==(_cminfo$allowstealth=null==cminfo?void 0:cminfo.allowstealth)&&void 0!==_cminfo$allowstealth&&_cminfo$allowstealth}))}},_exports.default})); //# sourceMappingURL=exporter.min.js.map \ No newline at end of file diff --git a/public/course/format/amd/build/local/courseeditor/exporter.min.js.map b/public/course/format/amd/build/local/courseeditor/exporter.min.js.map index 6c9c78ecd0e..c9feec9e166 100644 --- a/public/course/format/amd/build/local/courseeditor/exporter.min.js.map +++ b/public/course/format/amd/build/local/courseeditor/exporter.min.js.map @@ -1 +1 @@ -{"version":3,"file":"exporter.min.js","sources":["../../../src/local/courseeditor/exporter.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A configuration to provide to the modal.\n *\n * @typedef {Object} courseItem\n *\n * @property {String} type The type of element (section, cm).\n * @property {Number} id Element ID.\n * @property {String} url Element URL.\n */\n\n/**\n * Module to export parts of the state and transform them to be used in templates\n * and as draggable data.\n *\n * @module core_courseformat/local/courseeditor/exporter\n * @class core_courseformat/local/courseeditor/exporter\n * @copyright 2021 Ferran Recio \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class {\n\n /**\n * Class constructor.\n *\n * @param {CourseEditor} reactive the course editor object\n */\n constructor(reactive) {\n this.reactive = reactive;\n\n // Completions states are defined in lib/completionlib.php. There are 4 different completion\n // state values, however, the course index uses the same state for complete and complete_pass.\n // This is the reason why completed appears twice in the array.\n this.COMPLETIONS = ['incomplete', 'complete', 'complete', 'fail'];\n }\n\n /**\n * Generate the course export data from the state.\n *\n * @param {Object} state the current state.\n * @returns {Object}\n */\n course(state) {\n // Collect section information from the state.\n const data = {\n sections: [],\n editmode: this.reactive.isEditing,\n highlighted: state.course.highlighted ?? '',\n };\n const sectionlist = this.listedSectionIds(state);\n sectionlist.forEach(sectionid => {\n const sectioninfo = state.section.get(sectionid) ?? {};\n const section = this.section(state, sectioninfo);\n data.sections.push(section);\n });\n data.hassections = (data.sections.length != 0);\n\n return data;\n }\n\n /**\n * Get the IDs of the sections that are listed as regular sections.\n * @param {Object} state the current state.\n * @returns {Number[]} the list of section ids that are listed.\n */\n listedSectionIds(state) {\n const fullSectionList = state.course.sectionlist ?? [];\n return fullSectionList.filter(sectionid => {\n const sectioninfo = state.section.get(sectionid) ?? {};\n // Delegated sections (controlled by a component) are not listed in course.\n return sectioninfo.component === null;\n });\n }\n\n /**\n * Generate a section export data from the state.\n *\n * @param {Object} state the current state.\n * @param {Object} sectioninfo the section state data.\n * @returns {Object}\n */\n section(state, sectioninfo) {\n const section = {\n ...sectioninfo,\n highlighted: state.course.highlighted ?? '',\n cms: [],\n };\n const cmlist = sectioninfo.cmlist ?? [];\n cmlist.forEach(cmid => {\n const cminfo = state.cm.get(cmid);\n const cm = this.cm(state, cminfo);\n section.cms.push(cm);\n });\n section.hascms = (section.cms.length != 0);\n\n return section;\n }\n\n /**\n * Generate a cm export data from the state.\n *\n * @param {Object} state the current state.\n * @param {Object} cminfo the course module state data.\n * @returns {Object}\n */\n cm(state, cminfo) {\n const cm = {\n ...cminfo,\n isactive: false,\n sectioninfo: false, // Init to false to prevent mustache recursion loops.\n };\n if (cminfo.hasdelegatedsection) {\n const sectioninfo = state.section.get(cminfo.delegatesectionid);\n cm.sectioninfo = this.section(state, sectioninfo);\n }\n return cm;\n }\n\n /**\n * Generate a dragable cm data structure.\n *\n * This method is used by any draggable course module element to generate drop data\n * for its reactive/dragdrop instance.\n *\n * @param {*} state the state object\n * @param {*} cmid the cours emodule id\n * @returns {Object|null}\n */\n cmDraggableData(state, cmid) {\n const cminfo = state.cm.get(cmid);\n if (!cminfo) {\n return null;\n }\n\n // Drop an activity over the next activity is the same as doing anything.\n let nextcmid;\n const section = state.section.get(cminfo.sectionid);\n const currentindex = section?.cmlist.indexOf(cminfo.id);\n if (currentindex !== undefined) {\n nextcmid = section?.cmlist[currentindex + 1];\n }\n\n return {\n type: 'cm',\n id: cminfo.id,\n name: cminfo.name,\n sectionid: cminfo.sectionid,\n hasdelegatedsection: cminfo.hasdelegatedsection,\n nextcmid,\n };\n }\n\n /**\n * Generate a dragable cm data structure.\n *\n * This method is used by any draggable section element to generate drop data\n * for its reactive/dragdrop instance.\n *\n * @param {*} state the state object\n * @param {*} sectionid the cours section id\n * @returns {Object|null}\n */\n sectionDraggableData(state, sectionid) {\n const sectioninfo = state.section.get(sectionid);\n if (!sectioninfo) {\n return null;\n }\n return {\n type: 'section',\n id: sectioninfo.id,\n name: sectioninfo.name,\n number: sectioninfo.number,\n };\n }\n\n /**\n * Generate a file draggable structure.\n *\n * This method is used when files are dragged on the browser.\n *\n * @param {*} state the state object\n * @param {*} dataTransfer the current data tranfer data\n * @returns {Object|null}\n */\n fileDraggableData(state, dataTransfer) {\n const files = [];\n // Browsers do not provide the file list until the drop event.\n if (dataTransfer.files?.length > 0) {\n dataTransfer.files.forEach(file => {\n files.push(file);\n });\n }\n return {\n type: 'files',\n files,\n };\n }\n\n /**\n * Generate a completion export data from the cm element.\n *\n * @param {Object} state the current state.\n * @param {Object} cminfo the course module state data.\n * @returns {Object}\n */\n cmCompletion(state, cminfo) {\n const data = {\n statename: '',\n state: 'NaN',\n };\n if (cminfo.completionstate !== undefined) {\n data.state = cminfo.completionstate;\n data.hasstate = true;\n let statename = this.COMPLETIONS[cminfo.completionstate] ?? 'NaN';\n if (cminfo.isoverallcomplete !== undefined && cminfo.isoverallcomplete === true) {\n statename = 'complete';\n }\n data[`is${statename}`] = true;\n }\n return data;\n }\n\n /**\n * Return a sorted list of all sections and cms items in the state.\n *\n * @param {Object} state the current state.\n * @returns {courseItem[]} all sections and cms items in the state.\n */\n allItemsArray(state) {\n const items = [];\n const sectionlist = state.course.sectionlist ?? [];\n // Add sections.\n sectionlist.forEach(sectionid => {\n const sectioninfo = state.section.get(sectionid);\n // Skip delegated sections because components are responsible for them.\n if (sectioninfo.component !== null) {\n return;\n }\n\n items.push({\n type: 'section',\n id: sectioninfo.id,\n url: sectioninfo.sectionurl\n });\n // Add cms.\n const cmlist = sectioninfo.cmlist ?? [];\n cmlist.forEach(cmid => {\n const cmInfo = state.cm.get(cmid);\n items.push(...this.cmItemsArray(state, cmInfo));\n });\n });\n return items;\n }\n\n /**\n * Return a list of all items associated with an activity.\n *\n * @private\n * @param {Object} state the full current state.\n * @param {Object} cmInfo the course module state data.\n * @return {courseItem[]} the items array associated with that cm.\n */\n cmItemsArray(state, cmInfo) {\n // Activities with delegated sections are exported as sections.\n if (cmInfo.hasdelegatedsection) {\n const items = [];\n const delegatedsection = state.section.get(cmInfo.delegatesectionid);\n items.push({\n type: 'section',\n id: delegatedsection.id,\n url: delegatedsection.sectionurl\n });\n const delegatedCmlist = delegatedsection.cmlist ?? [];\n delegatedCmlist.forEach(cmid => {\n const cmInfo = state.cm.get(cmid);\n items.push({\n type: 'cm',\n id: cmInfo.id,\n url: cmInfo.url\n });\n });\n return items;\n }\n\n return [\n {type: 'cm', id: cmInfo.id, url: cmInfo.url},\n ];\n }\n\n /**\n * Check is some activities of a list can be stealth.\n *\n * @param {Object} state the current state.\n * @param {Number[]} cmIds the module ids to check\n * @returns {Boolean} if any of the activities can be stealth.\n */\n canUseStealth(state, cmIds) {\n return cmIds.some(cmId => {\n const cminfo = state.cm.get(cmId);\n return cminfo?.allowstealth ?? false;\n });\n }\n}\n"],"names":["constructor","reactive","COMPLETIONS","course","state","data","sections","editmode","this","isEditing","highlighted","listedSectionIds","forEach","sectionid","sectioninfo","section","get","push","hassections","length","sectionlist","filter","component","cms","cmlist","cmid","cminfo","cm","hascms","isactive","hasdelegatedsection","delegatesectionid","cmDraggableData","nextcmid","currentindex","indexOf","id","undefined","type","name","sectionDraggableData","number","fileDraggableData","dataTransfer","files","file","cmCompletion","statename","completionstate","hasstate","isoverallcomplete","allItemsArray","items","url","sectionurl","cmInfo","cmItemsArray","delegatedsection","canUseStealth","cmIds","some","cmId","allowstealth"],"mappings":";;;;;;;;;;MAyCIA,YAAYC,eACHA,SAAWA,cAKXC,YAAc,CAAC,aAAc,WAAY,WAAY,QAS9DC,OAAOC,uCAEGC,KAAO,CACTC,SAAU,GACVC,SAAUC,KAAKP,SAASQ,UACxBC,0CAAaN,MAAMD,OAAOO,mEAAe,WAEzBF,KAAKG,iBAAiBP,OAC9BQ,SAAQC,yCACVC,uCAAcV,MAAMW,QAAQC,IAAIH,4DAAc,GAC9CE,QAAUP,KAAKO,QAAQX,MAAOU,aACpCT,KAAKC,SAASW,KAAKF,YAEvBV,KAAKa,YAAuC,GAAxBb,KAAKC,SAASa,OAE3Bd,KAQXM,iBAAiBP,sEACWA,MAAMD,OAAOiB,mEAAe,IAC7BC,QAAOR,2CAGO,oCAFbT,MAAMW,QAAQC,IAAIH,8DAAc,IAEjCS,aAW3BP,QAAQX,MAAOU,kEACLC,QAAU,IACTD,YACHJ,2CAA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B,2BACtC3C,KAAKD,MAAQsB,OAAOsB,gBACpB3C,KAAK4C,UAAW,MACZF,wCAAYvC,KAAKN,YAAYwB,OAAOsB,wEAAoB,WAC3BX,IAA7BX,OAAOwB,oBAAgE,IAA7BxB,OAAOwB,oBACjDH,UAAY,YAEhB1C,iBAAU0C,aAAe,SAEtB1C,KASX8C,cAAc/C,wCACJgD,MAAQ,yCACMhD,MAAMD,OAAOiB,qEAAe,IAEpCR,SAAQC,2CACVC,YAAcV,MAAMW,QAAQC,IAAIH,cAER,OAA1BC,YAAYQ,iBAIhB8B,MAAMnC,KAAK,CACPqB,KAAM,UACNF,GAAItB,YAAYsB,GAChBiB,IAAKvC,YAAYwC,2CAGNxC,YAAYU,4DAAU,IAC9BZ,SAAQa,aACL8B,OAASnD,MAAMuB,GAAGX,IAAIS,MAC5B2B,MAAMnC,QAAQT,KAAKgD,aAAapD,MAAOmD,eAGxCH,MAWXI,aAAapD,MAAOmD,WAEZA,OAAOzB,oBAAqB,iCACtBsB,MAAQ,GACRK,iBAAmBrD,MAAMW,QAAQC,IAAIuC,OAAOxB,mBAClDqB,MAAMnC,KAAK,CACPqB,KAAM,UACNF,GAAIqB,iBAAiBrB,GACrBiB,IAAKI,iBAAiBH,kDAEFG,iBAAiBjC,8DAAU,IACnCZ,SAAQa,aACd8B,OAASnD,MAAMuB,GAAGX,IAAIS,MAC5B2B,MAAMnC,KAAK,CACPqB,KAAM,KACNF,GAAImB,OAAOnB,GACXiB,IAAKE,OAAOF,SAGbD,YAGJ,CACH,CAACd,KAAM,KAAMF,GAAImB,OAAOnB,GAAIiB,IAAKE,OAAOF,MAWhDK,cAActD,MAAOuD,cACVA,MAAMC,MAAKC,sCACRnC,OAAStB,MAAMuB,GAAGX,IAAI6C,0CACrBnC,MAAAA,cAAAA,OAAQoC"} \ No newline at end of file +{"version":3,"file":"exporter.min.js","sources":["../../../src/local/courseeditor/exporter.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * A configuration to provide to the modal.\n *\n * @typedef {Object} courseItem\n *\n * @property {String} type The type of element (section, cm).\n * @property {Number} id Element ID.\n * @property {String} url Element URL.\n */\n\n/**\n * Module to export parts of the state and transform them to be used in templates\n * and as draggable data.\n *\n * @module core_courseformat/local/courseeditor/exporter\n * @class core_courseformat/local/courseeditor/exporter\n * @copyright 2021 Ferran Recio \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class {\n\n /**\n * Class constructor.\n *\n * @param {CourseEditor} reactive the course editor object\n */\n constructor(reactive) {\n this.reactive = reactive;\n\n // Completions states are defined in lib/completionlib.php. There are 4 different completion\n // state values, however, the course index uses the same state for complete and complete_pass.\n // This is the reason why completed appears twice in the array.\n this.COMPLETIONS = ['incomplete', 'complete', 'complete', 'fail'];\n }\n\n /**\n * Generate the course export data from the state.\n *\n * @param {Object} state the current state.\n * @returns {Object}\n */\n course(state) {\n // Collect section information from the state.\n const data = {\n sections: [],\n editmode: this.reactive.isEditing,\n highlighted: state.course.highlighted ?? '',\n };\n const sectionlist = this.listedSectionIds(state);\n sectionlist.forEach(sectionid => {\n const sectioninfo = state.section.get(sectionid) ?? {};\n const section = this.section(state, sectioninfo);\n data.sections.push(section);\n });\n data.hassections = (data.sections.length != 0);\n\n return data;\n }\n\n /**\n * Get the IDs of the sections that are listed as regular sections.\n * @param {Object} state the current state.\n * @returns {Number[]} the list of section ids that are listed.\n */\n listedSectionIds(state) {\n const fullSectionList = state.course.sectionlist ?? [];\n return fullSectionList.filter(sectionid => {\n const sectioninfo = state.section.get(sectionid) ?? {};\n // Delegated sections (controlled by a component) are not listed in course.\n return sectioninfo.component === null;\n });\n }\n\n /**\n * Generate a section export data from the state.\n *\n * @param {Object} state the current state.\n * @param {Object} sectioninfo the section state data.\n * @returns {Object}\n */\n section(state, sectioninfo) {\n const section = {\n ...sectioninfo,\n highlighted: state.course.highlighted ?? '',\n cms: [],\n };\n const cmlist = sectioninfo.cmlist ?? [];\n cmlist.forEach(cmid => {\n const cminfo = state.cm.get(cmid);\n const cm = this.cm(state, cminfo);\n section.cms.push(cm);\n });\n section.hascms = (section.cms.length != 0);\n\n return section;\n }\n\n /**\n * Generate a cm export data from the state.\n *\n * @param {Object} state the current state.\n * @param {Object} cminfo the course module state data.\n * @returns {Object}\n */\n cm(state, cminfo) {\n const cm = {\n ...cminfo,\n isactive: false,\n sectioninfo: false, // Init to false to prevent mustache recursion loops.\n };\n if (cminfo.hasdelegatedsection) {\n const sectioninfo = state.section.get(cminfo.delegatesectionid) ?? {};\n cm.sectioninfo = this.section(state, sectioninfo);\n }\n return cm;\n }\n\n /**\n * Generate a dragable cm data structure.\n *\n * This method is used by any draggable course module element to generate drop data\n * for its reactive/dragdrop instance.\n *\n * @param {*} state the state object\n * @param {*} cmid the cours emodule id\n * @returns {Object|null}\n */\n cmDraggableData(state, cmid) {\n const cminfo = state.cm.get(cmid);\n if (!cminfo) {\n return null;\n }\n\n // Drop an activity over the next activity is the same as doing anything.\n let nextcmid;\n const section = state.section.get(cminfo.sectionid);\n const currentindex = section?.cmlist.indexOf(cminfo.id);\n if (currentindex !== undefined) {\n nextcmid = section?.cmlist[currentindex + 1];\n }\n\n return {\n type: 'cm',\n id: cminfo.id,\n name: cminfo.name,\n sectionid: cminfo.sectionid,\n hasdelegatedsection: cminfo.hasdelegatedsection,\n nextcmid,\n };\n }\n\n /**\n * Generate a dragable cm data structure.\n *\n * This method is used by any draggable section element to generate drop data\n * for its reactive/dragdrop instance.\n *\n * @param {*} state the state object\n * @param {*} sectionid the cours section id\n * @returns {Object|null}\n */\n sectionDraggableData(state, sectionid) {\n const sectioninfo = state.section.get(sectionid);\n if (!sectioninfo) {\n return null;\n }\n return {\n type: 'section',\n id: sectioninfo.id,\n name: sectioninfo.name,\n number: sectioninfo.number,\n };\n }\n\n /**\n * Generate a file draggable structure.\n *\n * This method is used when files are dragged on the browser.\n *\n * @param {*} state the state object\n * @param {*} dataTransfer the current data tranfer data\n * @returns {Object|null}\n */\n fileDraggableData(state, dataTransfer) {\n const files = [];\n // Browsers do not provide the file list until the drop event.\n if (dataTransfer.files?.length > 0) {\n dataTransfer.files.forEach(file => {\n files.push(file);\n });\n }\n return {\n type: 'files',\n files,\n };\n }\n\n /**\n * Generate a completion export data from the cm element.\n *\n * @param {Object} state the current state.\n * @param {Object} cminfo the course module state data.\n * @returns {Object}\n */\n cmCompletion(state, cminfo) {\n const data = {\n statename: '',\n state: 'NaN',\n };\n if (cminfo.completionstate !== undefined) {\n data.state = cminfo.completionstate;\n data.hasstate = true;\n let statename = this.COMPLETIONS[cminfo.completionstate] ?? 'NaN';\n if (cminfo.isoverallcomplete !== undefined && cminfo.isoverallcomplete === true) {\n statename = 'complete';\n }\n data[`is${statename}`] = true;\n }\n return data;\n }\n\n /**\n * Return a sorted list of all sections and cms items in the state.\n *\n * @param {Object} state the current state.\n * @returns {courseItem[]} all sections and cms items in the state.\n */\n allItemsArray(state) {\n const items = [];\n const sectionlist = state.course.sectionlist ?? [];\n // Add sections.\n sectionlist.forEach(sectionid => {\n const sectioninfo = state.section.get(sectionid);\n // Skip delegated sections because components are responsible for them.\n if (sectioninfo.component !== null) {\n return;\n }\n\n items.push({\n type: 'section',\n id: sectioninfo.id,\n url: sectioninfo.sectionurl\n });\n // Add cms.\n const cmlist = sectioninfo.cmlist ?? [];\n cmlist.forEach(cmid => {\n const cmInfo = state.cm.get(cmid);\n items.push(...this.cmItemsArray(state, cmInfo));\n });\n });\n return items;\n }\n\n /**\n * Return a list of all items associated with an activity.\n *\n * @private\n * @param {Object} state the full current state.\n * @param {Object} cmInfo the course module state data.\n * @return {courseItem[]} the items array associated with that cm.\n */\n cmItemsArray(state, cmInfo) {\n // Activities with delegated sections are exported as sections.\n if (cmInfo.hasdelegatedsection) {\n const items = [];\n const delegatedsection = state.section.get(cmInfo.delegatesectionid);\n if (delegatedsection) {\n items.push({\n type: 'section',\n id: delegatedsection.id,\n url: delegatedsection.sectionurl\n });\n const delegatedCmlist = delegatedsection.cmlist ?? [];\n delegatedCmlist.forEach(cmid => {\n const cmInfo = state.cm.get(cmid);\n items.push({\n type: 'cm',\n id: cmInfo.id,\n url: cmInfo.url\n });\n });\n }\n return items;\n }\n\n return [\n {type: 'cm', id: cmInfo.id, url: cmInfo.url},\n ];\n }\n\n /**\n * Check is some activities of a list can be stealth.\n *\n * @param {Object} state the current state.\n * @param {Number[]} cmIds the module ids to check\n * @returns {Boolean} if any of the activities can be stealth.\n */\n canUseStealth(state, cmIds) {\n return cmIds.some(cmId => {\n const cminfo = state.cm.get(cmId);\n return cminfo?.allowstealth ?? false;\n });\n }\n}\n"],"names":["constructor","reactive","COMPLETIONS","course","state","data","sections","editmode","this","isEditing","highlighted","listedSectionIds","forEach","sectionid","sectioninfo","section","get","push","hassections","length","sectionlist","filter","component","cms","cmlist","cmid","cminfo","cm","hascms","isactive","hasdelegatedsection","delegatesectionid","cmDraggableData","nextcmid","currentindex","indexOf","id","undefined","type","name","sectionDraggableData","number","fileDraggableData","dataTransfer","files","file","cmCompletion","statename","completionstate","hasstate","isoverallcomplete","allItemsArray","items","url","sectionurl","cmInfo","cmItemsArray","delegatedsection","canUseStealth","cmIds","some","cmId","allowstealth"],"mappings":";;;;;;;;;;MAyCIA,YAAYC,eACHA,SAAWA,cAKXC,YAAc,CAAC,aAAc,WAAY,WAAY,QAS9DC,OAAOC,uCAEGC,KAAO,CACTC,SAAU,GACVC,SAAUC,KAAKP,SAASQ,UACxBC,0CAAaN,MAAMD,OAAOO,mEAAe,WAEzBF,KAAKG,iBAAiBP,OAC9BQ,SAA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CACPqB,KAAM,KACNF,GAAImB,OAAOnB,GACXiB,IAAKE,OAAOF,gBAIjBD,YAGJ,CACH,CAACd,KAAM,KAAMF,GAAImB,OAAOnB,GAAIiB,IAAKE,OAAOF,MAWhDK,cAActD,MAAOuD,cACVA,MAAMC,MAAKC,sCACRnC,OAAStB,MAAMuB,GAAGX,IAAI6C,0CACrBnC,MAAAA,cAAAA,OAAQoC"} \ No newline at end of file diff --git a/public/course/format/amd/build/local/courseindex/section.min.js b/public/course/format/amd/build/local/courseindex/section.min.js index df56a5096a7..aa7f768d499 100644 --- a/public/course/format/amd/build/local/courseindex/section.min.js +++ b/public/course/format/amd/build/local/courseindex/section.min.js @@ -8,6 +8,6 @@ define("core_courseformat/local/courseindex/section",["exports","core_courseform * @class core_courseformat/local/courseindex/section * @copyright 2021 Ferran Recio * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_sectiontitle=_interopRequireDefault(_sectiontitle),_dndsection=_interopRequireDefault(_dndsection),_log=_interopRequireDefault(_log);class Component extends _dndsection.default{create(){this.name="courseindex_section",this.selectors={SECTION:"[data-for='section']",SECTION_ITEM:"[data-for='section_item']",SECTION_TITLE:"[data-for='section_title']",CM_LAST:'[data-for="cm"]:last-child',DND_ALLOWED:"[data-courseindexdndallowed='true']"},this.classes={SECTIONHIDDEN:"dimmed",SECTIONCURRENT:"current",LOCKED:"editinprogress",RESTRICTIONS:"restrictions",PAGEITEM:"pageitem",OVERLAYBORDERS:"overlay-preview-borders"},this.id=this.element.dataset.id,this.isPageItem=!1}static init(target,selectors){let element=document.querySelector(target);return element||(_log.default.debug("Init component with id is deprecated, use a query selector instead."),element=document.getElementById(target)),new this({element:element,selectors:selectors})}stateReady(state){var _section$sectionurl;this.configState(state);const sectionItem=this.getElement(this.selectors.SECTION_ITEM);if(this.reactive.isEditing&&this.reactive.supportComponents&&document.querySelector(this.selectors.DND_ALLOWED)){const titleitem=new _sectiontitle.default({...this,element:sectionItem,fullregion:this.element});this.configDragDrop(titleitem)}const section=state.section.get(this.id);window.location.href==(null===(_section$sectionurl=section.sectionurl)||void 0===_section$sectionurl?void 0:_section$sectionurl.replace(/&/g,"&"))&&(this.reactive.dispatch("setPageItem","section",this.id),sectionItem.scrollIntoView())}getWatchers(){return[{watch:"section[".concat(this.id,"]:deleted"),handler:this.remove},{watch:"section[".concat(this.id,"]:updated"),handler:this._refreshSection},{watch:"course.pageItem:updated",handler:this._refreshPageItem}]}getLastCm(){return this.getElement(this.selectors.CM_LAST)}_refreshSection(_ref){var _element$hasrestricti,_element$dragging,_element$locked;let{element:element}=_ref;const sectionItem=this.getElement(this.selectors.SECTION_ITEM);sectionItem.classList.toggle(this.classes.SECTIONHIDDEN,!element.visible),sectionItem.classList.toggle(this.classes.RESTRICTIONS,null!==(_element$hasrestricti=element.hasrestrictions)&&void 0!==_element$hasrestricti&&_element$hasrestricti),this.element.classList.toggle(this.classes.SECTIONCURRENT,element.current),this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.locked=element.locked,this.getElement(this.selectors.SECTION_TITLE).innerHTML=element.title}_refreshPageItem(_ref2){var _element$pageItem,_this$pageItem;let{element:element,state:state}=_ref2;if(!element.pageItem)return;const containsPageItem=this._isPageItemInThisSection(element.pageItem);if(!containsPageItem||this._isParentSectionIndexCollapsed(state))return this.pageItem=!1,void this.getElement(this.selectors.SECTION_ITEM).classList.remove(this.classes.PAGEITEM);!state.section.get(this.id).indexcollapsed||null!==(_element$pageItem=element.pageItem)&&void 0!==_element$pageItem&&_element$pageItem.isStatic?this.pageItem="section"==element.pageItem.type&&element.pageItem.id==this.id:this.pageItem=containsPageItem;this.getElement(this.selectors.SECTION_ITEM).classList.toggle(this.classes.PAGEITEM,null!==(_this$pageItem=this.pageItem)&&void 0!==_this$pageItem&&_this$pageItem),this.pageItem&&!this.reactive.isEditing&&this.element.scrollIntoView({block:"nearest"})}_isPageItemInThisSection(pageItem){if(pageItem.sectionId==this.id)return!0;return!!this.element.querySelector("".concat(this.selectors.SECTION,'[data-id="').concat(pageItem.sectionId,'"]'))}_isParentSectionIndexCollapsed(state){const parentElement=this.element.parentElement.closest(this.selectors.SECTION);if(!parentElement||!parentElement.dataset.id)return null;return!!state.section.get(parentElement.dataset.id).indexcollapsed}async addOverlay(){this.element.classList.add(this.classes.OVERLAYBORDERS)}removeOverlay(){this.element.classList.remove(this.classes.OVERLAYBORDERS)}}return _exports.default=Component,_exports.default})); + */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_sectiontitle=_interopRequireDefault(_sectiontitle),_dndsection=_interopRequireDefault(_dndsection),_log=_interopRequireDefault(_log);class Component extends _dndsection.default{create(){this.name="courseindex_section",this.selectors={SECTION:"[data-for='section']",SECTION_ITEM:"[data-for='section_item']",SECTION_TITLE:"[data-for='section_title']",CM_LAST:'[data-for="cm"]:last-child',DND_ALLOWED:"[data-courseindexdndallowed='true']"},this.classes={SECTIONHIDDEN:"dimmed",SECTIONCURRENT:"current",LOCKED:"editinprogress",RESTRICTIONS:"restrictions",PAGEITEM:"pageitem",OVERLAYBORDERS:"overlay-preview-borders"},this.id=this.element.dataset.id,this.isPageItem=!1}static init(target,selectors){let element=document.querySelector(target);return element||(_log.default.debug("Init component with id is deprecated, use a query selector instead."),element=document.getElementById(target)),new this({element:element,selectors:selectors})}stateReady(state){var _section$sectionurl;this.configState(state);const sectionItem=this.getElement(this.selectors.SECTION_ITEM);if(this.reactive.isEditing&&this.reactive.supportComponents&&document.querySelector(this.selectors.DND_ALLOWED)){const titleitem=new _sectiontitle.default({...this,element:sectionItem,fullregion:this.element});this.configDragDrop(titleitem)}const section=state.section.get(this.id);window.location.href==(null==section||null===(_section$sectionurl=section.sectionurl)||void 0===_section$sectionurl?void 0:_section$sectionurl.replace(/&/g,"&"))&&(this.reactive.dispatch("setPageItem","section",this.id),sectionItem.scrollIntoView())}getWatchers(){return[{watch:"section[".concat(this.id,"]:deleted"),handler:this.remove},{watch:"section[".concat(this.id,"]:updated"),handler:this._refreshSection},{watch:"course.pageItem:updated",handler:this._refreshPageItem}]}getLastCm(){return this.getElement(this.selectors.CM_LAST)}_refreshSection(_ref){var _element$hasrestricti,_element$dragging,_element$locked;let{element:element}=_ref;const sectionItem=this.getElement(this.selectors.SECTION_ITEM);sectionItem.classList.toggle(this.classes.SECTIONHIDDEN,!element.visible),sectionItem.classList.toggle(this.classes.RESTRICTIONS,null!==(_element$hasrestricti=element.hasrestrictions)&&void 0!==_element$hasrestricti&&_element$hasrestricti),this.element.classList.toggle(this.classes.SECTIONCURRENT,element.current),this.element.classList.toggle(this.classes.DRAGGING,null!==(_element$dragging=element.dragging)&&void 0!==_element$dragging&&_element$dragging),this.element.classList.toggle(this.classes.LOCKED,null!==(_element$locked=element.locked)&&void 0!==_element$locked&&_element$locked),this.locked=element.locked,this.getElement(this.selectors.SECTION_TITLE).innerHTML=element.title}_refreshPageItem(_ref2){var _element$pageItem,_this$pageItem;let{element:element,state:state}=_ref2;if(!element.pageItem)return;const containsPageItem=this._isPageItemInThisSection(element.pageItem);if(!containsPageItem||this._isParentSectionIndexCollapsed(state))return this.pageItem=!1,void this.getElement(this.selectors.SECTION_ITEM).classList.remove(this.classes.PAGEITEM);!state.section.get(this.id).indexcollapsed||null!==(_element$pageItem=element.pageItem)&&void 0!==_element$pageItem&&_element$pageItem.isStatic?this.pageItem="section"==element.pageItem.type&&element.pageItem.id==this.id:this.pageItem=containsPageItem;this.getElement(this.selectors.SECTION_ITEM).classList.toggle(this.classes.PAGEITEM,null!==(_this$pageItem=this.pageItem)&&void 0!==_this$pageItem&&_this$pageItem),this.pageItem&&!this.reactive.isEditing&&this.element.scrollIntoView({block:"nearest"})}_isPageItemInThisSection(pageItem){if(pageItem.sectionId==this.id)return!0;return!!this.element.querySelector("".concat(this.selectors.SECTION,'[data-id="').concat(pageItem.sectionId,'"]'))}_isParentSectionIndexCollapsed(state){const parentElement=this.element.parentElement.closest(this.selectors.SECTION);if(!parentElement||!parentElement.dataset.id)return null;return!!state.section.get(parentElement.dataset.id).indexcollapsed}async addOverlay(){this.element.classList.add(this.classes.OVERLAYBORDERS)}removeOverlay(){this.element.classList.remove(this.classes.OVERLAYBORDERS)}}return _exports.default=Component,_exports.default})); //# sourceMappingURL=section.min.js.map \ No newline at end of file diff --git a/public/course/format/amd/build/local/courseindex/section.min.js.map b/public/course/format/amd/build/local/courseindex/section.min.js.map index 2ac1284f61a..681d21ee040 100644 --- a/public/course/format/amd/build/local/courseindex/section.min.js.map +++ b/public/course/format/amd/build/local/courseindex/section.min.js.map @@ -1 +1 @@ -{"version":3,"file":"section.min.js","sources":["../../../src/local/courseindex/section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Course index section component.\n *\n * This component is used to control specific course section interactions like drag and drop.\n *\n * @module core_courseformat/local/courseindex/section\n * @class core_courseformat/local/courseindex/section\n * @copyright 2021 Ferran Recio \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport SectionTitle from 'core_courseformat/local/courseindex/sectiontitle';\nimport DndSection from 'core_courseformat/local/courseeditor/dndsection';\nimport log from \"core/log\";\n\nexport default class Component extends DndSection {\n\n /**\n * Constructor hook.\n */\n create() {\n // Optional component name for debugging.\n this.name = 'courseindex_section';\n // Default query selectors.\n this.selectors = {\n SECTION: `[data-for='section']`,\n SECTION_ITEM: `[data-for='section_item']`,\n SECTION_TITLE: `[data-for='section_title']`,\n CM_LAST: `[data-for=\"cm\"]:last-child`,\n DND_ALLOWED: `[data-courseindexdndallowed='true']`,\n };\n // Default classes to toggle on refresh.\n this.classes = {\n SECTIONHIDDEN: 'dimmed',\n SECTIONCURRENT: 'current',\n LOCKED: 'editinprogress',\n RESTRICTIONS: 'restrictions',\n PAGEITEM: 'pageitem',\n OVERLAYBORDERS: 'overlay-preview-borders',\n };\n\n // We need our id to watch specific events.\n this.id = this.element.dataset.id;\n this.isPageItem = false;\n }\n\n /**\n * Static method to create a component instance form the mustahce template.\n *\n * @param {string} target the DOM main element or its ID\n * @param {object} selectors optional css selector overrides\n * @return {Component}\n */\n static init(target, selectors) {\n let element = document.querySelector(target);\n // TODO Remove this if condition as part of MDL-83851.\n if (!element) {\n log.debug('Init component with id is deprecated, use a query selector instead.');\n element = document.getElementById(target);\n }\n return new this({\n element,\n selectors,\n });\n }\n\n /**\n * Initial state ready method.\n *\n * @param {Object} state the initial state\n */\n stateReady(state) {\n this.configState(state);\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n // Drag and drop is only available for components compatible course formats.\n if (this.reactive.isEditing && this.reactive.supportComponents && document.querySelector(this.selectors.DND_ALLOWED)) {\n // Init the inner dragable element passing the full section as affected region.\n const titleitem = new SectionTitle({\n ...this,\n element: sectionItem,\n fullregion: this.element,\n });\n this.configDragDrop(titleitem);\n }\n // Check if the current url is the section url.\n const section = state.section.get(this.id);\n // Sections urls may be null.\n if (window.location.href == section.sectionurl?.replace(/&/g, \"&\")) {\n this.reactive.dispatch('setPageItem', 'section', this.id);\n sectionItem.scrollIntoView();\n }\n }\n\n /**\n * Component watchers.\n *\n * @returns {Array} of watchers\n */\n getWatchers() {\n return [\n {watch: `section[${this.id}]:deleted`, handler: this.remove},\n {watch: `section[${this.id}]:updated`, handler: this._refreshSection},\n {watch: `course.pageItem:updated`, handler: this._refreshPageItem},\n ];\n }\n\n /**\n * Get the last CM element of that section.\n *\n * @returns {element|null}\n */\n getLastCm() {\n return this.getElement(this.selectors.CM_LAST);\n }\n\n /**\n * Update a course index section using the state information.\n *\n * @param {Object} param details the update details.\n * @param {Object} param.element the section element\n */\n _refreshSection({element}) {\n // Update classes.\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n sectionItem.classList.toggle(this.classes.SECTIONHIDDEN, !element.visible);\n sectionItem.classList.toggle(this.classes.RESTRICTIONS, element.hasrestrictions ?? false);\n this.element.classList.toggle(this.classes.SECTIONCURRENT, element.current);\n this.element.classList.toggle(this.classes.DRAGGING, element.dragging ?? false);\n this.element.classList.toggle(this.classes.LOCKED, element.locked ?? false);\n this.locked = element.locked;\n // Update title.\n this.getElement(this.selectors.SECTION_TITLE).innerHTML = element.title;\n }\n\n /**\n * Handle a page item update.\n *\n * @param {Object} details the update details\n * @param {Object} details.state the state data.\n * @param {Object} details.element the course state data.\n */\n _refreshPageItem({element, state}) {\n if (!element.pageItem) {\n return;\n }\n\n const containsPageItem = this._isPageItemInThisSection(element.pageItem);\n\n if (!containsPageItem || this._isParentSectionIndexCollapsed(state)) {\n this.pageItem = false;\n this.getElement(this.selectors.SECTION_ITEM).classList.remove(this.classes.PAGEITEM);\n return;\n }\n\n const section = state.section.get(this.id);\n if (section.indexcollapsed && !element.pageItem?.isStatic) {\n this.pageItem = containsPageItem;\n } else {\n this.pageItem = (element.pageItem.type == 'section' && element.pageItem.id == this.id);\n }\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n sectionItem.classList.toggle(this.classes.PAGEITEM, this.pageItem ?? false);\n if (this.pageItem && !this.reactive.isEditing) {\n this.element.scrollIntoView({block: \"nearest\"});\n }\n }\n\n /**\n * Check if the page item is inside this section.\n *\n * @private\n * @param {Object} pageItem\n * @param {Object} pageItem.sectionId the current page item section id.\n * @returns {boolean}\n */\n _isPageItemInThisSection(pageItem) {\n if (pageItem.sectionId == this.id) {\n return true;\n }\n // Check for any possible subsections.\n const subsection = this.element.querySelector(`${this.selectors.SECTION}[data-id=\"${pageItem.sectionId}\"]`);\n if (subsection) {\n return true;\n }\n return false;\n }\n\n /**\n * Check if the parent section index is collapsed.\n *\n * @private\n * @param {Object} state the current state\n * @returns {boolean|null} null if no parent section is found.\n */\n _isParentSectionIndexCollapsed(state) {\n const parentElement = this.element.parentElement.closest(this.selectors.SECTION);\n if (!parentElement || !parentElement.dataset.id) {\n return null;\n }\n const parentSection = state.section.get(parentElement.dataset.id);\n return !!parentSection.indexcollapsed;\n }\n\n /**\n * Overridden version of the component addOverlay async method.\n *\n * The course index is not compatible with overlay elements.\n */\n async addOverlay() {\n this.element.classList.add(this.classes.OVERLAYBORDERS);\n }\n\n /**\n * Overridden version of the component removeOverlay.\n *\n * The course index is not compatible with overlay elements.\n */\n removeOverlay() {\n this.element.classList.remove(this.classes.OVERLAYBORDERS);\n }\n}\n"],"names":["Component","DndSection","create","name","selectors","SECTION","SECTION_ITEM","SECTION_TITLE","CM_LAST","DND_ALLOWED","classes","SECTIONHIDDEN","SECTIONCURRENT","LOCKED","RESTRICTIONS","PAGEITEM","OVERLAYBORDERS","id","this","element","dataset","isPageItem","target","document","querySelector","debug","getElementById","stateReady","state","configState","sectionItem","getElement","reactive","isEditing","supportComponents","titleitem","SectionTitle","fullregion","configDragDrop","section","get","window","location","href","sectionurl","_section$sectionurl","replace","dispatch","scrollIntoView","getWatchers","watch","handler","remove","_refreshSection","_refreshPageItem","getLastCm","classList","toggle","visible","hasrestrictions","current","DRAGGING","dragging","locked","innerHTML","title","pageItem","containsPageItem","_isPageItemInThisSection","_isParentSectionIndexCollapsed","indexcollapsed","_element$pageItem","isStatic","type","block","sectionId","parentElement","closest","add","removeOverlay"],"mappings":";;;;;;;;;;iOA8BqBA,kBAAkBC,oBAKnCC,cAESC,KAAO,2BAEPC,UAAY,CACbC,+BACAC,yCACAC,2CACAC,qCACAC,wDAGCC,QAAU,CACXC,cAAe,SACfC,eAAgB,UAChBC,OAAQ,iBACRC,aAAc,eACdC,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AAQ4C,yDACtDA,OAAS5C,QAAQ4C,YAEjBhC,WAAWb,KAAKd,UAAUG,eAAeyD,UAAY7C,QAAQ8C,MAUtEX,iEAAiBnC,QAACA,QAADS,MAAUA,iBAClBT,QAAQ+C,sBAIPC,iBAAmBjD,KAAKkD,yBAAyBjD,QAAQ+C,cAE1DC,kBAAoBjD,KAAKmD,+BAA+BzC,mBACpDsC,UAAW,YACXnC,WAAWb,KAAKd,UAAUE,cAAckD,UAAUJ,OAAOlC,KAAKR,QAAQK,WAI/Da,MAAMW,QAAQC,IAAItB,KAAKD,IAC3BqD,0CAAmBnD,QAAQ+C,uCAARK,kBAAkBC,cAGxCN,SAAqC,WAAzB/C,QAAQ+C,SAASO,MAAqBtD,QAAQ+C,SAASjD,IAAMC,KAAKD,QAF9EiD,SAAWC,iBAIAjD,KAAKa,WAAWb,KAAKd,UAAUE,cACvCkD,UAAUC,OAAOvC,KAAKR,QAAQK,gCAAUG,KAAKgD,oDACrDhD,KAAKgD,WAAahD,KAAKc,SAASC,gBAC3Bd,QAAQ6B,eAAe,CAAC0B,MAAO,YAY5CN,yBAAyBF,aACjBA,SAASS,WAAazD,KAAKD,UACpB,UAGQC,KAAKC,QAAQK,wBAAiBN,KAAKd,UAAUC,6BAAoB6D,SAASS,iBAcjGN,+BAA+BzC,aACrBgD,cAAgB1D,KAAKC,QAAQyD,cAAcC,QAAQ3D,KAAKd,UAAUC,aACnEuE,gBAAkBA,cAAcxD,QAAQH,UAClC,aAEWW,MAAMW,QAAQC,IAAIoC,cAAcxD,QAAQH,IACvCqD,uCASlBnD,QAAQqC,UAAUsB,IAAI5D,KAAKR,QAAQM,gBAQ5C+D,qBACS5D,QAAQqC,UAAUJ,OAAOlC,KAAKR,QAAQM"} \ No newline at end of file +{"version":3,"file":"section.min.js","sources":["../../../src/local/courseindex/section.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Course index section component.\n *\n * This component is used to control specific course section interactions like drag and drop.\n *\n * @module core_courseformat/local/courseindex/section\n * @class core_courseformat/local/courseindex/section\n * @copyright 2021 Ferran Recio \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport SectionTitle from 'core_courseformat/local/courseindex/sectiontitle';\nimport DndSection from 'core_courseformat/local/courseeditor/dndsection';\nimport log from \"core/log\";\n\nexport default class Component extends DndSection {\n\n /**\n * Constructor hook.\n */\n create() {\n // Optional component name for debugging.\n this.name = 'courseindex_section';\n // Default query selectors.\n this.selectors = {\n SECTION: `[data-for='section']`,\n SECTION_ITEM: `[data-for='section_item']`,\n SECTION_TITLE: `[data-for='section_title']`,\n CM_LAST: `[data-for=\"cm\"]:last-child`,\n DND_ALLOWED: `[data-courseindexdndallowed='true']`,\n };\n // Default classes to toggle on refresh.\n this.classes = {\n SECTIONHIDDEN: 'dimmed',\n SECTIONCURRENT: 'current',\n LOCKED: 'editinprogress',\n RESTRICTIONS: 'restrictions',\n PAGEITEM: 'pageitem',\n OVERLAYBORDERS: 'overlay-preview-borders',\n };\n\n // We need our id to watch specific events.\n this.id = this.element.dataset.id;\n this.isPageItem = false;\n }\n\n /**\n * Static method to create a component instance form the mustahce template.\n *\n * @param {string} target the DOM main element or its ID\n * @param {object} selectors optional css selector overrides\n * @return {Component}\n */\n static init(target, selectors) {\n let element = document.querySelector(target);\n // TODO Remove this if condition as part of MDL-83851.\n if (!element) {\n log.debug('Init component with id is deprecated, use a query selector instead.');\n element = document.getElementById(target);\n }\n return new this({\n element,\n selectors,\n });\n }\n\n /**\n * Initial state ready method.\n *\n * @param {Object} state the initial state\n */\n stateReady(state) {\n this.configState(state);\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n // Drag and drop is only available for components compatible course formats.\n if (this.reactive.isEditing && this.reactive.supportComponents && document.querySelector(this.selectors.DND_ALLOWED)) {\n // Init the inner dragable element passing the full section as affected region.\n const titleitem = new SectionTitle({\n ...this,\n element: sectionItem,\n fullregion: this.element,\n });\n this.configDragDrop(titleitem);\n }\n // Check if the current url is the section url.\n const section = state.section.get(this.id);\n // Sections urls may be null.\n if (window.location.href == section?.sectionurl?.replace(/&/g, \"&\")) {\n this.reactive.dispatch('setPageItem', 'section', this.id);\n sectionItem.scrollIntoView();\n }\n }\n\n /**\n * Component watchers.\n *\n * @returns {Array} of watchers\n */\n getWatchers() {\n return [\n {watch: `section[${this.id}]:deleted`, handler: this.remove},\n {watch: `section[${this.id}]:updated`, handler: this._refreshSection},\n {watch: `course.pageItem:updated`, handler: this._refreshPageItem},\n ];\n }\n\n /**\n * Get the last CM element of that section.\n *\n * @returns {element|null}\n */\n getLastCm() {\n return this.getElement(this.selectors.CM_LAST);\n }\n\n /**\n * Update a course index section using the state information.\n *\n * @param {Object} param details the update details.\n * @param {Object} param.element the section element\n */\n _refreshSection({element}) {\n // Update classes.\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n sectionItem.classList.toggle(this.classes.SECTIONHIDDEN, !element.visible);\n sectionItem.classList.toggle(this.classes.RESTRICTIONS, element.hasrestrictions ?? false);\n this.element.classList.toggle(this.classes.SECTIONCURRENT, element.current);\n this.element.classList.toggle(this.classes.DRAGGING, element.dragging ?? false);\n this.element.classList.toggle(this.classes.LOCKED, element.locked ?? false);\n this.locked = element.locked;\n // Update title.\n this.getElement(this.selectors.SECTION_TITLE).innerHTML = element.title;\n }\n\n /**\n * Handle a page item update.\n *\n * @param {Object} details the update details\n * @param {Object} details.state the state data.\n * @param {Object} details.element the course state data.\n */\n _refreshPageItem({element, state}) {\n if (!element.pageItem) {\n return;\n }\n\n const containsPageItem = this._isPageItemInThisSection(element.pageItem);\n\n if (!containsPageItem || this._isParentSectionIndexCollapsed(state)) {\n this.pageItem = false;\n this.getElement(this.selectors.SECTION_ITEM).classList.remove(this.classes.PAGEITEM);\n return;\n }\n\n const section = state.section.get(this.id);\n if (section.indexcollapsed && !element.pageItem?.isStatic) {\n this.pageItem = containsPageItem;\n } else {\n this.pageItem = (element.pageItem.type == 'section' && element.pageItem.id == this.id);\n }\n const sectionItem = this.getElement(this.selectors.SECTION_ITEM);\n sectionItem.classList.toggle(this.classes.PAGEITEM, this.pageItem ?? false);\n if (this.pageItem && !this.reactive.isEditing) {\n this.element.scrollIntoView({block: \"nearest\"});\n }\n }\n\n /**\n * Check if the page item is inside this section.\n *\n * @private\n * @param {Object} pageItem\n * @param {Object} pageItem.sectionId the current page item section id.\n * @returns {boolean}\n */\n _isPageItemInThisSection(pageItem) {\n if (pageItem.sectionId == this.id) {\n return true;\n }\n // Check for any possible subsections.\n const subsection = this.element.querySelector(`${this.selectors.SECTION}[data-id=\"${pageItem.sectionId}\"]`);\n if (subsection) {\n return true;\n }\n return false;\n }\n\n /**\n * Check if the parent section index is collapsed.\n *\n * @private\n * @param {Object} state the current state\n * @returns {boolean|null} null if no parent section is found.\n */\n _isParentSectionIndexCollapsed(state) {\n const parentElement = this.element.parentElement.closest(this.selectors.SECTION);\n if (!parentElement || !parentElement.dataset.id) {\n return null;\n }\n const parentSection = state.section.get(parentElement.dataset.id);\n return !!parentSection.indexcollapsed;\n }\n\n /**\n * Overridden version of the component addOverlay async method.\n *\n * The course index is not compatible with overlay elements.\n */\n async addOverlay() {\n this.element.classList.add(this.classes.OVERLAYBORDERS);\n }\n\n /**\n * Overridden version of the component removeOverlay.\n *\n * The course index is not compatible with overlay elements.\n */\n removeOverlay() {\n this.element.classList.remove(this.classes.OVERLAYBORDERS);\n }\n}\n"],"names":["Component","DndSection","create","name","selectors","SECTION","SECTION_ITEM","SECTION_TITLE","CM_LAST","DND_ALLOWED","classes","SECTIONHIDDEN","SECTIONCURRENT","LOCKED","RESTRICTIONS","PAGEITEM","OVERLAYBORDERS","id","this","element","dataset","isPageItem","target","document","querySelector","debug","getElementById","stateReady","state","configState","sectionItem","getElement","reactive","isEditing","supportComponents","titleitem","SectionTitle","fullregion","configDragDrop","section","get","window","location","href","sectionurl","_section$sectionurl","replace","dispatch","scrollIntoView","getWatchers","watch","handler","remove","_refreshSection","_refreshPageItem","getLastCm","classList","toggle","visible","hasrestrictions","current","DRAGGING","dragging","locked","innerHTML","title","pageItem","containsPageItem","_isPageItemInThisSection","_isParentSectionIndexCollapsed","indexcollapsed","_element$pageItem","isStatic","type","block","sectionId","parentElement","closest","add","removeOverlay"],"mappings":";;;;;;;;;;iOA8BqBA,kBAAkBC,oBAKnCC,cAESC,KAAO,2BAEPC,UAAY,CACbC,+BACAC,yCACAC,2CACAC,qCACAC,wDAGCC,QAAU,CACXC,cAAe,SACfC,eAAgB,UAChBC,OAAQ,iBACRC,aAAc,eACdC,SAAU,WACVC,eAAgB,gCAIfC,GAAKC,KAAKC,QAAQC,QAAQH,QAC1BI,YAAa,cAUVC,OAAQlB,eACZe,QAAUI,SAASC,cAAcF,eAEhCH,uBACGM,MAAM,uEACVN,QAAUI,SAASG,eAAeJ,SAE/B,IAAIJ,KAAK,CACZC,QAAAA,QACAf,UAAAA,YASRuB,WAAWC,oCACFC,YAAYD,aACXE,YAAcZ,KAAKa,WAAWb,KAAKd,UAAUE,iBAE/CY,KAAKc,SAASC,WAAaf,KAAKc,SAASE,mBAAqBX,SAASC,cAAcN,KAAKd,UAAUK,aAAc,OAE5G0B,UAAY,IAAIC,sBAAa,IAC5BlB,KACHC,QAASW,YACTO,WAAYnB,KAAKC,eAEhBmB,eAAeH,iBAGlBI,QAAUX,MAAMW,QAAQC,IAAItB,KAAKD,IAEnCwB,OAAOC,SAASC,OAAQJ,MAAAA,qCAAAA,QAASK,iDAATC,oBAAqBC,QAAQ,SAAU,aAC1Dd,SAASe,SAAS,cAAe,UAAW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AAKgD,WAAahD,KAAKc,SAASC,gBAC3Bd,QAAQ6B,eAAe,CAAC0B,MAAO,YAY5CN,yBAAyBF,aACjBA,SAASS,WAAazD,KAAKD,UACpB,UAGQC,KAAKC,QAAQK,wBAAiBN,KAAKd,UAAUC,6BAAoB6D,SAASS,iBAcjGN,+BAA+BzC,aACrBgD,cAAgB1D,KAAKC,QAAQyD,cAAcC,QAAQ3D,KAAKd,UAAUC,aACnEuE,gBAAkBA,cAAcxD,QAAQH,UAClC,aAEWW,MAAMW,QAAQC,IAAIoC,cAAcxD,QAAQH,IACvCqD,uCASlBnD,QAAQqC,UAAUsB,IAAI5D,KAAKR,QAAQM,gBAQ5C+D,qBACS5D,QAAQqC,UAAUJ,OAAOlC,KAAKR,QAAQM"} \ No newline at end of file diff --git a/public/course/format/amd/src/local/courseeditor/exporter.js b/public/course/format/amd/src/local/courseeditor/exporter.js index b4b48698486..af8dc15df20 100644 --- a/public/course/format/amd/src/local/courseeditor/exporter.js +++ b/public/course/format/amd/src/local/courseeditor/exporter.js @@ -124,7 +124,7 @@ export default class { sectioninfo: false, // Init to false to prevent mustache recursion loops. }; if (cminfo.hasdelegatedsection) { - const sectioninfo = state.section.get(cminfo.delegatesectionid); + const sectioninfo = state.section.get(cminfo.delegatesectionid) ?? {}; cm.sectioninfo = this.section(state, sectioninfo); } return cm; @@ -279,20 +279,22 @@ export default class { if (cmInfo.hasdelegatedsection) { const items = []; const delegatedsection = state.section.get(cmInfo.delegatesectionid); - items.push({ - type: 'section', - id: delegatedsection.id, - url: delegatedsection.sectionurl - }); - const delegatedCmlist = delegatedsection.cmlist ?? []; - delegatedCmlist.forEach(cmid => { - const cmInfo = state.cm.get(cmid); + if (delegatedsection) { items.push({ - type: 'cm', - id: cmInfo.id, - url: cmInfo.url + type: 'section', + id: delegatedsection.id, + url: delegatedsection.sectionurl }); - }); + const delegatedCmlist = delegatedsection.cmlist ?? []; + delegatedCmlist.forEach(cmid => { + const cmInfo = state.cm.get(cmid); + items.push({ + type: 'cm', + id: cmInfo.id, + url: cmInfo.url + }); + }); + } return items; } diff --git a/public/course/format/amd/src/local/courseindex/section.js b/public/course/format/amd/src/local/courseindex/section.js index c432b99ecd1..d5e3673f056 100644 --- a/public/course/format/amd/src/local/courseindex/section.js +++ b/public/course/format/amd/src/local/courseindex/section.js @@ -100,7 +100,7 @@ export default class Component extends DndSection { // Check if the current url is the section url. const section = state.section.get(this.id); // Sections urls may be null. - if (window.location.href == section.sectionurl?.replace(/&/g, "&")) { + if (window.location.href == section?.sectionurl?.replace(/&/g, "&")) { this.reactive.dispatch('setPageItem', 'section', this.id); sectionItem.scrollIntoView(); }