diff --git a/amd/build/delete_page.min.js b/amd/build/delete_page.min.js index 0b20236c..a41ced3f 100644 --- a/amd/build/delete_page.min.js +++ b/amd/build/delete_page.min.js @@ -1,3 +1,3 @@ -define("mod_mootimeter/delete_page",["exports","core/ajax","core/log","core/modal_delete_cancel","core/modal_events","core/str","mod_mootimeter/reload_page","mod_mootimeter/utils"],(function(_exports,_ajax,_log,_modal_delete_cancel,_modal_events,_str,_reload_page,_utils){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_log=_interopRequireDefault(_log),_modal_delete_cancel=_interopRequireDefault(_modal_delete_cancel),_modal_events=_interopRequireDefault(_modal_events);_exports.init=async id=>{const pageid=document.getElementById("mootimeterstate").dataset.pageid,modal=await _modal_delete_cancel.default.create({title:(0,_str.get_string)("delete","core"),body:(0,_str.get_string)("areyousure")});modal.getRoot().on(_modal_events.default.delete,(function(){execDeletePage(pageid)})),document.getElementById(id).addEventListener("click",(()=>{modal.show()}));const execDeletePage=async pageid=>{var mtmstate=document.getElementById("mootimeterstate");const response=await(pageid=>(0,_ajax.call)([{methodname:"mod_mootimeter_delete_page",args:{pageid:pageid}}])[0])(pageid);200==response.code?((0,_utils.removeGetParam)("pageid",window.location.href),mtmstate.setAttribute("data-pageid",0),(0,_reload_page.execReloadPage)(0,response.cmid)):_log.default.error(response.string)}}})); +define("mod_mootimeter/delete_page",["exports","core/ajax","core/log","core/modal_delete_cancel","core/modal_events","core/str","mod_mootimeter/reload_page","mod_mootimeter/utils"],(function(_exports,_ajax,_log,_modal_delete_cancel,_modal_events,_str,_reload_page,_utils){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_log=_interopRequireDefault(_log),_modal_delete_cancel=_interopRequireDefault(_modal_delete_cancel),_modal_events=_interopRequireDefault(_modal_events);_exports.init=async id=>{const pageid=document.getElementById("mootimeterstate").dataset.pageid,modal=await _modal_delete_cancel.default.create({title:(0,_str.get_string)("delete","core"),body:(0,_str.get_string)("areyousure")});modal.getRoot().on(_modal_events.default.delete,(function(){execDeletePage(pageid)}));const element=document.getElementById(id);element&&element.addEventListener("click",(()=>{modal.show()}));const execDeletePage=async pageid=>{var mtmstate=document.getElementById("mootimeterstate");const response=await(pageid=>(0,_ajax.call)([{methodname:"mod_mootimeter_delete_page",args:{pageid:pageid}}])[0])(pageid);200==response.code?((0,_utils.removeGetParam)("pageid",window.location.href),mtmstate.setAttribute("data-pageid",0),(0,_reload_page.execReloadPage)(0,response.cmid)):_log.default.error(response.string)}}})); //# sourceMappingURL=delete_page.min.js.map \ No newline at end of file diff --git a/amd/build/delete_page.min.js.map b/amd/build/delete_page.min.js.map index b5c1c865..711a35d0 100644 --- a/amd/build/delete_page.min.js.map +++ b/amd/build/delete_page.min.js.map @@ -1 +1 @@ -{"version":3,"file":"delete_page.min.js","sources":["../src/delete_page.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\nimport ModalDeleteCancel from 'core/modal_delete_cancel';\nimport ModalEvents from 'core/modal_events';\nimport {get_string as getString} from 'core/str';\nimport {execReloadPage as reloadPage} from 'mod_mootimeter/reload_page';\nimport {removeGetParam} from 'mod_mootimeter/utils';\n\nexport const init = async(id) => {\n const pageid = document.getElementById('mootimeterstate').dataset.pageid;\n\n const modal = await ModalDeleteCancel.create({\n title: getString('delete', 'core'),\n body: getString('areyousure'),\n });\n\n modal.getRoot().on(ModalEvents.delete, function() {\n execDeletePage(pageid);\n });\n\n document.getElementById(id).addEventListener('click', () => {\n modal.show();\n });\n\n /**\n * Call to store input value\n * @param {int} pageid\n * @returns {mixed}\n */\n const deletePageCall = (\n pageid,\n ) => fetchMany([{\n methodname: 'mod_mootimeter_delete_page',\n args: {\n pageid\n },\n }])[0];\n\n /**\n * Executes the call to store input value.\n * @param {int} pageid\n */\n const execDeletePage = async(pageid) => {\n var mtmstate = document.getElementById('mootimeterstate');\n const response = await deletePageCall(pageid);\n if (response.code != 200) {\n Log.error(response.string);\n return;\n }\n removeGetParam('pageid', window.location.href);\n mtmstate.setAttribute('data-pageid', 0);\n reloadPage(0, response.cmid);\n };\n};\n"],"names":["async","pageid","document","getElementById","dataset","modal","ModalDeleteCancel","create","title","body","getRoot","on","ModalEvents","delete","execDeletePage","id","addEventListener","show","mtmstate","response","methodname","args","deletePageCall","code","window","location","href","setAttribute","cmid","error","string"],"mappings":"qlBAQoBA,MAAAA,WACVC,OAASC,SAASC,eAAe,mBAAmBC,QAAQH,OAE5DI,YAAcC,6BAAkBC,OAAO,CACzCC,OAAO,mBAAU,SAAU,QAC3BC,MAAM,mBAAU,gBAGpBJ,MAAMK,UAAUC,GAAGC,sBAAYC,QAAQ,WACnCC,eAAeb,WAGnBC,SAASC,eAAeY,IAAIC,iBAAiB,SAAS,KAClDX,MAAMY,gBAqBJH,eAAiBd,MAAAA,aACfkB,SAAWhB,SAASC,eAAe,yBACjCgB,cAdNlB,CAAAA,SACC,cAAU,CAAC,CACZmB,WAAY,6BACZC,KAAM,CACFpB,OAAAA,WAEJ,GAQuBqB,CAAerB,QACjB,KAAjBkB,SAASI,gCAIE,SAAUC,OAAOC,SAASC,MACzCR,SAASS,aAAa,cAAe,mCAC1B,EAAGR,SAASS,oBALfC,MAAMV,SAASW"} \ No newline at end of file +{"version":3,"file":"delete_page.min.js","sources":["../src/delete_page.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\nimport ModalDeleteCancel from 'core/modal_delete_cancel';\nimport ModalEvents from 'core/modal_events';\nimport {get_string as getString} from 'core/str';\nimport {execReloadPage as reloadPage} from 'mod_mootimeter/reload_page';\nimport {removeGetParam} from 'mod_mootimeter/utils';\n\nexport const init = async(id) => {\n const pageid = document.getElementById('mootimeterstate').dataset.pageid;\n\n const modal = await ModalDeleteCancel.create({\n title: getString('delete', 'core'),\n body: getString('areyousure'),\n });\n\n modal.getRoot().on(ModalEvents.delete, function() {\n execDeletePage(pageid);\n });\n\n const element = document.getElementById(id);\n if (element) {\n element.addEventListener('click', () => {\n modal.show();\n });\n }\n\n /**\n * Call to store input value\n * @param {int} pageid\n * @returns {mixed}\n */\n const deletePageCall = (\n pageid,\n ) => fetchMany([{\n methodname: 'mod_mootimeter_delete_page',\n args: {\n pageid\n },\n }])[0];\n\n /**\n * Executes the call to store input value.\n * @param {int} pageid\n */\n const execDeletePage = async(pageid) => {\n var mtmstate = document.getElementById('mootimeterstate');\n const response = await deletePageCall(pageid);\n if (response.code != 200) {\n Log.error(response.string);\n return;\n }\n removeGetParam('pageid', window.location.href);\n mtmstate.setAttribute('data-pageid', 0);\n reloadPage(0, response.cmid);\n };\n};\n"],"names":["async","pageid","document","getElementById","dataset","modal","ModalDeleteCancel","create","title","body","getRoot","on","ModalEvents","delete","execDeletePage","element","id","addEventListener","show","mtmstate","response","methodname","args","deletePageCall","code","window","location","href","setAttribute","cmid","error","string"],"mappings":"qlBAQoBA,MAAAA,WACVC,OAASC,SAASC,eAAe,mBAAmBC,QAAQH,OAE5DI,YAAcC,6BAAkBC,OAAO,CACzCC,OAAO,mBAAU,SAAU,QAC3BC,MAAM,mBAAU,gBAGpBJ,MAAMK,UAAUC,GAAGC,sBAAYC,QAAQ,WACnCC,eAAeb,iBAGbc,QAAUb,SAASC,eAAea,IACpCD,SACAA,QAAQE,iBAAiB,SAAS,KAC9BZ,MAAMa,gBAsBRJ,eAAiBd,MAAAA,aACfmB,SAAWjB,SAASC,eAAe,yBACjCiB,cAdNnB,CAAAA,SACC,cAAU,CAAC,CACZoB,WAAY,6BACZC,KAAM,CACFrB,OAAAA,WAEJ,GAQuBsB,CAAetB,QACjB,KAAjBmB,SAASI,gCAIE,SAAUC,OAAOC,SAASC,MACzCR,SAASS,aAAa,cAAe,mCAC1B,EAAGR,SAASS,oBALfC,MAAMV,SAASW"} \ No newline at end of file diff --git a/amd/build/handler_input.min.js b/amd/build/handler_input.min.js index f6dc6d86..1b538f9d 100644 --- a/amd/build/handler_input.min.js +++ b/amd/build/handler_input.min.js @@ -1,3 +1,3 @@ -define("mod_mootimeter/handler_input",["exports","core/ajax","core/log"],(function(_exports,_ajax,_log){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_log=(obj=_log)&&obj.__esModule?obj:{default:obj};_exports.init=uniqueID=>{const obj=document.getElementById(uniqueID);document.getElementById(uniqueID)&&(obj.addEventListener("focusin",(function(){document.getElementById("mootimeterstate").setAttribute("data-lockpagereload",1)})),obj.addEventListener("focusout",(function(){const id=obj.id,pageid=obj.dataset.pageid,ajaxmethode=obj.dataset.ajaxmethode,inputname=obj.dataset.name,inputvalue=document.getElementById(id).value,thisDataset=JSON.stringify(obj.dataset);return delete document.getElementById("mootimeterstate").dataset.lockpagereload,execStoreInputValue(ajaxmethode,pageid,inputname,inputvalue,thisDataset)})))};const execStoreInputValue=async(ajaxmethode,pageid,inputname,inputvalue,thisDataset)=>{const response=await((ajaxmethode,pageid,inputname,inputvalue,thisDataset)=>(0,_ajax.call)([{methodname:ajaxmethode,args:{pageid:pageid,inputname:inputname,inputvalue:inputvalue,thisDataset:thisDataset}}])[0])(ajaxmethode,pageid,inputname,inputvalue,thisDataset);200!=response.code&&_log.default.error(response.string),200==response.code&&_log.default.info(response.string)}})); +define("mod_mootimeter/handler_input",["exports","core/ajax","core/log","core/notification"],(function(_exports,_ajax,_log,_notification){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_log=(obj=_log)&&obj.__esModule?obj:{default:obj};_exports.init=uniqueID=>{const obj=document.getElementById(uniqueID);document.getElementById(uniqueID)&&(obj.addEventListener("focusin",(function(){document.getElementById("mootimeterstate").setAttribute("data-lockpagereload",1)})),obj.addEventListener("focusout",(function(){const id=obj.id,pageid=obj.dataset.pageid,ajaxmethode=obj.dataset.ajaxmethode,inputname=obj.dataset.name,inputvalue=document.getElementById(id).value,thisDataset=JSON.stringify(obj.dataset);return delete document.getElementById("mootimeterstate").dataset.lockpagereload,execStoreInputValue(ajaxmethode,pageid,inputname,inputvalue,thisDataset)})))};const execStoreInputValue=async(ajaxmethode,pageid,inputname,inputvalue,thisDataset)=>{let response=null;try{response=await((ajaxmethode,pageid,inputname,inputvalue,thisDataset)=>(0,_ajax.call)([{methodname:ajaxmethode,args:{pageid:pageid,inputname:inputname,inputvalue:inputvalue,thisDataset:thisDataset}}])[0])(ajaxmethode,pageid,inputname,inputvalue,thisDataset)}catch(err){(0,_notification.exception)(err)}200!=response.code&&_log.default.error(response.string),200==response.code&&_log.default.info(response.string)}})); //# sourceMappingURL=handler_input.min.js.map \ No newline at end of file diff --git a/amd/build/handler_input.min.js.map b/amd/build/handler_input.min.js.map index 34aaab64..739d0ff4 100644 --- a/amd/build/handler_input.min.js.map +++ b/amd/build/handler_input.min.js.map @@ -1 +1 @@ -{"version":3,"file":"handler_input.min.js","sources":["../src/handler_input.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\n\nexport const init = (uniqueID) => {\n const obj = document.getElementById(uniqueID);\n\n if (!document.getElementById(uniqueID)) {\n return;\n }\n\n obj.addEventListener(\"focusin\", mootimeterlockstore);\n\n obj.addEventListener(\"focusout\", mootimeterStoreInput);\n\n /**\n * Store the value.\n * @returns {mixed}\n */\n function mootimeterStoreInput() {\n const id = obj.id;\n const pageid = obj.dataset.pageid;\n const ajaxmethode = obj.dataset.ajaxmethode;\n const inputname = obj.dataset.name;\n const inputvalue = document.getElementById(id).value;\n const thisDataset = JSON.stringify(obj.dataset);\n\n var mtmstate = document.getElementById('mootimeterstate');\n delete mtmstate.dataset.lockpagereload;\n\n return execStoreInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset);\n }\n\n /**\n * Callback to lock pagereload until focusout event is triggered.\n */\n function mootimeterlockstore() {\n var mtmstate = document.getElementById('mootimeterstate');\n mtmstate.setAttribute('data-lockpagereload', 1);\n }\n};\n\n/**\n * Call to store input value\n * @param {string} ajaxmethode\n * @param {int} pageid\n * @param {string} inputname\n * @param {string} inputvalue\n * @param {string} thisDataset\n * @returns {mixed}\n */\nconst storeInputValue = (\n ajaxmethode,\n pageid,\n inputname,\n inputvalue,\n thisDataset\n) => fetchMany([{\n methodname: ajaxmethode,\n args: {\n pageid,\n inputname,\n inputvalue,\n thisDataset\n },\n}])[0];\n\n/**\n * Executes the call to store input value.\n * @param {string} ajaxmethode\n * @param {int} pageid\n * @param {string} inputname\n * @param {string} inputvalue\n * @param {string} thisDataset\n */\nconst execStoreInputValue = async(ajaxmethode, pageid, inputname, inputvalue, thisDataset) => {\n const response = await storeInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset);\n if (response.code != 200) {\n Log.error(response.string);\n }\n if (response.code == 200) {\n Log.info(response.string);\n }\n};\n"],"names":["uniqueID","obj","document","getElementById","addEventListener","setAttribute","id","pageid","dataset","ajaxmethode","inputname","name","inputvalue","value","thisDataset","JSON","stringify","lockpagereload","execStoreInputValue","async","response","methodname","args","storeInputValue","code","error","string","info"],"mappings":"6PAGqBA,iBACXC,IAAMC,SAASC,eAAeH,UAE/BE,SAASC,eAAeH,YAI7BC,IAAIG,iBAAiB,sBA0BFF,SAASC,eAAe,mBAC9BE,aAAa,sBAAuB,MAzBjDJ,IAAIG,iBAAiB,6BAOXE,GAAKL,IAAIK,GACTC,OAASN,IAAIO,QAAQD,OACrBE,YAAcR,IAAIO,QAAQC,YAC1BC,UAAYT,IAAIO,QAAQG,KACxBC,WAAaV,SAASC,eAAeG,IAAIO,MACzCC,YAAcC,KAAKC,UAAUf,IAAIO,uBAExBN,SAASC,eAAe,mBACvBK,QAAQS,eAEjBC,oBAAoBT,YAAaF,OAAQG,UAAWE,WAAYE,wBA6CzEI,oBAAsBC,MAAMV,YAAaF,OAAQG,UAAWE,WAAYE,qBACpEM,cAzBc,EACpBX,YACAF,OACAG,UACAE,WACAE,eACC,cAAU,CAAC,CACZO,WAAYZ,YACZa,KAAM,CACFf,OAAAA,OACAG,UAAAA,UACAE,WAAAA,WACAE,YAAAA,gBAEJ,GAWuBS,CAAgBd,YAAaF,OAAQG,UAAWE,WAAYE,aAC9D,KAAjBM,SAASI,mBACLC,MAAML,SAASM,QAEF,KAAjBN,SAASI,mBACLG,KAAKP,SAASM"} \ No newline at end of file +{"version":3,"file":"handler_input.min.js","sources":["../src/handler_input.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\nimport {exception as displayException} from 'core/notification';\n\nexport const init = (uniqueID) => {\n const obj = document.getElementById(uniqueID);\n\n if (!document.getElementById(uniqueID)) {\n return;\n }\n\n obj.addEventListener(\"focusin\", mootimeterlockstore);\n\n obj.addEventListener(\"focusout\", mootimeterStoreInput);\n\n /**\n * Store the value.\n * @returns {mixed}\n */\n function mootimeterStoreInput() {\n const id = obj.id;\n const pageid = obj.dataset.pageid;\n const ajaxmethode = obj.dataset.ajaxmethode;\n const inputname = obj.dataset.name;\n const inputvalue = document.getElementById(id).value;\n const thisDataset = JSON.stringify(obj.dataset);\n\n var mtmstate = document.getElementById('mootimeterstate');\n delete mtmstate.dataset.lockpagereload;\n\n return execStoreInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset);\n }\n\n /**\n * Callback to lock pagereload until focusout event is triggered.\n */\n function mootimeterlockstore() {\n var mtmstate = document.getElementById('mootimeterstate');\n mtmstate.setAttribute('data-lockpagereload', 1);\n }\n};\n\n/**\n * Call to store input value\n * @param {string} ajaxmethode\n * @param {int} pageid\n * @param {string} inputname\n * @param {string} inputvalue\n * @param {string} thisDataset\n * @returns {mixed}\n */\nconst storeInputValue = (\n ajaxmethode,\n pageid,\n inputname,\n inputvalue,\n thisDataset\n) => fetchMany([{\n methodname: ajaxmethode,\n args: {\n pageid,\n inputname,\n inputvalue,\n thisDataset\n },\n}])[0];\n\n/**\n * Executes the call to store input value.\n * @param {string} ajaxmethode\n * @param {int} pageid\n * @param {string} inputname\n * @param {string} inputvalue\n * @param {string} thisDataset\n */\nconst execStoreInputValue = async(ajaxmethode, pageid, inputname, inputvalue, thisDataset) => {\n let response = null;\n try {\n response = await storeInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset);\n } catch (err) {\n displayException(err);\n }\n if (response.code != 200) {\n Log.error(response.string);\n }\n if (response.code == 200) {\n Log.info(response.string);\n }\n};\n"],"names":["uniqueID","obj","document","getElementById","addEventListener","setAttribute","id","pageid","dataset","ajaxmethode","inputname","name","inputvalue","value","thisDataset","JSON","stringify","lockpagereload","execStoreInputValue","async","response","methodname","args","storeInputValue","err","code","error","string","info"],"mappings":"+RAIqBA,iBACXC,IAAMC,SAASC,eAAeH,UAE/BE,SAASC,eAAeH,YAI7BC,IAAIG,iBAAiB,sBA0BFF,SAASC,eAAe,mBAC9BE,aAAa,sBAAuB,MAzBjDJ,IAAIG,iBAAiB,6BAOXE,GAAKL,IAAIK,GACTC,OAASN,IAAIO,QAAQD,OACrBE,YAAcR,IAAIO,QAAQC,YAC1BC,UAAYT,IAAIO,QAAQG,KACxBC,WAAaV,SAASC,eAAeG,IAAIO,MACzCC,YAAcC,KAAKC,UAAUf,IAAIO,uBAExBN,SAASC,eAAe,mBACvBK,QAAQS,eAEjBC,oBAAoBT,YAAaF,OAAQG,UAAWE,WAAYE,wBA6CzEI,oBAAsBC,MAAMV,YAAaF,OAAQG,UAAWE,WAAYE,mBACtEM,SAAW,SAEXA,cA3BgB,EACpBX,YACAF,OACAG,UACAE,WACAE,eACC,cAAU,CAAC,CACZO,WAAYZ,YACZa,KAAM,CACFf,OAAAA,OACAG,UAAAA,UACAE,WAAAA,WACAE,YAAAA,gBAEJ,GAaqBS,CAAgBd,YAAaF,OAAQG,UAAWE,WAAYE,aAC/E,MAAOU,iCACYA,KAEA,KAAjBJ,SAASK,mBACLC,MAAMN,SAASO,QAEF,KAAjBP,SAASK,mBACLG,KAAKR,SAASO"} \ No newline at end of file diff --git a/amd/build/reload_page.min.js b/amd/build/reload_page.min.js index cac09565..3df2590b 100644 --- a/amd/build/reload_page.min.js +++ b/amd/build/reload_page.min.js @@ -1,3 +1,3 @@ -define("mod_mootimeter/reload_page",["exports","core/ajax","core/log","core/notification","core/templates","mod_mootimeter/reload_pagelist","mod_mootimeter/utils","mod_mootimeter/get_mootimeterstate"],(function(_exports,_ajax,_log,_notification,_templates,_reload_pagelist,_utils,_get_mootimeterstate){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.reloadSettingsCol=_exports.reloadPageContent=_exports.reloadContentMenu=_exports.init=_exports.execReloadPage=void 0,_log=_interopRequireDefault(_log),_templates=_interopRequireDefault(_templates);_exports.init=uniqueID=>{const obj=document.getElementById(uniqueID);obj&&obj.addEventListener("click",(function(){var pageid=0,dataset="";this.dataset&&(pageid=this.dataset.pageid,dataset=this.dataset);null!=pageid&&"undefined"!=pageid&&0!=pageid.length||(pageid=0);const queryString=window.location.search,cmid=new URLSearchParams(queryString).get("id");execReloadPage(pageid,cmid,dataset)}))};const execReloadPage=async(pageid,cmid,dataset)=>{var mtmstate=document.getElementById("mootimeterstate");if(mtmstate.dataset.lockpagereload)return;dataset?Object.assign(dataset,(0,_utils.getGetParams)()):dataset=(0,_utils.getGetParams)(),dataset=JSON.stringify(dataset),0!=pageid&&await(0,_get_mootimeterstate.getMootimeterstate)(),mtmstate=document.getElementById("mootimeterstate");const response=await((pageid,cmid,dataset)=>(0,_ajax.call)([{methodname:"mod_mootimeter_get_pagecontentparams",args:{pageid:pageid,cmid:cmid,dataset:dataset}}])[0])(pageid,cmid,dataset);if(200!=response.code&&_log.default.error(response.string),200==response.code){const pageparmas=JSON.parse(response.pageparams);mtmstate.dataset.contentchangedat_prev&&mtmstate.dataset.contentchangedat_prev==mtmstate.contentchangedat&&mtmstate.dataset.teacherpermissiontoview_prev&&mtmstate.dataset.teacherpermissiontoview_prev==mtmstate.dataset.teacherpermissiontoviewteacherpermissiontoview||(reloadPageContent(pageparmas.pagecontent),(0,_reload_pagelist.execReloadPagelist)(pageid,cmid,!0)),mtmstate.dataset.pagecontentmenuchangedat_prev&&mtmstate.dataset.pagecontentmenuchangedat_prev==mtmstate.settingschangedat||reloadContentMenu(pageparmas.contentmenu),!pageparmas.colsettings||mtmstate.dataset.settingschangedat_prev&&mtmstate.dataset.settingschangedat_prev==mtmstate.settingschangedat||reloadSettingsCol(pageparmas.colsettings),pageparmas.pageid&&(mtmstate.setAttribute("data-pageid",pageparmas.pageid),(0,_utils.setGetParam)("pageid",pageparmas.pageid))}};_exports.execReloadPage=execReloadPage;const reloadSettingsCol=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.replaceNodeContents("#mootimeter-col-settings",html,js),mtmstate.setAttribute("data-settingschangedat_prev",mtmstate.dataset.settingschangedat),!0})).catch((error=>(0,_notification.exception)(error)))};_exports.reloadSettingsCol=reloadSettingsCol;const reloadContentMenu=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");if(_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref2=>{let{html:html,js:js}=_ref2;return _templates.default.replaceNode("#mootimeter-pagecontentmenu",html,js),mtmstate.setAttribute("data-pagecontentmenuchangedat_prev",mtmstate.dataset.pagecontentmenuchangedat),!0})).catch((error=>(0,_notification.exception)(error))),pageparmas.sp)for(const[key,value]of Object.entries(pageparmas.sp))(0,_utils.setGetParam)(key,value)};_exports.reloadContentMenu=reloadContentMenu;const reloadPageContent=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref3=>{let{html:html,js:js}=_ref3;return _templates.default.replaceNodeContents("#mootimeter-pagecontent",html,js),mtmstate.setAttribute("data-contentchangedat_prev",mtmstate.dataset.contentchangedat),mtmstate.setAttribute("data-teacherpermissiontoview_prev",mtmstate.dataset.teacherpermissiontoview),!0})).catch((error=>(0,_notification.exception)(error)))};_exports.reloadPageContent=reloadPageContent})); +define("mod_mootimeter/reload_page",["exports","core/ajax","core/log","core/notification","core/templates","mod_mootimeter/reload_pagelist","mod_mootimeter/utils","mod_mootimeter/get_mootimeterstate"],(function(_exports,_ajax,_log,_notification,_templates,_reload_pagelist,_utils,_get_mootimeterstate){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.reloadSettingsCol=_exports.reloadPageContent=_exports.reloadContentMenu=_exports.init=_exports.execReloadPage=void 0,_log=_interopRequireDefault(_log),_templates=_interopRequireDefault(_templates);_exports.init=uniqueID=>{const obj=document.getElementById(uniqueID);obj&&obj.addEventListener("click",(function(){var pageid=0,dataset="";this.dataset&&(pageid=this.dataset.pageid,dataset=this.dataset);null!=pageid&&"undefined"!=pageid&&0!=pageid.length||(pageid=0);const queryString=window.location.search,cmid=new URLSearchParams(queryString).get("id");execReloadPage(pageid,cmid,dataset)}))};const execReloadPage=async(pageid,cmid,dataset)=>{var mtmstate=document.getElementById("mootimeterstate");if(mtmstate.dataset.lockpagereload)return;dataset?Object.assign(dataset,(0,_utils.getGetParams)()):dataset=(0,_utils.getGetParams)(),dataset=JSON.stringify(dataset),0!=pageid&&await(0,_get_mootimeterstate.getMootimeterstate)(),mtmstate=document.getElementById("mootimeterstate");const response=await((pageid,cmid,dataset)=>(0,_ajax.call)([{methodname:"mod_mootimeter_get_pagecontentparams",args:{pageid:pageid,cmid:cmid,dataset:dataset}}])[0])(pageid,cmid,dataset);if(200!=response.code&&_log.default.error(response.string),200==response.code){const pageparmas=JSON.parse(response.pageparams);mtmstate.dataset.contentchangedat_prev&&mtmstate.dataset.contentchangedat_prev==mtmstate.contentchangedat&&mtmstate.dataset.teacherpermissiontoview_prev&&mtmstate.dataset.teacherpermissiontoview_prev==mtmstate.dataset.teacherpermissiontoviewteacherpermissiontoview||(reloadPageContent(pageparmas.pagecontent),(0,_reload_pagelist.execReloadPagelist)(pageid,cmid,!0)),mtmstate.dataset.pagecontentmenuchangedat_prev&&mtmstate.dataset.pagecontentmenuchangedat_prev==mtmstate.settingschangedat||pageparmas.contentmenu&&reloadContentMenu(pageparmas.contentmenu),!pageparmas.colsettings||mtmstate.dataset.settingschangedat_prev&&mtmstate.dataset.settingschangedat_prev==mtmstate.settingschangedat||reloadSettingsCol(pageparmas.colsettings),pageparmas.pageid&&(mtmstate.setAttribute("data-pageid",pageparmas.pageid),(0,_utils.setGetParam)("pageid",pageparmas.pageid))}};_exports.execReloadPage=execReloadPage;const reloadSettingsCol=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.replaceNodeContents("#mootimeter-col-settings",html,js),mtmstate.setAttribute("data-settingschangedat_prev",mtmstate.dataset.settingschangedat),!0})).catch((error=>(0,_notification.exception)(error)))};_exports.reloadSettingsCol=reloadSettingsCol;const reloadContentMenu=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");if(_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref2=>{let{html:html,js:js}=_ref2;return _templates.default.replaceNode("#mootimeter-pagecontentmenu",html,js),mtmstate.setAttribute("data-pagecontentmenuchangedat_prev",mtmstate.dataset.pagecontentmenuchangedat),!0})).catch((error=>(0,_notification.exception)(error))),pageparmas.sp)for(const[key,value]of Object.entries(pageparmas.sp))(0,_utils.setGetParam)(key,value)};_exports.reloadContentMenu=reloadContentMenu;const reloadPageContent=async pageparmas=>{var mtmstate=document.getElementById("mootimeterstate");_templates.default.renderForPromise(pageparmas.template,pageparmas).then((_ref3=>{let{html:html,js:js}=_ref3;return _templates.default.replaceNodeContents("#mootimeter-pagecontent",html,js),mtmstate.setAttribute("data-contentchangedat_prev",mtmstate.dataset.contentchangedat),mtmstate.setAttribute("data-teacherpermissiontoview_prev",mtmstate.dataset.teacherpermissiontoview),!0})).catch((error=>(0,_notification.exception)(error)))};_exports.reloadPageContent=reloadPageContent})); //# sourceMappingURL=reload_page.min.js.map \ No newline at end of file diff --git a/amd/build/reload_page.min.js.map b/amd/build/reload_page.min.js.map index 7bffae36..817a7b5e 100644 --- a/amd/build/reload_page.min.js.map +++ b/amd/build/reload_page.min.js.map @@ -1 +1 @@ -{"version":3,"file":"reload_page.min.js","sources":["../src/reload_page.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\nimport {exception as displayException} from 'core/notification';\nimport Templates from 'core/templates';\nimport {execReloadPagelist as reloadPagelist} from 'mod_mootimeter/reload_pagelist';\nimport {getGetParams} from 'mod_mootimeter/utils';\nimport {setGetParam} from 'mod_mootimeter/utils';\nimport {getMootimeterstate} from 'mod_mootimeter/get_mootimeterstate';\n\nexport const init = (uniqueID) => {\n\n const obj = document.getElementById(uniqueID);\n if (!obj) {\n return;\n }\n obj.addEventListener(\"click\", changePage);\n\n /**\n * Store the value.\n */\n function changePage() {\n var pageid = 0;\n var dataset = \"\";\n if (this.dataset) {\n pageid = this.dataset.pageid;\n dataset = this.dataset;\n }\n\n if (pageid === null || pageid === undefined || pageid == \"undefined\" || pageid.length == 0) {\n pageid = 0;\n }\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n const cmid = urlParams.get('id');\n execReloadPage(pageid, cmid, dataset);\n }\n};\n\n/**\n * Call to store input value\n * @param {int} pageid\n * @param {int} cmid\n * @param {string} dataset\n * @returns {array}\n */\nconst reloadPage = (\n pageid,\n cmid,\n dataset\n) => fetchMany([{\n methodname: 'mod_mootimeter_get_pagecontentparams',\n args: {\n pageid,\n cmid,\n dataset\n },\n}])[0];\n\n/**\n * Executes the call to store input value.\n * @param {int} pageid\n * @param {int} cmid\n * @param {array} dataset\n */\nexport const execReloadPage = async(pageid, cmid, dataset) => {\n\n // Check if the pagereload is locked.\n var mtmstate = document.getElementById('mootimeterstate');\n if (mtmstate.dataset.lockpagereload) {\n return;\n }\n\n if (!dataset) {\n dataset = getGetParams();\n } else {\n Object.assign(dataset, getGetParams());\n }\n\n dataset = JSON.stringify(dataset);\n\n // Get the most recent timestamps.\n if (pageid != 0) {\n await getMootimeterstate();\n }\n\n mtmstate = document.getElementById('mootimeterstate');\n\n const response = await reloadPage(pageid, cmid, dataset);\n if (response.code != 200) {\n Log.error(response.string);\n }\n\n if (response.code == 200) {\n\n const pageparmas = JSON.parse(response.pageparams);\n\n // Replace the pagecontent.\n if (\n !mtmstate.dataset.contentchangedat_prev\n || mtmstate.dataset.contentchangedat_prev != mtmstate.contentchangedat\n || !mtmstate.dataset.teacherpermissiontoview_prev\n || mtmstate.dataset.teacherpermissiontoview_prev != mtmstate.dataset.teacherpermissiontoviewteacherpermissiontoview\n ) {\n reloadPageContent(pageparmas.pagecontent);\n\n // Set active page marked in pageslist.\n reloadPagelist(pageid, cmid, true);\n }\n\n // Replace the pagecontent menu.\n if (\n !mtmstate.dataset.pagecontentmenuchangedat_prev\n || mtmstate.dataset.pagecontentmenuchangedat_prev != mtmstate.settingschangedat\n ) {\n reloadContentMenu(pageparmas.contentmenu);\n }\n\n if (\n pageparmas.colsettings\n && (\n !mtmstate.dataset.settingschangedat_prev\n || mtmstate.dataset.settingschangedat_prev != mtmstate.settingschangedat\n )\n ) {\n reloadSettingsCol(pageparmas.colsettings);\n }\n\n if (pageparmas.pageid) {\n // Set new pageid.\n mtmstate.setAttribute('data-pageid', pageparmas.pageid);\n\n // Set URL parameter - pageid.\n setGetParam('pageid', pageparmas.pageid);\n }\n }\n};\n\nexport const reloadSettingsCol = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n // Replace the settings col if necessary.\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNodeContents('#mootimeter-col-settings', html, js);\n mtmstate.setAttribute('data-settingschangedat_prev', mtmstate.dataset.settingschangedat);\n return true;\n })\n .catch((error) => displayException(error));\n\n};\n\nexport const reloadContentMenu = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n // Replace the settings col if necessary.\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNode('#mootimeter-pagecontentmenu', html, js);\n mtmstate.setAttribute('data-pagecontentmenuchangedat_prev', mtmstate.dataset.pagecontentmenuchangedat);\n return true;\n })\n .catch((error) => displayException(error));\n\n // Set subpage URL parameters.\n if (pageparmas.sp) {\n for (const [key, value] of Object.entries(pageparmas.sp)) {\n setGetParam(key, value);\n }\n }\n};\n\nexport const reloadPageContent = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNodeContents('#mootimeter-pagecontent', html, js);\n mtmstate.setAttribute('data-contentchangedat_prev', mtmstate.dataset.contentchangedat);\n mtmstate.setAttribute('data-teacherpermissiontoview_prev', mtmstate.dataset.teacherpermissiontoview);\n return true;\n })\n .catch((error) => displayException(error));\n};\n"],"names":["uniqueID","obj","document","getElementById","addEventListener","pageid","dataset","this","length","queryString","window","location","search","cmid","URLSearchParams","get","execReloadPage","async","mtmstate","lockpagereload","Object","assign","JSON","stringify","response","methodname","args","reloadPage","code","error","string","pageparmas","parse","pageparams","contentchangedat_prev","contentchangedat","teacherpermissiontoview_prev","teacherpermissiontoviewteacherpermissiontoview","reloadPageContent","pagecontent","pagecontentmenuchangedat_prev","settingschangedat","reloadContentMenu","contentmenu","colsettings","settingschangedat_prev","reloadSettingsCol","setAttribute","renderForPromise","template","then","_ref","html","js","replaceNodeContents","catch","_ref2","replaceNode","pagecontentmenuchangedat","sp","key","value","entries","_ref3","teacherpermissiontoview"],"mappings":"opBASqBA,iBAEXC,IAAMC,SAASC,eAAeH,UAC/BC,KAGLA,IAAIG,iBAAiB,wBAMbC,OAAS,EACTC,QAAU,GACVC,KAAKD,UACLD,OAASE,KAAKD,QAAQD,OACtBC,QAAUC,KAAKD,SAGfD,MAAAA,QAAqD,aAAVA,QAA0C,GAAjBA,OAAOG,SAC3EH,OAAS,SAGPI,YAAcC,OAAOC,SAASC,OAE9BC,KADY,IAAIC,gBAAgBL,aACfM,IAAI,MAC3BC,eAAeX,OAAQQ,KAAMP,mBA8BxBU,eAAiBC,MAAMZ,OAAQQ,KAAMP,eAG1CY,SAAWhB,SAASC,eAAe,sBACnCe,SAASZ,QAAQa,sBAIhBb,QAGDc,OAAOC,OAAOf,SAAS,0BAFvBA,SAAU,yBAKdA,QAAUgB,KAAKC,UAAUjB,SAGX,GAAVD,cACM,6CAGVa,SAAWhB,SAASC,eAAe,yBAE7BqB,cA1CS,EACfnB,OACAQ,KACAP,WACC,cAAU,CAAC,CACZmB,WAAY,uCACZC,KAAM,CACFrB,OAAAA,OACAQ,KAAAA,KACAP,QAAAA,YAEJ,GA+BuBqB,CAAWtB,OAAQQ,KAAMP,YAC3B,KAAjBkB,SAASI,mBACLC,MAAML,SAASM,QAGF,KAAjBN,SAASI,KAAa,OAEhBG,WAAaT,KAAKU,MAAMR,SAASS,YAIlCf,SAASZ,QAAQ4B,uBACfhB,SAASZ,QAAQ4B,uBAAyBhB,SAASiB,kBAClDjB,SAASZ,QAAQ8B,8BAClBlB,SAASZ,QAAQ8B,8BAAgClB,SAASZ,QAAQ+B,iDAErEC,kBAAkBP,WAAWQ,qDAGdlC,OAAQQ,MAAM,IAK5BK,SAASZ,QAAQkC,+BACftB,SAASZ,QAAQkC,+BAAiCtB,SAASuB,mBAE9DC,kBAAkBX,WAAWY,cAI7BZ,WAAWa,aAEN1B,SAASZ,QAAQuC,wBACf3B,SAASZ,QAAQuC,wBAA0B3B,SAASuB,mBAG3DK,kBAAkBf,WAAWa,aAG7Bb,WAAW1B,SAEXa,SAAS6B,aAAa,cAAehB,WAAW1B,+BAGpC,SAAU0B,WAAW1B,wDAKhCyC,kBAAoB7B,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,sCAG7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKC,WAACC,KAACA,KAADC,GAAOA,mCACAC,oBAAoB,2BAA4BF,KAAMC,IAChEnC,SAAS6B,aAAa,8BAA+B7B,SAASZ,QAAQmC,oBAC/D,KAEVc,OAAO1B,QAAU,2BAAiBA,6DAI9Ba,kBAAoBzB,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,yCAG7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKM,YAACJ,KAACA,KAADC,GAAOA,oCACAI,YAAY,8BAA+BL,KAAMC,IAC3DnC,SAAS6B,aAAa,qCAAsC7B,SAASZ,QAAQoD,2BACtE,KAEVH,OAAO1B,QAAU,2BAAiBA,SAGnCE,WAAW4B,OACN,MAAOC,IAAKC,SAAUzC,OAAO0C,QAAQ/B,WAAW4B,2BACrCC,IAAKC,2DAKhBvB,kBAAoBrB,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,sCAE7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKa,YAACX,KAACA,KAADC,GAAOA,oCACAC,oBAAoB,0BAA2BF,KAAMC,IAC/DnC,SAAS6B,aAAa,6BAA8B7B,SAASZ,QAAQ6B,kBACrEjB,SAAS6B,aAAa,oCAAqC7B,SAASZ,QAAQ0D,0BACrE,KAEVT,OAAO1B,QAAU,2BAAiBA"} \ No newline at end of file +{"version":3,"file":"reload_page.min.js","sources":["../src/reload_page.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport Log from 'core/log';\nimport {exception as displayException} from 'core/notification';\nimport Templates from 'core/templates';\nimport {execReloadPagelist as reloadPagelist} from 'mod_mootimeter/reload_pagelist';\nimport {getGetParams} from 'mod_mootimeter/utils';\nimport {setGetParam} from 'mod_mootimeter/utils';\nimport {getMootimeterstate} from 'mod_mootimeter/get_mootimeterstate';\n\nexport const init = (uniqueID) => {\n\n const obj = document.getElementById(uniqueID);\n if (!obj) {\n return;\n }\n obj.addEventListener(\"click\", changePage);\n\n /**\n * Store the value.\n */\n function changePage() {\n var pageid = 0;\n var dataset = \"\";\n if (this.dataset) {\n pageid = this.dataset.pageid;\n dataset = this.dataset;\n }\n\n if (pageid === null || pageid === undefined || pageid == \"undefined\" || pageid.length == 0) {\n pageid = 0;\n }\n\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n const cmid = urlParams.get('id');\n execReloadPage(pageid, cmid, dataset);\n }\n};\n\n/**\n * Call to store input value\n * @param {int} pageid\n * @param {int} cmid\n * @param {string} dataset\n * @returns {array}\n */\nconst reloadPage = (\n pageid,\n cmid,\n dataset\n) => fetchMany([{\n methodname: 'mod_mootimeter_get_pagecontentparams',\n args: {\n pageid,\n cmid,\n dataset\n },\n}])[0];\n\n/**\n * Executes the call to store input value.\n * @param {int} pageid\n * @param {int} cmid\n * @param {array} dataset\n */\nexport const execReloadPage = async(pageid, cmid, dataset) => {\n\n // Check if the pagereload is locked.\n var mtmstate = document.getElementById('mootimeterstate');\n if (mtmstate.dataset.lockpagereload) {\n return;\n }\n\n if (!dataset) {\n dataset = getGetParams();\n } else {\n Object.assign(dataset, getGetParams());\n }\n\n dataset = JSON.stringify(dataset);\n\n // Get the most recent timestamps.\n if (pageid != 0) {\n await getMootimeterstate();\n }\n\n mtmstate = document.getElementById('mootimeterstate');\n\n const response = await reloadPage(pageid, cmid, dataset);\n if (response.code != 200) {\n Log.error(response.string);\n }\n\n if (response.code == 200) {\n\n const pageparmas = JSON.parse(response.pageparams);\n\n // Replace the pagecontent.\n if (\n !mtmstate.dataset.contentchangedat_prev\n || mtmstate.dataset.contentchangedat_prev != mtmstate.contentchangedat\n || !mtmstate.dataset.teacherpermissiontoview_prev\n || mtmstate.dataset.teacherpermissiontoview_prev != mtmstate.dataset.teacherpermissiontoviewteacherpermissiontoview\n ) {\n reloadPageContent(pageparmas.pagecontent);\n\n // Set active page marked in pageslist.\n reloadPagelist(pageid, cmid, true);\n }\n\n // Replace the pagecontent menu.\n if (\n !mtmstate.dataset.pagecontentmenuchangedat_prev\n || mtmstate.dataset.pagecontentmenuchangedat_prev != mtmstate.settingschangedat\n ) {\n if (pageparmas.contentmenu) {\n reloadContentMenu(pageparmas.contentmenu);\n }\n }\n\n if (\n pageparmas.colsettings\n && (\n !mtmstate.dataset.settingschangedat_prev\n || mtmstate.dataset.settingschangedat_prev != mtmstate.settingschangedat\n )\n ) {\n reloadSettingsCol(pageparmas.colsettings);\n }\n\n if (pageparmas.pageid) {\n // Set new pageid.\n mtmstate.setAttribute('data-pageid', pageparmas.pageid);\n\n // Set URL parameter - pageid.\n setGetParam('pageid', pageparmas.pageid);\n }\n }\n};\n\nexport const reloadSettingsCol = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n // Replace the settings col if necessary.\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNodeContents('#mootimeter-col-settings', html, js);\n mtmstate.setAttribute('data-settingschangedat_prev', mtmstate.dataset.settingschangedat);\n return true;\n })\n .catch((error) => displayException(error));\n\n};\n\nexport const reloadContentMenu = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n // Replace the settings col if necessary.\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNode('#mootimeter-pagecontentmenu', html, js);\n mtmstate.setAttribute('data-pagecontentmenuchangedat_prev', mtmstate.dataset.pagecontentmenuchangedat);\n return true;\n })\n .catch((error) => displayException(error));\n\n // Set subpage URL parameters.\n if (pageparmas.sp) {\n for (const [key, value] of Object.entries(pageparmas.sp)) {\n setGetParam(key, value);\n }\n }\n};\n\nexport const reloadPageContent = async(pageparmas) => {\n\n var mtmstate = document.getElementById('mootimeterstate');\n\n Templates.renderForPromise(pageparmas.template, pageparmas)\n .then(({html, js}) => {\n Templates.replaceNodeContents('#mootimeter-pagecontent', html, js);\n mtmstate.setAttribute('data-contentchangedat_prev', mtmstate.dataset.contentchangedat);\n mtmstate.setAttribute('data-teacherpermissiontoview_prev', mtmstate.dataset.teacherpermissiontoview);\n return true;\n })\n .catch((error) => displayException(error));\n};\n"],"names":["uniqueID","obj","document","getElementById","addEventListener","pageid","dataset","this","length","queryString","window","location","search","cmid","URLSearchParams","get","execReloadPage","async","mtmstate","lockpagereload","Object","assign","JSON","stringify","response","methodname","args","reloadPage","code","error","string","pageparmas","parse","pageparams","contentchangedat_prev","contentchangedat","teacherpermissiontoview_prev","teacherpermissiontoviewteacherpermissiontoview","reloadPageContent","pagecontent","pagecontentmenuchangedat_prev","settingschangedat","contentmenu","reloadContentMenu","colsettings","settingschangedat_prev","reloadSettingsCol","setAttribute","renderForPromise","template","then","_ref","html","js","replaceNodeContents","catch","_ref2","replaceNode","pagecontentmenuchangedat","sp","key","value","entries","_ref3","teacherpermissiontoview"],"mappings":"opBASqBA,iBAEXC,IAAMC,SAASC,eAAeH,UAC/BC,KAGLA,IAAIG,iBAAiB,wBAMbC,OAAS,EACTC,QAAU,GACVC,KAAKD,UACLD,OAASE,KAAKD,QAAQD,OACtBC,QAAUC,KAAKD,SAGfD,MAAAA,QAAqD,aAAVA,QAA0C,GAAjBA,OAAOG,SAC3EH,OAAS,SAGPI,YAAcC,OAAOC,SAASC,OAE9BC,KADY,IAAIC,gBAAgBL,aACfM,IAAI,MAC3BC,eAAeX,OAAQQ,KAAMP,mBA8BxBU,eAAiBC,MAAMZ,OAAQQ,KAAMP,eAG1CY,SAAWhB,SAASC,eAAe,sBACnCe,SAASZ,QAAQa,sBAIhBb,QAGDc,OAAOC,OAAOf,SAAS,0BAFvBA,SAAU,yBAKdA,QAAUgB,KAAKC,UAAUjB,SAGX,GAAVD,cACM,6CAGVa,SAAWhB,SAASC,eAAe,yBAE7BqB,cA1CS,EACfnB,OACAQ,KACAP,WACC,cAAU,CAAC,CACZmB,WAAY,uCACZC,KAAM,CACFrB,OAAAA,OACAQ,KAAAA,KACAP,QAAAA,YAEJ,GA+BuBqB,CAAWtB,OAAQQ,KAAMP,YAC3B,KAAjBkB,SAASI,mBACLC,MAAML,SAASM,QAGF,KAAjBN,SAASI,KAAa,OAEhBG,WAAaT,KAAKU,MAAMR,SAASS,YAIlCf,SAASZ,QAAQ4B,uBACfhB,SAASZ,QAAQ4B,uBAAyBhB,SAASiB,kBAClDjB,SAASZ,QAAQ8B,8BAClBlB,SAASZ,QAAQ8B,8BAAgClB,SAASZ,QAAQ+B,iDAErEC,kBAAkBP,WAAWQ,qDAGdlC,OAAQQ,MAAM,IAK5BK,SAASZ,QAAQkC,+BACftB,SAASZ,QAAQkC,+BAAiCtB,SAASuB,mBAE1DV,WAAWW,aACXC,kBAAkBZ,WAAWW,cAKjCX,WAAWa,aAEN1B,SAASZ,QAAQuC,wBACf3B,SAASZ,QAAQuC,wBAA0B3B,SAASuB,mBAG3DK,kBAAkBf,WAAWa,aAG7Bb,WAAW1B,SAEXa,SAAS6B,aAAa,cAAehB,WAAW1B,+BAGpC,SAAU0B,WAAW1B,wDAKhCyC,kBAAoB7B,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,sCAG7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKC,WAACC,KAACA,KAADC,GAAOA,mCACAC,oBAAoB,2BAA4BF,KAAMC,IAChEnC,SAAS6B,aAAa,8BAA+B7B,SAASZ,QAAQmC,oBAC/D,KAEVc,OAAO1B,QAAU,2BAAiBA,6DAI9Bc,kBAAoB1B,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,yCAG7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKM,YAACJ,KAACA,KAADC,GAAOA,oCACAI,YAAY,8BAA+BL,KAAMC,IAC3DnC,SAAS6B,aAAa,qCAAsC7B,SAASZ,QAAQoD,2BACtE,KAEVH,OAAO1B,QAAU,2BAAiBA,SAGnCE,WAAW4B,OACN,MAAOC,IAAKC,SAAUzC,OAAO0C,QAAQ/B,WAAW4B,2BACrCC,IAAKC,2DAKhBvB,kBAAoBrB,MAAAA,iBAEzBC,SAAWhB,SAASC,eAAe,sCAE7B6C,iBAAiBjB,WAAWkB,SAAUlB,YAC3CmB,MAAKa,YAACX,KAACA,KAADC,GAAOA,oCACAC,oBAAoB,0BAA2BF,KAAMC,IAC/DnC,SAAS6B,aAAa,6BAA8B7B,SAASZ,QAAQ6B,kBACrEjB,SAAS6B,aAAa,oCAAqC7B,SAASZ,QAAQ0D,0BACrE,KAEVT,OAAO1B,QAAU,2BAAiBA"} \ No newline at end of file diff --git a/amd/src/delete_page.js b/amd/src/delete_page.js index 4145558b..d7db7e7d 100644 --- a/amd/src/delete_page.js +++ b/amd/src/delete_page.js @@ -18,9 +18,12 @@ export const init = async(id) => { execDeletePage(pageid); }); - document.getElementById(id).addEventListener('click', () => { - modal.show(); - }); + const element = document.getElementById(id); + if (element) { + element.addEventListener('click', () => { + modal.show(); + }); + } /** * Call to store input value diff --git a/amd/src/handler_input.js b/amd/src/handler_input.js index 2ce3b5de..383bb735 100644 --- a/amd/src/handler_input.js +++ b/amd/src/handler_input.js @@ -1,5 +1,6 @@ import {call as fetchMany} from 'core/ajax'; import Log from 'core/log'; +import {exception as displayException} from 'core/notification'; export const init = (uniqueID) => { const obj = document.getElementById(uniqueID); @@ -73,7 +74,12 @@ const storeInputValue = ( * @param {string} thisDataset */ const execStoreInputValue = async(ajaxmethode, pageid, inputname, inputvalue, thisDataset) => { - const response = await storeInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset); + let response = null; + try { + response = await storeInputValue(ajaxmethode, pageid, inputname, inputvalue, thisDataset); + } catch (err) { + displayException(err); + } if (response.code != 200) { Log.error(response.string); } diff --git a/amd/src/reload_page.js b/amd/src/reload_page.js index 41eaa189..b82345dc 100644 --- a/amd/src/reload_page.js +++ b/amd/src/reload_page.js @@ -113,7 +113,9 @@ export const execReloadPage = async(pageid, cmid, dataset) => { !mtmstate.dataset.pagecontentmenuchangedat_prev || mtmstate.dataset.pagecontentmenuchangedat_prev != mtmstate.settingschangedat ) { - reloadContentMenu(pageparmas.contentmenu); + if (pageparmas.contentmenu) { + reloadContentMenu(pageparmas.contentmenu); + } } if ( diff --git a/classes/external/get_mootimeterstate.php b/classes/external/get_mootimeterstate.php index 6087f2ca..af441791 100644 --- a/classes/external/get_mootimeterstate.php +++ b/classes/external/get_mootimeterstate.php @@ -48,7 +48,7 @@ class get_mootimeterstate extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'pageid' => new external_value(PARAM_RAW, 'pageid to be active', VALUE_REQUIRED), + 'pageid' => new external_value(PARAM_INT, 'pageid to be active', VALUE_REQUIRED), 'cmid' => new external_value(PARAM_INT, 'The coursemodule id.', VALUE_REQUIRED), 'dataset' => new external_value(PARAM_RAW, 'The dataset of the page.', VALUE_REQUIRED), ]); @@ -88,7 +88,8 @@ public static function execute(int $pageid, int $cmid, string $dataset): array { $helper = new \mod_mootimeter\helper(); $page = $helper->get_page($pageid); if (empty($page)) { - $page = array_pop($helper->get_pages($cm->instance, "sortorder ASC")); + $pages = $helper->get_pages($cm->instance, "sortorder ASC"); + $page = array_pop($pages); } $mootimeterstate = json_encode(mootimeterstate::get_mootimeterstate_params($page, $dataset)); $return = ['code' => 200, 'string' => 'ok', 'state' => $mootimeterstate]; diff --git a/classes/external/get_pagecontentparams.php b/classes/external/get_pagecontentparams.php index 27b1b2e1..fe616d9e 100644 --- a/classes/external/get_pagecontentparams.php +++ b/classes/external/get_pagecontentparams.php @@ -47,7 +47,7 @@ class get_pagecontentparams extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'pageid' => new external_value(PARAM_RAW, 'pageid to be active', VALUE_REQUIRED), + 'pageid' => new external_value(PARAM_INT, 'pageid to be active', VALUE_REQUIRED), 'cmid' => new external_value(PARAM_INT, 'The coursemodule id.', VALUE_REQUIRED), 'dataset' => new external_value(PARAM_RAW, 'The dataset of the button clicked', VALUE_REQUIRED), ]); diff --git a/classes/external/reload_pagelist.php b/classes/external/reload_pagelist.php index 6b599c6d..798ad42f 100644 --- a/classes/external/reload_pagelist.php +++ b/classes/external/reload_pagelist.php @@ -48,7 +48,7 @@ class reload_pagelist extends external_api { */ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ - 'pageid' => new external_value(PARAM_RAW, 'pageid to be active', VALUE_REQUIRED), + 'pageid' => new external_value(PARAM_INT, 'pageid to be active', VALUE_REQUIRED), 'cmid' => new external_value(PARAM_INT, 'The coursemodule id.', VALUE_REQUIRED), 'dataset' => new external_value(PARAM_RAW, 'The dataset of the page.', VALUE_REQUIRED), ]); diff --git a/classes/external/store_setting.php b/classes/external/store_setting.php index 79f69544..4f2149e2 100644 --- a/classes/external/store_setting.php +++ b/classes/external/store_setting.php @@ -50,8 +50,8 @@ class store_setting extends external_api { public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ 'pageid' => new external_value(PARAM_INT, 'The page id to obtain results for.', VALUE_REQUIRED), - 'inputname' => new external_value(PARAM_RAW, 'The name of the input to store.', VALUE_REQUIRED), - 'inputvalue' => new external_value(PARAM_RAW, 'The value of the input to store.', VALUE_REQUIRED), + 'inputname' => new external_value(PARAM_TEXT, 'The name of the input to store.', VALUE_REQUIRED), + 'inputvalue' => new external_value(PARAM_TEXT, 'The value of the input to store.', VALUE_REQUIRED), 'thisDataset' => new external_value(PARAM_RAW, 'The value of the input to store.', VALUE_REQUIRED), ]); } diff --git a/classes/helper.php b/classes/helper.php index 13f601e5..7aad66fa 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -373,7 +373,7 @@ public function get_rendered_page_content_params(object $cm, object $page, bool $params = [ 'pageid' => $page->id, 'cmid' => $cm->id, - 'question' => s(self::get_tool_config($page, 'question')), + 'question' => clean_param(self::get_tool_config($page, 'question'), PARAM_TEXT), 'isediting' => $isediting, 'withwrapper' => $withwrapper, 'sp' => [ diff --git a/tools/quiz/amd/build/store_answer.min.js b/tools/quiz/amd/build/store_answer.min.js index 125ecaaa..4dfc3a12 100644 --- a/tools/quiz/amd/build/store_answer.min.js +++ b/tools/quiz/amd/build/store_answer.min.js @@ -1,3 +1,3 @@ -define("mootimetertool_quiz/store_answer",["exports","core/ajax","core/notification","core/str","core/templates"],(function(_exports,_ajax,_notification,_str,_templates){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj};_exports.init=uniqId=>{const submitbtn=document.getElementById(uniqId);submitbtn&&submitbtn.addEventListener("click",(function(){const selectedanswerids=[],pageid=this.dataset.pageid,checkboxes=document.getElementsByName("multipleanswers[]");for(const checkbox of checkboxes)checkbox.checked&&selectedanswerids.push(checkbox.value);return storeAnswer(pageid,selectedanswerids)}))};const storeAnswer=async(pageid,selectedanswerids)=>{var infobox;(infobox=document.getElementById("mtmt_answer_warning"))&&infobox.remove(),selectedanswerids=JSON.stringify(selectedanswerids);const successString=await(0,_str.get_string)("notification_success_store_answer","mod_mootimeter"),response=await((pageid,aoids)=>(0,_ajax.call)([{methodname:"mootimetertool_quiz_store_answer",args:{pageid:pageid,aoids:aoids}}])[0])(pageid,selectedanswerids);1e3!=response.code&&1001!=response.code&&1002!=response.code||renderInfoBox("warning",response.string,"fa-exclamation"),200==response.code&&renderInfoBox("success",successString,"")};function renderInfoBox(notificationType,notificationString,icon){const context={notification_id:"mtmt_answer_warning",notification_type:notificationType,notification_icon:icon,notification_text:notificationString};_templates.default.renderForPromise("mod_mootimeter/elements/snippet_notification",context).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.appendNodeContents("#mtmt_tool-colct-header",html,js),!0})).catch((error=>(0,_notification.exception)(error)))}})); +define("mootimetertool_quiz/store_answer",["exports","core/ajax","core/notification","core/str","core/templates"],(function(_exports,_ajax,_notification,_str,_templates){var obj;Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_templates=(obj=_templates)&&obj.__esModule?obj:{default:obj};_exports.init=uniqId=>{const submitbtn=document.getElementById(uniqId);submitbtn&&submitbtn.addEventListener("click",(function(){const selectedanswerids=[],pageid=this.dataset.pageid,checkboxes=document.getElementsByName("multipleanswers[]");for(const checkbox of checkboxes)checkbox.checked&&selectedanswerids.push(checkbox.value);return storeAnswer(pageid,selectedanswerids)}))};const storeAnswer=async(pageid,selectedanswerids)=>{var infobox;(infobox=document.getElementById("mtmt_answer_warning"))&&infobox.remove(),selectedanswerids=JSON.stringify(selectedanswerids);const successString=await(0,_str.get_string)("notification_success_store_answer","mod_mootimeter");try{await((pageid,aoids)=>(0,_ajax.call)([{methodname:"mootimetertool_quiz_store_answer",args:{pageid:pageid,aoids:aoids}}])[0])(pageid,selectedanswerids)}catch{console.log("blub")}1e3!=response.code&&1001!=response.code&&1002!=response.code||renderInfoBox("warning",response.string,"fa-exclamation"),200==response.code&&renderInfoBox("success",successString,"")};function renderInfoBox(notificationType,notificationString,icon){const context={notification_id:"mtmt_answer_warning",notification_type:notificationType,notification_icon:icon,notification_text:notificationString};_templates.default.renderForPromise("mod_mootimeter/elements/snippet_notification",context).then((_ref=>{let{html:html,js:js}=_ref;return _templates.default.appendNodeContents("#mtmt_tool-colct-header",html,js),!0})).catch((error=>(0,_notification.exception)(error)))}})); //# sourceMappingURL=store_answer.min.js.map \ No newline at end of file diff --git a/tools/quiz/amd/build/store_answer.min.js.map b/tools/quiz/amd/build/store_answer.min.js.map index bfd56fb5..a22f7abc 100644 --- a/tools/quiz/amd/build/store_answer.min.js.map +++ b/tools/quiz/amd/build/store_answer.min.js.map @@ -1 +1 @@ -{"version":3,"file":"store_answer.min.js","sources":["../src/store_answer.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport {exception as displayException} from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport Templates from 'core/templates';\n\nexport const init = (uniqId) => {\n\n // Get all up elements.\n const submitbtn = document.getElementById(uniqId);\n\n if (!submitbtn) {\n return;\n }\n\n submitbtn.addEventListener(\"click\", store);\n\n /**\n * Create new page.\n *\n * @returns {mixed}\n */\n function store() {\n const selectedanswerids = [];\n const pageid = this.dataset.pageid;\n const checkboxes = document.getElementsByName('multipleanswers[]');\n for (const checkbox of checkboxes) {\n if (checkbox.checked) {\n selectedanswerids.push(checkbox.value);\n }\n }\n return storeAnswer(pageid, selectedanswerids);\n }\n\n};\n\n/**\n * Call to create a new instance\n *\n * @param {int} pageid\n * @param {[]} aoids\n * @returns {mixed}\n */\nconst execStoreAnswer = (\n pageid,\n aoids\n) => fetchMany([{\n methodname: 'mootimetertool_quiz_store_answer',\n args: {\n pageid,\n aoids\n },\n}])[0];\n\n/**\n * Executes the call to create a new page.\n * @param {int} pageid\n * @param {array} selectedanswerids\n */\nconst storeAnswer = async(pageid, selectedanswerids) => {\n removeInfoBox();\n\n selectedanswerids = JSON.stringify(selectedanswerids);\n\n const successString = await getString('notification_success_store_answer', 'mod_mootimeter');\n const response = await execStoreAnswer(pageid, selectedanswerids);\n\n if (response.code == 1000 || response.code == 1001 || response.code == 1002) {\n renderInfoBox(\"warning\", response.string, \"fa-exclamation\");\n }\n\n if (response.code == 200) {\n renderInfoBox('success', successString, '');\n }\n};\n\n/**\n * Generate an info box.\n * @param {string} notificationType\n * @param {string} notificationString\n * @param {string} icon\n */\nfunction renderInfoBox(notificationType, notificationString, icon) {\n\n const context = {\n \"notification_id\": \"mtmt_answer_warning\",\n \"notification_type\": notificationType,\n \"notification_icon\": icon,\n \"notification_text\": notificationString\n };\n\n Templates.renderForPromise('mod_mootimeter/elements/snippet_notification', context)\n .then(({html, js}) => {\n Templates.appendNodeContents('#mtmt_tool-colct-header', html, js);\n return true;\n })\n .catch((error) => displayException(error));\n}\n\n/**\n * Remove the info box.\n */\nfunction removeInfoBox() {\n var infobox = document.getElementById(\"mtmt_answer_warning\");\n if (infobox) {\n infobox.remove();\n }\n}\n"],"names":["uniqId","submitbtn","document","getElementById","addEventListener","selectedanswerids","pageid","this","dataset","checkboxes","getElementsByName","checkbox","checked","push","value","storeAnswer","async","infobox","remove","JSON","stringify","successString","response","aoids","methodname","args","execStoreAnswer","code","renderInfoBox","string","notificationType","notificationString","icon","context","renderForPromise","then","_ref","html","js","appendNodeContents","catch","error"],"mappings":"2UAKqBA,eAGXC,UAAYC,SAASC,eAAeH,QAErCC,WAILA,UAAUG,iBAAiB,0BAQjBC,kBAAoB,GACpBC,OAASC,KAAKC,QAAQF,OACtBG,WAAaP,SAASQ,kBAAkB,yBACzC,MAAMC,YAAYF,WACfE,SAASC,SACTP,kBAAkBQ,KAAKF,SAASG,cAGjCC,YAAYT,OAAQD,6BA4B7BU,YAAcC,MAAMV,OAAQD,yBA4C1BY,SAAAA,QAAUf,SAASC,eAAe,yBAElCc,QAAQC,SA3CZb,kBAAoBc,KAAKC,UAAUf,yBAE7BgB,oBAAsB,mBAAU,oCAAqC,kBACrEC,cAtBc,EACpBhB,OACAiB,SACC,cAAU,CAAC,CACZC,WAAY,mCACZC,KAAM,CACFnB,OAAAA,OACAiB,MAAAA,UAEJ,GAauBG,CAAgBpB,OAAQD,mBAE1B,KAAjBiB,SAASK,MAAiC,MAAjBL,SAASK,MAAiC,MAAjBL,SAASK,MAC3DC,cAAc,UAAWN,SAASO,OAAQ,kBAGzB,KAAjBP,SAASK,MACTC,cAAc,UAAWP,cAAe,cAUvCO,cAAcE,iBAAkBC,mBAAoBC,YAEnDC,QAAU,iBACO,wCACEH,mCACAE,uBACAD,uCAGfG,iBAAiB,+CAAgDD,SACtEE,MAAKC,WAACC,KAACA,KAADC,GAAOA,mCACAC,mBAAmB,0BAA2BF,KAAMC,KACvD,KAEVE,OAAOC,QAAU,2BAAiBA"} \ No newline at end of file +{"version":3,"file":"store_answer.min.js","sources":["../src/store_answer.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport {exception as displayException} from 'core/notification';\nimport {get_string as getString} from 'core/str';\nimport Templates from 'core/templates';\n\nexport const init = (uniqId) => {\n\n // Get all up elements.\n const submitbtn = document.getElementById(uniqId);\n\n if (!submitbtn) {\n return;\n }\n\n submitbtn.addEventListener(\"click\", store);\n\n /**\n * Create new page.\n *\n * @returns {mixed}\n */\n function store() {\n const selectedanswerids = [];\n const pageid = this.dataset.pageid;\n const checkboxes = document.getElementsByName('multipleanswers[]');\n for (const checkbox of checkboxes) {\n if (checkbox.checked) {\n selectedanswerids.push(checkbox.value);\n }\n }\n return storeAnswer(pageid, selectedanswerids);\n }\n\n};\n\n/**\n * Call to create a new instance\n *\n * @param {int} pageid\n * @param {[]} aoids\n * @returns {mixed}\n */\nconst execStoreAnswer = (\n pageid,\n aoids\n) => fetchMany([{\n methodname: 'mootimetertool_quiz_store_answer',\n args: {\n pageid,\n aoids\n },\n}])[0];\n\n/**\n * Executes the call to create a new page.\n * @param {int} pageid\n * @param {array} selectedanswerids\n */\nconst storeAnswer = async(pageid, selectedanswerids) => {\n removeInfoBox();\n\n selectedanswerids = JSON.stringify(selectedanswerids);\n\n const successString = await getString('notification_success_store_answer', 'mod_mootimeter');\n try {\n const response = await execStoreAnswer(pageid, selectedanswerids);\n } catch {\n console.log(\"blub\");\n }\n\n if (response.code == 1000 || response.code == 1001 || response.code == 1002) {\n renderInfoBox(\"warning\", response.string, \"fa-exclamation\");\n }\n\n if (response.code == 200) {\n renderInfoBox('success', successString, '');\n }\n};\n\n/**\n * Generate an info box.\n * @param {string} notificationType\n * @param {string} notificationString\n * @param {string} icon\n */\nfunction renderInfoBox(notificationType, notificationString, icon) {\n\n const context = {\n \"notification_id\": \"mtmt_answer_warning\",\n \"notification_type\": notificationType,\n \"notification_icon\": icon,\n \"notification_text\": notificationString\n };\n\n Templates.renderForPromise('mod_mootimeter/elements/snippet_notification', context)\n .then(({html, js}) => {\n Templates.appendNodeContents('#mtmt_tool-colct-header', html, js);\n return true;\n })\n .catch((error) => displayException(error));\n}\n\n/**\n * Remove the info box.\n */\nfunction removeInfoBox() {\n var infobox = document.getElementById(\"mtmt_answer_warning\");\n if (infobox) {\n infobox.remove();\n }\n}\n"],"names":["uniqId","submitbtn","document","getElementById","addEventListener","selectedanswerids","pageid","this","dataset","checkboxes","getElementsByName","checkbox","checked","push","value","storeAnswer","async","infobox","remove","JSON","stringify","successString","aoids","methodname","args","execStoreAnswer","console","log","response","code","renderInfoBox","string","notificationType","notificationString","icon","context","renderForPromise","then","_ref","html","js","appendNodeContents","catch","error"],"mappings":"2UAKqBA,eAGXC,UAAYC,SAASC,eAAeH,QAErCC,WAILA,UAAUG,iBAAiB,0BAQjBC,kBAAoB,GACpBC,OAASC,KAAKC,QAAQF,OACtBG,WAAaP,SAASQ,kBAAkB,yBACzC,MAAMC,YAAYF,WACfE,SAASC,SACTP,kBAAkBQ,KAAKF,SAASG,cAGjCC,YAAYT,OAAQD,6BA4B7BU,YAAcC,MAAMV,OAAQD,yBAgD1BY,SAAAA,QAAUf,SAASC,eAAe,yBAElCc,QAAQC,SA/CZb,kBAAoBc,KAAKC,UAAUf,yBAE7BgB,oBAAsB,mBAAU,oCAAqC,2BArBvD,EACpBf,OACAgB,SACC,cAAU,CAAC,CACZC,WAAY,mCACZC,KAAM,CACFlB,OAAAA,OACAgB,MAAAA,UAEJ,GAc2BG,CAAgBnB,OAAQD,mBACjD,MACEqB,QAAQC,IAAI,QAGK,KAAjBC,SAASC,MAAiC,MAAjBD,SAASC,MAAiC,MAAjBD,SAASC,MAC3DC,cAAc,UAAWF,SAASG,OAAQ,kBAGzB,KAAjBH,SAASC,MACTC,cAAc,UAAWT,cAAe,cAUvCS,cAAcE,iBAAkBC,mBAAoBC,YAEnDC,QAAU,iBACO,wCACEH,mCACAE,uBACAD,uCAGfG,iBAAiB,+CAAgDD,SACtEE,MAAKC,WAACC,KAACA,KAADC,GAAOA,mCACAC,mBAAmB,0BAA2BF,KAAMC,KACvD,KAEVE,OAAOC,QAAU,2BAAiBA"} \ No newline at end of file diff --git a/tools/quiz/amd/src/store_answer.js b/tools/quiz/amd/src/store_answer.js index 45ccf2e3..02fdaa20 100644 --- a/tools/quiz/amd/src/store_answer.js +++ b/tools/quiz/amd/src/store_answer.js @@ -62,7 +62,14 @@ const storeAnswer = async(pageid, selectedanswerids) => { selectedanswerids = JSON.stringify(selectedanswerids); const successString = await getString('notification_success_store_answer', 'mod_mootimeter'); - const response = await execStoreAnswer(pageid, selectedanswerids); + let response = null; + // We need to also catch exceptions here, because we could have invalid parameters exception which will not even + // make it to a valid response. + try { + response = await execStoreAnswer(pageid, selectedanswerids); + } catch (err) { + displayException(err); + } if (response.code == 1000 || response.code == 1001 || response.code == 1002) { renderInfoBox("warning", response.string, "fa-exclamation"); diff --git a/tools/quiz/classes/external/store_answeroption.php b/tools/quiz/classes/external/store_answeroption.php index cbc04392..82913805 100644 --- a/tools/quiz/classes/external/store_answeroption.php +++ b/tools/quiz/classes/external/store_answeroption.php @@ -52,7 +52,7 @@ public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ 'pageid' => new external_value(PARAM_INT, 'The page id to obtain results for.', VALUE_REQUIRED), 'aoid' => new external_value(PARAM_INT, 'The id of the answer option.', VALUE_REQUIRED), - 'value' => new external_value(PARAM_RAW, 'The text value of the answer option.', VALUE_REQUIRED), + 'value' => new external_value(PARAM_TEXT, 'The text value of the answer option.', VALUE_REQUIRED), 'id' => new external_value(PARAM_RAW, 'The inputs id.', VALUE_REQUIRED), ]); } diff --git a/tools/quiz/classes/quiz.php b/tools/quiz/classes/quiz.php index f0d881f6..9bffee6d 100644 --- a/tools/quiz/classes/quiz.php +++ b/tools/quiz/classes/quiz.php @@ -555,7 +555,7 @@ public function get_col_settings_tool_params(object $page, array $params = []) { $params['question'] = [ 'mtm-input-id' => 'mtm_input_question', - 'mtm-input-value' => s(self::get_tool_config($page, 'question')), + 'mtm-input-value' => clean_param(self::get_tool_config($page, 'question'), PARAM_TEXT), 'mtm-input-placeholder' => get_string('enter_question', 'mod_mootimeter'), 'mtm-input-name' => "question", 'additional_class' => 'mootimeter_settings_selector', @@ -964,5 +964,4 @@ public function get_answer_overview(object $cm, object $page): string { $params = $this->get_answer_overview($cm, $page); return $OUTPUT->render_from_template("mod_mootimeter/answers_overview", $params); } - } diff --git a/tools/quiz/lang/de/mootimetertool_quiz.php b/tools/quiz/lang/de/mootimetertool_quiz.php index a30e2dd4..7b02c31a 100644 --- a/tools/quiz/lang/de/mootimetertool_quiz.php +++ b/tools/quiz/lang/de/mootimetertool_quiz.php @@ -28,7 +28,7 @@ $string['add_question_option'] = "Antwortmöglichkeit hinzufügen"; $string['answeroptions'] = "Antwortmöglichkeiten"; -$string['answers_max_number'] = 'Maximale Anzahl von Antworten die pro Teilnehmer ausgewählt werden können (0: unbegrenzt)'; +$string['answers_max_number'] = 'Maximale Anzahl an Antwortmöglichkeiten, die ein Teilnehmer auswählen kann (0: unbegrenzt)'; $string['atleastoneanswer'] = 'Sie müssen mindestens eine Antwortoption auswählen'; $string['enter_answeroption'] = 'Bitte eine Antwortoption eingeben.'; $string['error_to_many_answers'] = 'Sie haben zu viele Antworten ausgewählt. Sie können nur {$a} Optionen auswählen.'; diff --git a/tools/wordcloud/amd/build/store_answer.min.js b/tools/wordcloud/amd/build/store_answer.min.js index 511d50a0..3313ab74 100644 --- a/tools/wordcloud/amd/build/store_answer.min.js +++ b/tools/wordcloud/amd/build/store_answer.min.js @@ -1,3 +1,3 @@ -define("mootimetertool_wordcloud/store_answer",["exports","core/ajax","mod_mootimeter/reload_page","mod_mootimeter/utils"],(function(_exports,_ajax,_reload_page,_utils){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0;_exports.init=(inputid,enterid)=>{const ao=document.getElementById(inputid);ao&&ao.addEventListener("keyup",(function(event){"Enter"!==event.code&&"NumpadEnter"!==event.code||store(inputid)}));const ae=document.getElementById(enterid);function store(inputid){var pageid=document.getElementById(inputid).dataset.pageid,answer=document.getElementById(inputid).value;storeAnswer(pageid,answer,inputid)}ae&&ae.addEventListener("click",(function(){store(inputid)}))};const storeAnswer=async(pageid,answer,inputid)=>{document.getElementById(inputid).disabled=!0;const response=await((pageid,answer)=>(0,_ajax.call)([{methodname:"mootimetertool_wordcloud_store_answer",args:{pageid:pageid,answer:answer}}])[0])(pageid,answer);if((0,_utils.removeInfoBox)("mtmt_answer_warning"),1e3!=response.code&&1001!=response.code&&1002!=response.code||((0,_utils.renderInfoBox)("mtmt_tool-colct-header","mtmt_answer_warning","warning",response.string),document.getElementById(inputid).disabled=!1,document.getElementById(inputid).focus()),200==response.code){const queryString=window.location.search,urlParams=new URLSearchParams(queryString);await(0,_reload_page.execReloadPage)(urlParams.get("pageid"),urlParams.get("id")),await(0,_utils.delay)(100);for(var elements=document.getElementsByClassName("mtmt-wc-answerinput"),i=0;i{const ao=document.getElementById(inputid);ao&&ao.addEventListener("keyup",(function(event){"Enter"!==event.code&&"NumpadEnter"!==event.code||store(inputid)}));const ae=document.getElementById(enterid);function store(inputid){var pageid=document.getElementById(inputid).dataset.pageid,answer=document.getElementById(inputid).value;storeAnswer(pageid,answer,inputid)}ae&&ae.addEventListener("click",(function(){store(inputid)}))};const storeAnswer=async(pageid,answer,inputid)=>{document.getElementById(inputid).disabled=!0;let response=null;try{response=await((pageid,answer)=>(0,_ajax.call)([{methodname:"mootimetertool_wordcloud_store_answer",args:{pageid:pageid,answer:answer}}])[0])(pageid,answer)}catch(err){(0,_notification.exception)(err)}if((0,_utils.removeInfoBox)("mtmt_answer_warning"),1e3!=response.code&&1001!=response.code&&1002!=response.code||((0,_utils.renderInfoBox)("mtmt_tool-colct-header","mtmt_answer_warning","warning",response.string),document.getElementById(inputid).disabled=!1,document.getElementById(inputid).focus()),200==response.code){const queryString=window.location.search,urlParams=new URLSearchParams(queryString);await(0,_reload_page.execReloadPage)(urlParams.get("pageid"),urlParams.get("id")),await(0,_utils.delay)(100);for(var elements=document.getElementsByClassName("mtmt-wc-answerinput"),i=0;i {\n\n // Register event to input box.\n const ao = document.getElementById(inputid);\n if (ao) {\n ao.addEventListener(\"keyup\", function(event) {\n if (event.code === 'Enter' || event.code === 'NumpadEnter') {\n store(inputid);\n }\n });\n }\n\n // Register event to submit button.\n const ae = document.getElementById(enterid);\n if (ae) {\n ae.addEventListener(\"click\", function() {\n store(inputid);\n });\n }\n\n /**\n * Create new page.\n * @param {string} inputid\n */\n function store(inputid) {\n var pageid = document.getElementById(inputid).dataset.pageid;\n var answer = document.getElementById(inputid).value;\n storeAnswer(pageid, answer, inputid);\n }\n};\n\n/**\n * Call to store an answer\n * @param {int} pageid\n * @param {string} answer\n * @returns {array}\n */\nconst execStoreAnswer = (\n pageid,\n answer,\n) => fetchMany([{\n methodname: 'mootimetertool_wordcloud_store_answer',\n args: {\n pageid,\n answer\n },\n}])[0];\n\n\n/**\n * Executes the call to store an answer.\n * @param {int} pageid\n * @param {string} answer\n * @param {string} inputid\n */\nconst storeAnswer = async(pageid, answer, inputid) => {\n\n // Disable the input field until the page is refreshed.\n document.getElementById(inputid).disabled = true;\n\n const response = await execStoreAnswer(pageid, answer);\n\n const infoboxid = \"mtmt_answer_warning\";\n\n removeInfoBox(infoboxid);\n\n if (response.code == 1000 || response.code == 1001 || response.code == 1002) {\n renderInfoBox(\"mtmt_tool-colct-header\", infoboxid, \"warning\", response.string);\n document.getElementById(inputid).disabled = false;\n document.getElementById(inputid).focus();\n }\n\n if (response.code == 200) {\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n await reloadPage(urlParams.get('pageid'), urlParams.get('id'));\n\n // Now set the focus to the input field.\n\n // Yes, it is not nice, but the dom needs some time to be updated.\n await delay(100);\n\n var elements = document.getElementsByClassName(\"mtmt-wc-answerinput\");\n for (var i = 0; i < elements.length; i++) {\n if (elements.item(i).autofocus == true) {\n elements.item(i).focus();\n }\n }\n }\n};\n"],"names":["inputid","enterid","ao","document","getElementById","addEventListener","event","code","store","ae","pageid","dataset","answer","value","storeAnswer","async","disabled","response","methodname","args","execStoreAnswer","string","focus","queryString","window","location","search","urlParams","URLSearchParams","get","elements","getElementsByClassName","i","length","item","autofocus"],"mappings":"oQAMoB,CAACA,QAASC,iBAGpBC,GAAKC,SAASC,eAAeJ,SAC/BE,IACAA,GAAGG,iBAAiB,SAAS,SAASC,OACf,UAAfA,MAAMC,MAAmC,gBAAfD,MAAMC,MAChCC,MAAMR,kBAMZS,GAAKN,SAASC,eAAeH,kBAW1BO,MAAMR,aACPU,OAASP,SAASC,eAAeJ,SAASW,QAAQD,OAClDE,OAAST,SAASC,eAAeJ,SAASa,MAC9CC,YAAYJ,OAAQE,OAAQZ,SAb5BS,IACAA,GAAGJ,iBAAiB,SAAS,WACzBG,MAAMR,mBAuCZc,YAAcC,MAAML,OAAQE,OAAQZ,WAGtCG,SAASC,eAAeJ,SAASgB,UAAW,QAEtCC,cAvBc,EACpBP,OACAE,UACC,cAAU,CAAC,CACZM,WAAY,wCACZC,KAAM,CACFT,OAAAA,OACAE,OAAAA,WAEJ,GAcuBQ,CAAgBV,OAAQE,oCAE7B,uBAIG,KAAjBK,SAASV,MAAiC,MAAjBU,SAASV,MAAiC,MAAjBU,SAASV,gCAC7C,yBALA,sBAKqC,UAAWU,SAASI,QACvElB,SAASC,eAAeJ,SAASgB,UAAW,EAC5Cb,SAASC,eAAeJ,SAASsB,SAGhB,KAAjBL,SAASV,KAAa,OAChBgB,YAAcC,OAAOC,SAASC,OAC9BC,UAAY,IAAIC,gBAAgBL,mBAChC,+BAAWI,UAAUE,IAAI,UAAWF,UAAUE,IAAI,aAKlD,gBAAM,aAERC,SAAW3B,SAAS4B,uBAAuB,uBACtCC,EAAI,EAAGA,EAAIF,SAASG,OAAQD,IACC,GAA9BF,SAASI,KAAKF,GAAGG,WACjBL,SAASI,KAAKF,GAAGV"} \ No newline at end of file +{"version":3,"file":"store_answer.min.js","sources":["../src/store_answer.js"],"sourcesContent":["import {call as fetchMany} from 'core/ajax';\nimport {execReloadPage as reloadPage} from 'mod_mootimeter/reload_page';\nimport {renderInfoBox} from 'mod_mootimeter/utils';\nimport {removeInfoBox} from 'mod_mootimeter/utils';\nimport {delay} from 'mod_mootimeter/utils';\nimport {exception as displayException} from 'core/notification';\n\nexport const init = (inputid, enterid) => {\n\n // Register event to input box.\n const ao = document.getElementById(inputid);\n if (ao) {\n ao.addEventListener(\"keyup\", function(event) {\n if (event.code === 'Enter' || event.code === 'NumpadEnter') {\n store(inputid);\n }\n });\n }\n\n // Register event to submit button.\n const ae = document.getElementById(enterid);\n if (ae) {\n ae.addEventListener(\"click\", function() {\n store(inputid);\n });\n }\n\n /**\n * Create new page.\n * @param {string} inputid\n */\n function store(inputid) {\n var pageid = document.getElementById(inputid).dataset.pageid;\n var answer = document.getElementById(inputid).value;\n storeAnswer(pageid, answer, inputid);\n }\n};\n\n/**\n * Call to store an answer\n * @param {int} pageid\n * @param {string} answer\n * @returns {array}\n */\nconst execStoreAnswer = (\n pageid,\n answer,\n) => fetchMany([{\n methodname: 'mootimetertool_wordcloud_store_answer',\n args: {\n pageid,\n answer\n },\n}])[0];\n\n\n/**\n * Executes the call to store an answer.\n * @param {int} pageid\n * @param {string} answer\n * @param {string} inputid\n */\nconst storeAnswer = async(pageid, answer, inputid) => {\n\n // Disable the input field until the page is refreshed.\n document.getElementById(inputid).disabled = true;\n let response = null;\n try {\n response = await execStoreAnswer(pageid, answer);\n } catch (err) {\n displayException(err);\n }\n\n const infoboxid = \"mtmt_answer_warning\";\n\n removeInfoBox(infoboxid);\n\n if (response.code == 1000 || response.code == 1001 || response.code == 1002) {\n renderInfoBox(\"mtmt_tool-colct-header\", infoboxid, \"warning\", response.string);\n document.getElementById(inputid).disabled = false;\n document.getElementById(inputid).focus();\n }\n\n if (response.code == 200) {\n const queryString = window.location.search;\n const urlParams = new URLSearchParams(queryString);\n await reloadPage(urlParams.get('pageid'), urlParams.get('id'));\n\n // Now set the focus to the input field.\n\n // Yes, it is not nice, but the dom needs some time to be updated.\n await delay(100);\n\n var elements = document.getElementsByClassName(\"mtmt-wc-answerinput\");\n for (var i = 0; i < elements.length; i++) {\n if (elements.item(i).autofocus == true) {\n elements.item(i).focus();\n }\n }\n }\n};\n"],"names":["inputid","enterid","ao","document","getElementById","addEventListener","event","code","store","ae","pageid","dataset","answer","value","storeAnswer","async","disabled","response","methodname","args","execStoreAnswer","err","string","focus","queryString","window","location","search","urlParams","URLSearchParams","get","elements","getElementsByClassName","i","length","item","autofocus"],"mappings":"sSAOoB,CAACA,QAASC,iBAGpBC,GAAKC,SAASC,eAAeJ,SAC/BE,IACAA,GAAGG,iBAAiB,SAAS,SAASC,OACf,UAAfA,MAAMC,MAAmC,gBAAfD,MAAMC,MAChCC,MAAMR,kBAMZS,GAAKN,SAASC,eAAeH,kBAW1BO,MAAMR,aACPU,OAASP,SAASC,eAAeJ,SAASW,QAAQD,OAClDE,OAAST,SAASC,eAAeJ,SAASa,MAC9CC,YAAYJ,OAAQE,OAAQZ,SAb5BS,IACAA,GAAGJ,iBAAiB,SAAS,WACzBG,MAAMR,mBAuCZc,YAAcC,MAAML,OAAQE,OAAQZ,WAGtCG,SAASC,eAAeJ,SAASgB,UAAW,MACxCC,SAAW,SAEXA,cAxBgB,EACpBP,OACAE,UACC,cAAU,CAAC,CACZM,WAAY,wCACZC,KAAM,CACFT,OAAAA,OACAE,OAAAA,WAEJ,GAeqBQ,CAAgBV,OAAQE,QAC3C,MAAOS,iCACYA,iCAGH,uBAIG,KAAjBJ,SAASV,MAAiC,MAAjBU,SAASV,MAAiC,MAAjBU,SAASV,gCAC7C,yBALA,sBAKqC,UAAWU,SAASK,QACvEnB,SAASC,eAAeJ,SAASgB,UAAW,EAC5Cb,SAASC,eAAeJ,SAASuB,SAGhB,KAAjBN,SAASV,KAAa,OAChBiB,YAAcC,OAAOC,SAASC,OAC9BC,UAAY,IAAIC,gBAAgBL,mBAChC,+BAAWI,UAAUE,IAAI,UAAWF,UAAUE,IAAI,aAKlD,gBAAM,aAERC,SAAW5B,SAAS6B,uBAAuB,uBACtCC,EAAI,EAAGA,EAAIF,SAASG,OAAQD,IACC,GAA9BF,SAASI,KAAKF,GAAGG,WACjBL,SAASI,KAAKF,GAAGV"} \ No newline at end of file diff --git a/tools/wordcloud/amd/src/store_answer.js b/tools/wordcloud/amd/src/store_answer.js index ccc1269c..e3c06a75 100644 --- a/tools/wordcloud/amd/src/store_answer.js +++ b/tools/wordcloud/amd/src/store_answer.js @@ -3,6 +3,7 @@ import {execReloadPage as reloadPage} from 'mod_mootimeter/reload_page'; import {renderInfoBox} from 'mod_mootimeter/utils'; import {removeInfoBox} from 'mod_mootimeter/utils'; import {delay} from 'mod_mootimeter/utils'; +import {exception as displayException} from 'core/notification'; export const init = (inputid, enterid) => { @@ -63,8 +64,12 @@ const storeAnswer = async(pageid, answer, inputid) => { // Disable the input field until the page is refreshed. document.getElementById(inputid).disabled = true; - - const response = await execStoreAnswer(pageid, answer); + let response = null; + try { + response = await execStoreAnswer(pageid, answer); + } catch (err) { + displayException(err); + } const infoboxid = "mtmt_answer_warning"; diff --git a/tools/wordcloud/classes/external/store_answer.php b/tools/wordcloud/classes/external/store_answer.php index e7bcbb79..1a3bcdb0 100644 --- a/tools/wordcloud/classes/external/store_answer.php +++ b/tools/wordcloud/classes/external/store_answer.php @@ -48,7 +48,7 @@ class store_answer extends external_api { public static function execute_parameters(): external_function_parameters { return new external_function_parameters([ 'pageid' => new external_value(PARAM_INT, 'The page id to obtain results for.', VALUE_REQUIRED), - 'answer' => new external_value(PARAM_RAW, 'The answer the user entered.', VALUE_REQUIRED), + 'answer' => new external_value(PARAM_TEXT, 'The answer the user entered.', VALUE_REQUIRED), ]); } diff --git a/tools/wordcloud/classes/wordcloud.php b/tools/wordcloud/classes/wordcloud.php index 2fb72d2d..166f1062 100644 --- a/tools/wordcloud/classes/wordcloud.php +++ b/tools/wordcloud/classes/wordcloud.php @@ -366,7 +366,7 @@ public function get_col_settings_tool_params(object $page, array $params = []) { $params['question'] = [ 'mtm-input-id' => 'mtm_input_question', - 'mtm-input-value' => s(self::get_tool_config($page, 'question')), + 'mtm-input-value' => clean_param(self::get_tool_config($page, 'question'), PARAM_TEXT), 'mtm-input-placeholder' => get_string('enter_question', 'mod_mootimeter'), 'mtm-input-name' => "question", 'additional_class' => 'mootimeter_settings_selector',