diff --git a/admin/tool/dataprivacy/amd/build/selectedcourses.min.js b/admin/tool/dataprivacy/amd/build/selectedcourses.min.js
index 42f21ba675e..d7cf2bcdbf4 100644
--- a/admin/tool/dataprivacy/amd/build/selectedcourses.min.js
+++ b/admin/tool/dataprivacy/amd/build/selectedcourses.min.js
@@ -1,3 +1,3 @@
-define("tool_dataprivacy/selectedcourses",["exports","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core/prefetch","core/str"],(function(_exports,_ajax,_notification,_modal_factory,_modal_events,_fragment,_prefetch,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events),_fragment=_interopRequireDefault(_fragment),(0,_prefetch.prefetchStrings)("tool_dataprivacy",["selectedcourses","approverequest","errornoselectedcourse"]);return _exports.default=class{constructor(contextId,requestId){_defineProperty(this,"contextId",0),_defineProperty(this,"requestId",0),_defineProperty(this,"strings",null),_defineProperty(this,"getBody",(formdata=>{let params=null;return void 0!==formdata&&(params={jsonformdata:JSON.stringify(formdata)}),_fragment.default.loadFragment("tool_dataprivacy","selectcourses_form",this.contextId,params)})),_defineProperty(this,"submitForm",(e=>{e.preventDefault(),this.modal.getRoot().find("form").submit()})),_defineProperty(this,"submitFormAjax",(e=>{e.preventDefault();let formData=this.modal.getRoot().find("form").serialize();if(-1===formData.indexOf("coursecontextids")){const customSelect=this.modal.getRoot().find(".custom-select"),invalidText=this.modal.getRoot().find(".invalid-feedback");return customSelect.addClass("is-invalid"),invalidText.attr("style","display: block"),void(0,_str.get_string)("errornoselectedcourse","tool_dataprivacy").then((value=>{invalidText.empty().append(value)})).catch(_notification.default.exception)}_ajax.default.call([{methodname:"tool_dataprivacy_submit_selected_courses_form",args:{requestid:this.requestId,jsonformdata:JSON.stringify(formData)},done:data=>{data.warnings.length>0?this.modal.setBody(this.getBody(formData)):(this.modal.destroy(),document.location.reload())},fail:_notification.default.exception}])})),this.contextId=contextId,this.requestId=requestId,_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:(0,_str.get_string)("selectcourses","tool_dataprivacy"),body:this.getBody({requestid:requestId}),large:!0,removeOnClose:!0,buttons:{save:(0,_str.get_string)("approverequest","tool_dataprivacy")}}).then((modal=>(this.modal=modal,modal))).then((modal=>(modal.getRoot().on(_modal_events.default.save,this.submitForm.bind(this)),modal.getRoot().on("submit","form",this.submitFormAjax.bind(this)),modal.show(),modal))).catch(_notification.default.exception)}},_exports.default}));
+define("tool_dataprivacy/selectedcourses",["exports","core/ajax","core/notification","core/modal_factory","core/modal_events","core/fragment","core/prefetch","core/str"],(function(_exports,_ajax,_notification,_modal_factory,_modal_events,_fragment,_prefetch,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_ajax=_interopRequireDefault(_ajax),_notification=_interopRequireDefault(_notification),_modal_factory=_interopRequireDefault(_modal_factory),_modal_events=_interopRequireDefault(_modal_events),_fragment=_interopRequireDefault(_fragment),(0,_prefetch.prefetchStrings)("tool_dataprivacy",["selectedcourses","approverequest","errornoselectedcourse"]);return _exports.default=class{constructor(contextId,requestId){_defineProperty(this,"contextId",0),_defineProperty(this,"requestId",0),this.contextId=contextId,this.requestId=requestId,_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:(0,_str.get_string)("selectcourses","tool_dataprivacy"),body:this.getBody({requestid:requestId}),large:!0,removeOnClose:!0,buttons:{save:(0,_str.get_string)("approverequest","tool_dataprivacy")}}).then((modal=>(this.modal=modal,modal))).then((modal=>(modal.getRoot().on(_modal_events.default.save,this.submitForm.bind(this)),modal.getRoot().on("submit","form",this.submitFormAjax.bind(this)),modal.show(),modal))).catch(_notification.default.exception)}getBody(formdata){const params=formdata?{jsonformdata:JSON.stringify(formdata)}:null;return _fragment.default.loadFragment("tool_dataprivacy","selectcourses_form",this.contextId,params)}submitForm(e){e.preventDefault(),this.modal.getRoot().find("form").submit()}submitFormAjax(e){e.preventDefault();let formData=this.modal.getRoot().find("form").serialize();if(-1===formData.indexOf("coursecontextids")){const customSelect=this.modal.getRoot().find(".custom-select"),invalidText=this.modal.getRoot().find(".invalid-feedback");return customSelect.addClass("is-invalid"),invalidText.attr("style","display: block"),void(0,_str.get_string)("errornoselectedcourse","tool_dataprivacy").then((value=>{invalidText.empty().append(value)})).catch(_notification.default.exception)}_ajax.default.call([{methodname:"tool_dataprivacy_submit_selected_courses_form",args:{requestid:this.requestId,jsonformdata:JSON.stringify(formData)}}])[0].then((data=>(data.warnings.length>0?this.modal.setBody(this.getBody(formData)):(this.modal.destroy(),document.location.reload()),data))).catch((error=>_notification.default.exception(error)))}},_exports.default}));
//# sourceMappingURL=selectedcourses.min.js.map
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/build/selectedcourses.min.js.map b/admin/tool/dataprivacy/amd/build/selectedcourses.min.js.map
index cf5ef9f4e53..3c85e5d7045 100644
--- a/admin/tool/dataprivacy/amd/build/selectedcourses.min.js.map
+++ b/admin/tool/dataprivacy/amd/build/selectedcourses.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"selectedcourses.min.js","sources":["../src/selectedcourses.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 * Selected courses.\n *\n * @module tool_dataprivacy/selectedcourses\n * @copyright 2021 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since Moodle 4.3\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport Fragment from 'core/fragment';\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\n\nprefetchStrings('tool_dataprivacy', [\n 'selectedcourses',\n 'approverequest',\n 'errornoselectedcourse',\n]);\n\n/**\n * Selected Courses popup modal.\n *\n */\nexport default class SelectedCourses {\n /**\n * @var {String} contextId Context ID to load the fragment.\n * @private\n */\n contextId = 0;\n\n /**\n * @var {String} requestId ID of data export request.\n * @private\n */\n requestId = 0;\n\n /**\n * @var {Promise}\n * @private\n */\n strings = null;\n\n /**\n * Constructor\n *\n * @param {String} contextId Context ID to load the fragment.\n * @param {String} requestId ID of data export request.\n */\n constructor(contextId, requestId) {\n\n this.contextId = contextId;\n this.requestId = requestId;\n // Now create the modal.\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: getString('selectcourses', 'tool_dataprivacy'),\n body: this.getBody({requestid: requestId}),\n large: true,\n removeOnClose: true,\n buttons: {\n save: getString('approverequest', 'tool_dataprivacy'),\n },\n }).then(modal => {\n this.modal = modal;\n\n return modal;\n }).then(modal => {\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n modal.show();\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Get body of modal.\n *\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n getBody = (formdata) => {\n\n let params = null;\n if (typeof formdata !== \"undefined\") {\n params = {jsonformdata: JSON.stringify(formdata)};\n }\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'selectcourses_form', this.contextId, params);\n };\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n submitForm = (e) => {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n };\n\n /**\n * Submit select courses form using ajax.\n *\n * @method submitFormAjax\n * @private\n * @param {Event} e Form submission event.\n */\n submitFormAjax = (e) => {\n\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n let formData = this.modal.getRoot().find('form').serialize();\n\n if (formData.indexOf('coursecontextids') === -1) {\n const customSelect = this.modal.getRoot().find('.custom-select');\n const invalidText = this.modal.getRoot().find('.invalid-feedback');\n customSelect.addClass('is-invalid');\n invalidText.attr('style', 'display: block');\n getString('errornoselectedcourse', 'tool_dataprivacy').then(value => {\n invalidText.empty().append(value);\n return;\n }).catch(Notification.exception);\n return;\n }\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_submit_selected_courses_form',\n args: {requestid: this.requestId, jsonformdata: JSON.stringify(formData)},\n done: (data) => {\n if (data.warnings.length > 0) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.modal.destroy();\n document.location.reload();\n }\n },\n fail: Notification.exception\n }]);\n };\n}\n"],"names":["constructor","contextId","requestId","formdata","params","jsonformdata","JSON","stringify","Fragment","loadFragment","this","e","preventDefault","modal","getRoot","find","submit","formData","serialize","indexOf","customSelect","invalidText","addClass","attr","then","value","empty","append","catch","Notification","exception","call","methodname","args","requestid","done","data","warnings","length","setBody","getBody","destroy","document","location","reload","fail","create","type","ModalFactory","types","SAVE_CANCEL","title","body","large","removeOnClose","buttons","save","on","ModalEvents","submitForm","bind","submitFormAjax","show"],"mappings":"01BAgCgB,mBAAoB,CAChC,kBACA,iBACA,wDAgCAA,YAAYC,UAAWC,4CApBX,oCAMA,kCAMF,sCA8CCC,eAEHC,OAAS,iBACW,IAAbD,WACPC,OAAS,CAACC,aAAcC,KAAKC,UAAUJ,YAGpCK,kBAASC,aAAa,mBAAoB,qBAAsBC,KAAKT,UAAWG,8CAU7EO,IACVA,EAAEC,sBACGC,MAAMC,UAAUC,KAAK,QAAQC,mDAUpBL,IAEdA,EAAEC,qBAGEK,SAAWP,KAAKG,MAAMC,UAAUC,KAAK,QAAQG,gBAEH,IAA1CD,SAASE,QAAQ,oBAA4B,OACvCC,aAAeV,KAAKG,MAAMC,UAAUC,KAAK,kBACzCM,YAAcX,KAAKG,MAAMC,UAAUC,KAAK,4BAC9CK,aAAaE,SAAS,cACtBD,YAAYE,KAAK,QAAS,0CAChB,wBAAyB,oBAAoBC,MAAKC,QACxDJ,YAAYK,QAAQC,OAAOF,UAE5BG,MAAMC,sBAAaC,yBAIrBC,KAAK,CAAC,CACPC,WAAY,gDACZC,KAAM,CAACC,UAAWxB,KAAKR,UAAWG,aAAcC,KAAKC,UAAUU,WAC/DkB,KAAOC,OACCA,KAAKC,SAASC,OAAS,OAClBzB,MAAM0B,QAAQ7B,KAAK8B,QAAQvB,iBAE3BJ,MAAM4B,UACXC,SAASC,SAASC,WAG1BC,KAAMhB,sBAAaC,qBA/FlB7B,UAAYA,eACZC,UAAYA,iCAEJ4C,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,YACzBC,OAAO,mBAAU,gBAAiB,oBAClCC,KAAM1C,KAAK8B,QAAQ,CAACN,UAAWhC,YAC/BmD,OAAO,EACPC,eAAe,EACfC,QAAS,CACLC,MAAM,mBAAU,iBAAkB,uBAEvChC,MAAKX,aACKA,MAAQA,MAENA,SACRW,MAAKX,QAGJA,MAAMC,UAAU2C,GAAGC,sBAAYF,KAAM9C,KAAKiD,WAAWC,KAAKlD,OAG1DG,MAAMC,UAAU2C,GAAG,SAAU,OAAQ/C,KAAKmD,eAAeD,KAAKlD,OAC9DG,MAAMiD,OACCjD,SACRe,MAAMC,sBAAaC"}
\ No newline at end of file
+{"version":3,"file":"selectedcourses.min.js","sources":["../src/selectedcourses.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 * Selected courses.\n *\n * @module tool_dataprivacy/selectedcourses\n * @copyright 2021 The Open University\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since Moodle 4.3\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\nimport ModalFactory from 'core/modal_factory';\nimport ModalEvents from 'core/modal_events';\nimport Fragment from 'core/fragment';\nimport {prefetchStrings} from 'core/prefetch';\nimport {get_string as getString} from 'core/str';\n\nprefetchStrings('tool_dataprivacy', [\n 'selectedcourses',\n 'approverequest',\n 'errornoselectedcourse',\n]);\n\n/**\n * Selected Courses popup modal.\n *\n */\nexport default class SelectedCourses {\n /**\n * @var {String} contextId Context ID to load the fragment.\n * @private\n */\n contextId = 0;\n\n /**\n * @var {String} requestId ID of data export request.\n * @private\n */\n requestId = 0;\n\n /**\n * Constructor\n *\n * @param {String} contextId Context ID to load the fragment.\n * @param {String} requestId ID of data export request.\n */\n constructor(contextId, requestId) {\n this.contextId = contextId;\n this.requestId = requestId;\n // Now create the modal.\n ModalFactory.create({\n type: ModalFactory.types.SAVE_CANCEL,\n title: getString('selectcourses', 'tool_dataprivacy'),\n body: this.getBody({requestid: requestId}),\n large: true,\n removeOnClose: true,\n buttons: {\n save: getString('approverequest', 'tool_dataprivacy'),\n },\n }).then((modal) => {\n this.modal = modal;\n\n return modal;\n }).then((modal) => {\n // We catch the modal save event, and use it to submit the form inside the modal.\n // Triggering a form submission will give JS validation scripts a chance to check for errors.\n modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));\n\n // We also catch the form submit event and use it to submit the form with ajax.\n modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));\n modal.show();\n return modal;\n }).catch(Notification.exception);\n }\n\n /**\n * Get body of modal.\n *\n * @method getBody\n * @param {Object} formdata\n * @private\n * @return {Promise}\n */\n getBody(formdata) {\n const params = formdata ? {jsonformdata: JSON.stringify(formdata)} : null;\n\n // Get the content of the modal.\n return Fragment.loadFragment('tool_dataprivacy', 'selectcourses_form', this.contextId, params);\n }\n\n /**\n * This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.\n *\n * @method submitForm\n * @param {Event} e Form submission event.\n * @private\n */\n submitForm(e) {\n e.preventDefault();\n this.modal.getRoot().find('form').submit();\n }\n\n /**\n * Submit select courses form using ajax.\n *\n * @method submitFormAjax\n * @private\n * @param {Event} e Form submission event.\n */\n submitFormAjax(e) {\n e.preventDefault();\n\n // Convert all the form elements values to a serialised string.\n let formData = this.modal.getRoot().find('form').serialize();\n\n if (formData.indexOf('coursecontextids') === -1) {\n const customSelect = this.modal.getRoot().find('.custom-select');\n const invalidText = this.modal.getRoot().find('.invalid-feedback');\n customSelect.addClass('is-invalid');\n invalidText.attr('style', 'display: block');\n getString('errornoselectedcourse', 'tool_dataprivacy').then(value => {\n invalidText.empty().append(value);\n return;\n }).catch(Notification.exception);\n return;\n }\n\n Ajax.call([{\n methodname: 'tool_dataprivacy_submit_selected_courses_form',\n args: {requestid: this.requestId, jsonformdata: JSON.stringify(formData)},\n }])[0]\n .then((data) => {\n if (data.warnings.length > 0) {\n this.modal.setBody(this.getBody(formData));\n } else {\n this.modal.destroy();\n document.location.reload();\n }\n return data;\n })\n .catch((error) => Notification.exception(error));\n }\n}\n"],"names":["constructor","contextId","requestId","create","type","ModalFactory","types","SAVE_CANCEL","title","body","this","getBody","requestid","large","removeOnClose","buttons","save","then","modal","getRoot","on","ModalEvents","submitForm","bind","submitFormAjax","show","catch","Notification","exception","formdata","params","jsonformdata","JSON","stringify","Fragment","loadFragment","e","preventDefault","find","submit","formData","serialize","indexOf","customSelect","invalidText","addClass","attr","value","empty","append","call","methodname","args","data","warnings","length","setBody","destroy","document","location","reload","error"],"mappings":"01BAgCgB,mBAAoB,CAChC,kBACA,iBACA,wDA0BAA,YAAYC,UAAWC,4CAdX,oCAMA,QASHD,UAAYA,eACZC,UAAYA,iCAEJC,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,YACzBC,OAAO,mBAAU,gBAAiB,oBAClCC,KAAMC,KAAKC,QAAQ,CAACC,UAAWV,YAC/BW,OAAO,EACPC,eAAe,EACfC,QAAS,CACLC,MAAM,mBAAU,iBAAkB,uBAEvCC,MAAMC,aACAA,MAAQA,MAENA,SACRD,MAAMC,QAGLA,MAAMC,UAAUC,GAAGC,sBAAYL,KAAMN,KAAKY,WAAWC,KAAKb,OAG1DQ,MAAMC,UAAUC,GAAG,SAAU,OAAQV,KAAKc,eAAeD,KAAKb,OAC9DQ,MAAMO,OACCP,SACRQ,MAAMC,sBAAaC,WAW1BjB,QAAQkB,gBACEC,OAASD,SAAW,CAACE,aAAcC,KAAKC,UAAUJ,WAAa,YAG9DK,kBAASC,aAAa,mBAAoB,qBAAsBzB,KAAKT,UAAW6B,QAU3FR,WAAWc,GACPA,EAAEC,sBACGnB,MAAMC,UAAUmB,KAAK,QAAQC,SAUtCf,eAAeY,GACXA,EAAEC,qBAGEG,SAAW9B,KAAKQ,MAAMC,UAAUmB,KAAK,QAAQG,gBAEH,IAA1CD,SAASE,QAAQ,oBAA4B,OACvCC,aAAejC,KAAKQ,MAAMC,UAAUmB,KAAK,kBACzCM,YAAclC,KAAKQ,MAAMC,UAAUmB,KAAK,4BAC9CK,aAAaE,SAAS,cACtBD,YAAYE,KAAK,QAAS,0CAChB,wBAAyB,oBAAoB7B,MAAK8B,QACxDH,YAAYI,QAAQC,OAAOF,UAE5BrB,MAAMC,sBAAaC,yBAIrBsB,KAAK,CAAC,CACPC,WAAY,gDACZC,KAAM,CAACxC,UAAWF,KAAKR,UAAW6B,aAAcC,KAAKC,UAAUO,cAC/D,GACHvB,MAAMoC,OACCA,KAAKC,SAASC,OAAS,OAClBrC,MAAMsC,QAAQ9C,KAAKC,QAAQ6B,iBAE3BtB,MAAMuC,UACXC,SAASC,SAASC,UAEfP,QAEV3B,OAAOmC,OAAUlC,sBAAaC,UAAUiC"}
\ No newline at end of file
diff --git a/admin/tool/dataprivacy/amd/src/selectedcourses.js b/admin/tool/dataprivacy/amd/src/selectedcourses.js
index d34a0e9c70b..5ca0e6f2f05 100644
--- a/admin/tool/dataprivacy/amd/src/selectedcourses.js
+++ b/admin/tool/dataprivacy/amd/src/selectedcourses.js
@@ -53,12 +53,6 @@ export default class SelectedCourses {
*/
requestId = 0;
- /**
- * @var {Promise}
- * @private
- */
- strings = null;
-
/**
* Constructor
*
@@ -66,7 +60,6 @@ export default class SelectedCourses {
* @param {String} requestId ID of data export request.
*/
constructor(contextId, requestId) {
-
this.contextId = contextId;
this.requestId = requestId;
// Now create the modal.
@@ -79,20 +72,20 @@ export default class SelectedCourses {
buttons: {
save: getString('approverequest', 'tool_dataprivacy'),
},
- }).then(modal => {
- this.modal = modal;
+ }).then((modal) => {
+ this.modal = modal;
- return modal;
- }).then(modal => {
- // We catch the modal save event, and use it to submit the form inside the modal.
- // Triggering a form submission will give JS validation scripts a chance to check for errors.
- modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));
+ return modal;
+ }).then((modal) => {
+ // We catch the modal save event, and use it to submit the form inside the modal.
+ // Triggering a form submission will give JS validation scripts a chance to check for errors.
+ modal.getRoot().on(ModalEvents.save, this.submitForm.bind(this));
- // We also catch the form submit event and use it to submit the form with ajax.
- modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));
- modal.show();
- return modal;
- }).catch(Notification.exception);
+ // We also catch the form submit event and use it to submit the form with ajax.
+ modal.getRoot().on('submit', 'form', this.submitFormAjax.bind(this));
+ modal.show();
+ return modal;
+ }).catch(Notification.exception);
}
/**
@@ -103,15 +96,12 @@ export default class SelectedCourses {
* @private
* @return {Promise}
*/
- getBody = (formdata) => {
+ getBody(formdata) {
+ const params = formdata ? {jsonformdata: JSON.stringify(formdata)} : null;
- let params = null;
- if (typeof formdata !== "undefined") {
- params = {jsonformdata: JSON.stringify(formdata)};
- }
// Get the content of the modal.
return Fragment.loadFragment('tool_dataprivacy', 'selectcourses_form', this.contextId, params);
- };
+ }
/**
* This triggers a form submission, so that any mform elements can do final tricks before the form submission is processed.
@@ -120,10 +110,10 @@ export default class SelectedCourses {
* @param {Event} e Form submission event.
* @private
*/
- submitForm = (e) => {
+ submitForm(e) {
e.preventDefault();
this.modal.getRoot().find('form').submit();
- };
+ }
/**
* Submit select courses form using ajax.
@@ -132,8 +122,7 @@ export default class SelectedCourses {
* @private
* @param {Event} e Form submission event.
*/
- submitFormAjax = (e) => {
-
+ submitFormAjax(e) {
e.preventDefault();
// Convert all the form elements values to a serialised string.
@@ -154,15 +143,16 @@ export default class SelectedCourses {
Ajax.call([{
methodname: 'tool_dataprivacy_submit_selected_courses_form',
args: {requestid: this.requestId, jsonformdata: JSON.stringify(formData)},
- done: (data) => {
- if (data.warnings.length > 0) {
- this.modal.setBody(this.getBody(formData));
- } else {
- this.modal.destroy();
- document.location.reload();
- }
- },
- fail: Notification.exception
- }]);
- };
+ }])[0]
+ .then((data) => {
+ if (data.warnings.length > 0) {
+ this.modal.setBody(this.getBody(formData));
+ } else {
+ this.modal.destroy();
+ document.location.reload();
+ }
+ return data;
+ })
+ .catch((error) => Notification.exception(error));
+ }
}
diff --git a/admin/tool/dataprivacy/classes/api.php b/admin/tool/dataprivacy/classes/api.php
index 5f9264c4844..532deae3bee 100644
--- a/admin/tool/dataprivacy/classes/api.php
+++ b/admin/tool/dataprivacy/classes/api.php
@@ -1375,11 +1375,10 @@ class api {
/**
* Adds the contexts from the contextlist_collection to the request with the status provided.
*
- * @since Moodle 4.0
+ * @since Moodle 4.3
* @param contextlist_collection $clcollection a collection of contextlists for all components.
* @param int $requestid the id of the request.
* @param int $status the status to set the contexts to.
- * return void
*/
public static function add_request_contexts_with_status(contextlist_collection $clcollection, int $requestid, int $status) {
global $DB;
@@ -1414,7 +1413,7 @@ class api {
/**
* Finds all request contextlists having at least on approved context, and returns them as in a contextlist_collection.
*
- * @since Moodle 3.11
+ * @since Moodle 4.3
* @param data_request $request the data request with which the contextlists are associated.
* @return contextlist_collection the collection of approved_contextlist objects.
* @throws coding_exception
@@ -1464,7 +1463,7 @@ class api {
/**
* Sets the status of all contexts associated with the request.
*
- * @since Moodle 3.11
+ * @since Moodle 4.3
* @param int $requestid the requestid to which the contexts belong.
* @param int $status the status to set to.
* @throws \dml_exception if the requestid is invalid.
@@ -1511,7 +1510,7 @@ class api {
/**
* Only approve the contexts which are children of the provided course contexts.
*
- * @since Moodle 3.11
+ * @since Moodle 4.3
* @param int $requestid Request identifier
* @param array $coursecontextids List of course context identifier.
* @throws \dml_transaction_exception
@@ -1602,7 +1601,7 @@ class api {
/**
* Get list of course context for user to filter.
*
- * @since Moodle 3.11
+ * @since Moodle 4.3
* @param int $requestid Request identifier.
* @return array
* @throws dml_exception
diff --git a/admin/tool/dataprivacy/classes/contextlist_context.php b/admin/tool/dataprivacy/classes/contextlist_context.php
index 0bfdb46b5cf..2f40a786e6e 100644
--- a/admin/tool/dataprivacy/classes/contextlist_context.php
+++ b/admin/tool/dataprivacy/classes/contextlist_context.php
@@ -24,7 +24,7 @@ use core\persistent;
* @package tool_dataprivacy
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
class contextlist_context extends persistent {
@@ -44,7 +44,6 @@ class contextlist_context extends persistent {
* Return the definition of the properties of this model.
*
* @return array
- * @since Moodle 4.0
*/
protected static function define_properties(): array {
return [
@@ -61,8 +60,8 @@ class contextlist_context extends persistent {
self::STATUS_REJECTED,
],
'default' => self::STATUS_PENDING,
- 'type' => PARAM_INT
- ]
+ 'type' => PARAM_INT,
+ ],
];
}
}
diff --git a/admin/tool/dataprivacy/classes/dataprivacy_contextlist.php b/admin/tool/dataprivacy/classes/dataprivacy_contextlist.php
index 25f92ebb1e8..1fad7937604 100644
--- a/admin/tool/dataprivacy/classes/dataprivacy_contextlist.php
+++ b/admin/tool/dataprivacy/classes/dataprivacy_contextlist.php
@@ -24,7 +24,7 @@ use core\persistent;
* @package tool_dataprivacy
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
class dataprivacy_contextlist extends persistent {
@@ -35,13 +35,12 @@ class dataprivacy_contextlist extends persistent {
* Return the definition of the properties of this model.
*
* @return array
- * @since Moodle 4.0
*/
protected static function define_properties(): array {
return [
'component' => [
- 'type' => PARAM_TEXT
- ]
+ 'type' => PARAM_TEXT,
+ ],
];
}
@@ -50,7 +49,6 @@ class dataprivacy_contextlist extends persistent {
*
* @param \core_privacy\local\request\contextlist $contextlist the core privacy contextlist.
* @return dataprivacy_contextlist a dataprivacy_contextlist persistent.
- * @since Moodle 4.0
*/
public static function from_contextlist(\core_privacy\local\request\contextlist $contextlist): dataprivacy_contextlist {
$contextlistpersistent = new dataprivacy_contextlist();
diff --git a/admin/tool/dataprivacy/classes/external.php b/admin/tool/dataprivacy/classes/external.php
index d7ed7739512..15cfc191617 100644
--- a/admin/tool/dataprivacy/classes/external.php
+++ b/admin/tool/dataprivacy/classes/external.php
@@ -358,7 +358,6 @@ class external extends external_api {
]);
}
-
/**
* Parameter description for approve_data_request().
*
diff --git a/admin/tool/dataprivacy/classes/external/data_request_exporter.php b/admin/tool/dataprivacy/classes/external/data_request_exporter.php
index 4b5f49d5eb2..41ee4bac745 100644
--- a/admin/tool/dataprivacy/classes/external/data_request_exporter.php
+++ b/admin/tool/dataprivacy/classes/external/data_request_exporter.php
@@ -107,7 +107,7 @@ class data_request_exporter extends persistent_exporter {
'allowfiltering' => [
'type' => PARAM_BOOL,
'optional' => true,
- 'default' => false
+ 'default' => false,
],
'canmarkcomplete' => [
'type' => PARAM_BOOL,
diff --git a/admin/tool/dataprivacy/classes/external/submit_selected_courses_form.php b/admin/tool/dataprivacy/classes/external/submit_selected_courses_form.php
index c30f102c135..0d146eb454b 100644
--- a/admin/tool/dataprivacy/classes/external/submit_selected_courses_form.php
+++ b/admin/tool/dataprivacy/classes/external/submit_selected_courses_form.php
@@ -23,25 +23,20 @@
*/
namespace tool_dataprivacy\external;
-defined('MOODLE_INTERNAL') || die();
-
-global $CFG;
-require_once($CFG->libdir . '/externallib.php');
-
-use context_system;
-use external_api;
-use external_function_parameters;
-use external_single_structure;
-use external_value;
-use external_warnings;
+use core_external\external_api;
+use core_external\external_function_parameters;
+use core_external\external_single_structure;
+use core_external\external_value;
+use core_external\external_warnings;
use core\notification;
+use context_system;
/**
* Class for submit selected courses from form.
*
* @copyright 2021 The Open University.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * since Moodle 4.0
+ * @since Moodle 4.3
*/
class submit_selected_courses_form extends external_api {
/**
@@ -51,8 +46,8 @@ class submit_selected_courses_form extends external_api {
*/
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters([
- 'requestid' => new external_value(PARAM_INT, 'The id of data request'),
- 'jsonformdata' => new external_value(PARAM_RAW, 'The data of selected courses form, encoded as a json array')
+ 'requestid' => new external_value(PARAM_INT, 'The id of data request'),
+ 'jsonformdata' => new external_value(PARAM_RAW, 'The data of selected courses form, encoded as a json array'),
]);
}
@@ -68,8 +63,8 @@ class submit_selected_courses_form extends external_api {
$warnings = [];
$result = false;
$params = self::validate_parameters(self::execute_parameters(), [
- 'requestid' => $requestid,
- 'jsonformdata' => $jsonformdata
+ 'requestid' => $requestid,
+ 'jsonformdata' => $jsonformdata,
]);
$context = context_system::instance();
@@ -110,15 +105,15 @@ class submit_selected_courses_form extends external_api {
notification::success(get_string('requestapproved', 'tool_dataprivacy'));
} else {
$warnings = [
- 'item' => $requestid,
- 'warningcode' => 'errorrequestnotfound',
- 'message' => get_string('errorrequestnotfound', 'tool_dataprivacy')
+ 'item' => $requestid,
+ 'warningcode' => 'errorrequestnotfound',
+ 'message' => get_string('errorrequestnotfound', 'tool_dataprivacy'),
];
}
}
return [
- 'result' => $result,
- 'warnings' => $warnings
+ 'result' => $result,
+ 'warnings' => $warnings,
];
}
@@ -129,8 +124,8 @@ class submit_selected_courses_form extends external_api {
*/
public static function execute_returns(): external_single_structure {
return new external_single_structure([
- 'result' => new external_value(PARAM_BOOL, 'The processing result'),
- 'warnings' => new external_warnings()
+ 'result' => new external_value(PARAM_BOOL, 'The processing result'),
+ 'warnings' => new external_warnings(),
]);
}
}
diff --git a/admin/tool/dataprivacy/classes/form/exportfilter_form.php b/admin/tool/dataprivacy/classes/form/exportfilter_form.php
index 9b638b5767a..af20de846c9 100644
--- a/admin/tool/dataprivacy/classes/form/exportfilter_form.php
+++ b/admin/tool/dataprivacy/classes/form/exportfilter_form.php
@@ -20,7 +20,7 @@
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package tool_dataprivacy
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
namespace tool_dataprivacy\form;
@@ -35,14 +35,11 @@ require_once($CFG->libdir.'/formslib.php');
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package tool_dataprivacy
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
class exportfilter_form extends \moodleform {
/**
* Form definition.
- *
- * @return void
- * @since Moodle 4.0
*/
public function definition(): void {
$requestid = $this->_customdata['requestid'];
@@ -77,8 +74,12 @@ class exportfilter_form extends \moodleform {
}
if ($contexts) {
- $mform->addElement('selectgroups', 'coursecontextids', get_string('selectcourses', 'tool_dataprivacy'),
- $selectitems);
+ $mform->addElement(
+ 'selectgroups',
+ 'coursecontextids',
+ get_string('selectcourses', 'tool_dataprivacy'),
+ $selectitems,
+ );
$mform->getElement('coursecontextids')->setMultiple(true);
$mform->getElement('coursecontextids')->setSize(15);
} else {
@@ -92,7 +93,6 @@ class exportfilter_form extends \moodleform {
* @param array $data
* @param array $files
* @return array
- * @since Moodle 4.0
*/
public function validation($data, $files) {
$errors = [];
diff --git a/admin/tool/dataprivacy/classes/output/data_requests_table.php b/admin/tool/dataprivacy/classes/output/data_requests_table.php
index c31469da9b5..57678967d72 100644
--- a/admin/tool/dataprivacy/classes/output/data_requests_table.php
+++ b/admin/tool/dataprivacy/classes/output/data_requests_table.php
@@ -35,7 +35,6 @@ use moodle_url;
use stdClass;
use table_sql;
use tool_dataprivacy\api;
-use tool_dataprivacy\data_request;
use tool_dataprivacy\external\data_request_exporter;
defined('MOODLE_INTERNAL') || die;
@@ -225,8 +224,11 @@ class data_requests_table extends table_sql {
// View action.
$actionurl = new moodle_url('#');
- $actiondata = ['data-action' => 'view', 'data-requestid' => $requestid,
- 'data-contextid' => \context_system::instance()->id];
+ $actiondata = [
+ 'data-action' => 'view',
+ 'data-requestid' => $requestid,
+ 'data-contextid' => \context_system::instance()->id,
+ ];
$actiontext = get_string('viewrequest', 'tool_dataprivacy');
$actions[] = new action_menu_link_secondary($actionurl, null, $actiontext, $actiondata);
diff --git a/admin/tool/dataprivacy/classes/request_contextlist.php b/admin/tool/dataprivacy/classes/request_contextlist.php
index 595c696ef85..48a7f169477 100644
--- a/admin/tool/dataprivacy/classes/request_contextlist.php
+++ b/admin/tool/dataprivacy/classes/request_contextlist.php
@@ -24,7 +24,7 @@ use core\persistent;
* @package tool_dataprivacy
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
class request_contextlist extends persistent {
@@ -39,11 +39,11 @@ class request_contextlist extends persistent {
protected static function define_properties(): array {
return [
'requestid' => [
- 'type' => PARAM_INT
+ 'type' => PARAM_INT,
],
'contextlistid' => [
- 'type' => PARAM_INT
- ]
+ 'type' => PARAM_INT,
+ ],
];
}
@@ -53,7 +53,6 @@ class request_contextlist extends persistent {
* @param int $requestid ID of data request.
* @param int $contextlistid ID of context list.
* @return $this
- * @since Moodle 4.0
*/
public static function create_relation(int $requestid, int $contextlistid): request_contextlist {
$requestcontextlist = new request_contextlist();
diff --git a/admin/tool/dataprivacy/classes/task/initiate_data_request_task.php b/admin/tool/dataprivacy/classes/task/initiate_data_request_task.php
index 24d10d7b193..02482795727 100644
--- a/admin/tool/dataprivacy/classes/task/initiate_data_request_task.php
+++ b/admin/tool/dataprivacy/classes/task/initiate_data_request_task.php
@@ -18,7 +18,6 @@ namespace tool_dataprivacy\task;
use coding_exception;
use core\task\adhoc_task;
-use moodle_exception;
use tool_dataprivacy\api;
use tool_dataprivacy\contextlist_context;
use tool_dataprivacy\data_request;
@@ -32,17 +31,14 @@ use tool_dataprivacy\data_request;
* @package tool_dataprivacy
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @since Moodle 4.0
+ * @since Moodle 4.3
*/
class initiate_data_request_task extends adhoc_task {
/**
* Run the task to initiate the data request process.
- *
- * return void
- * @since Moodle 4.0
*/
- public function execute():void {
+ public function execute(): void {
if (!isset($this->get_custom_data()->requestid)) {
throw new coding_exception('The custom data \'requestid\' is required.');
}
diff --git a/admin/tool/dataprivacy/classes/task/process_data_request_task.php b/admin/tool/dataprivacy/classes/task/process_data_request_task.php
index 8ecf60ff850..9d3427ea269 100644
--- a/admin/tool/dataprivacy/classes/task/process_data_request_task.php
+++ b/admin/tool/dataprivacy/classes/task/process_data_request_task.php
@@ -35,8 +35,6 @@ use moodle_url;
use tool_dataprivacy\api;
use tool_dataprivacy\data_request;
-defined('MOODLE_INTERNAL') || die();
-
/**
* Class that processes an approved data request and prepares/deletes the user's data.
*
@@ -107,7 +105,10 @@ class process_data_request_task extends adhoc_task {
$approvedclcollection = api::get_approved_contextlist_collection_for_request($requestpersistent);
} else {
$approvedclcollection = api::get_approved_contextlist_collection_for_collection(
- $contextlistcollection, $foruser, $request->type);
+ $contextlistcollection,
+ $foruser,
+ $request->type,
+ );
}
$usercontext = \context_user::instance($foruser->id, IGNORE_MISSING);
@@ -140,7 +141,10 @@ class process_data_request_task extends adhoc_task {
$completestatus = api::DATAREQUEST_STATUS_REJECTED;
} else {
$approvedclcollection = api::get_approved_contextlist_collection_for_collection(
- $contextlistcollection, $foruser, $request->type);
+ $contextlistcollection,
+ $foruser,
+ $request->type,
+ );
$manager = new \core_privacy\manager();
$manager->set_observer(new \tool_dataprivacy\manager_observer());
diff --git a/admin/tool/dataprivacy/db/services.php b/admin/tool/dataprivacy/db/services.php
index 994dcf0bbfd..d683eafeb51 100644
--- a/admin/tool/dataprivacy/db/services.php
+++ b/admin/tool/dataprivacy/db/services.php
@@ -75,12 +75,11 @@ $functions = [
],
'tool_dataprivacy_submit_selected_courses_form' => [
'classname' => 'tool_dataprivacy\external\submit_selected_courses_form',
- 'classpath' => '',
'description' => 'Save list of selected courses for export',
'type' => 'write',
'capabilities' => 'tool/dataprivacy:managedatarequests',
- 'ajax' => 'true',
- 'loginrequired' => 'true',
+ 'ajax' => true,
+ 'loginrequired' => true,
],
'tool_dataprivacy_bulk_approve_data_requests' => [
'classname' => 'tool_dataprivacy\external',
diff --git a/admin/tool/dataprivacy/db/upgrade.php b/admin/tool/dataprivacy/db/upgrade.php
index 31eb8916df7..8b67f7c50de 100644
--- a/admin/tool/dataprivacy/db/upgrade.php
+++ b/admin/tool/dataprivacy/db/upgrade.php
@@ -90,7 +90,7 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
// Automatically generated Moodle v4.2.0 release upgrade line.
// Put any upgrade step following this.
- if ($oldversion < 2023052200) {
+ if ($oldversion < 2023062700) {
// Define table tool_dataprivacy_contextlist to be created.
$table = new xmldb_table('tool_dataprivacy_contextlist');
@@ -149,7 +149,7 @@ function xmldb_tool_dataprivacy_upgrade($oldversion) {
}
// Dataprivacy savepoint reached.
- upgrade_plugin_savepoint(true, 2023052200, 'tool', 'dataprivacy');
+ upgrade_plugin_savepoint(true, 2023062700, 'tool', 'dataprivacy');
}
return true;
diff --git a/admin/tool/dataprivacy/lib.php b/admin/tool/dataprivacy/lib.php
index 16a5fae516b..060db1b9db6 100644
--- a/admin/tool/dataprivacy/lib.php
+++ b/admin/tool/dataprivacy/lib.php
@@ -24,8 +24,6 @@
use core_user\output\myprofile\tree;
use tool_dataprivacy\form\exportfilter_form;
-defined('MOODLE_INTERNAL') || die();
-
/**
* Add nodes to myprofile page.
*
diff --git a/admin/tool/dataprivacy/tests/api_test.php b/admin/tool/dataprivacy/tests/api_test.php
index 7359edf91dc..6216e9150b8 100644
--- a/admin/tool/dataprivacy/tests/api_test.php
+++ b/admin/tool/dataprivacy/tests/api_test.php
@@ -691,8 +691,16 @@ class api_test extends \advanced_testcase {
* @throws coding_exception
* @throws invalid_persistent_exception
*/
- public function test_create_data_request($asprivacyofficer, $type, $setting, $automaticapproval, $expecteddpoval,
- $expectedstatus, $expectedtaskcount, $allowfiltering) {
+ public function test_create_data_request(
+ $asprivacyofficer,
+ $type,
+ $setting,
+ $automaticapproval,
+ $expecteddpoval,
+ $expectedstatus,
+ $expectedtaskcount,
+ $allowfiltering,
+ ) {
global $USER;
$this->resetAfterTest();
diff --git a/admin/tool/dataprivacy/tests/behat/dataexport.feature b/admin/tool/dataprivacy/tests/behat/dataexport.feature
index 71d9f00dd69..1d643f47561 100644
--- a/admin/tool/dataprivacy/tests/behat/dataexport.feature
+++ b/admin/tool/dataprivacy/tests/behat/dataexport.feature
@@ -185,7 +185,7 @@ Feature: Data export from the privacy API
And I reload the page
And I should see "Download ready" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
- And following "Download" should download between "1" and "144000" bytes
+ And following "Download" should download between "1" and "167500" bytes
And the following config values are set as admin:
| privacyrequestexpiry | 1 | tool_dataprivacy |
And I wait "1" seconds
@@ -229,7 +229,7 @@ Feature: Data export from the privacy API
And I reload the page
And I should see "Download ready" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
- And following "Download" should download between "1" and "144000" bytes
+ And following "Download" should download between "1" and "167500" bytes
@javascript
Scenario: Filter before export data for a user and download it in the view request action
@@ -262,4 +262,4 @@ Feature: Data export from the privacy API
And I reload the page
And I should see "Download ready" in the "Victim User 1" "table_row"
And I open the action menu in "Victim User 1" "table_row"
- And following "Download" should download between "1" and "144000" bytes
+ And following "Download" should download between "1" and "167500" bytes
diff --git a/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php b/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php
index c26da139b34..06d21dd596b 100644
--- a/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php
+++ b/admin/tool/dataprivacy/tests/external/submit_selected_courses_form_test.php
@@ -18,7 +18,6 @@
* This is the external method for submit selected courses.
*
* @package tool_dataprivacy
- * @since Moodle 4.0
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -43,8 +42,6 @@ use tool_dataprivacy\api;
class submit_selected_courses_form_test extends \externallib_advanced_testcase {
/**
* Test for submit_selected_courses_form().
- *
- * @runInSeparateProcess
*/
public function test_submit_selected_courses_form() {
global $DB;
diff --git a/admin/tool/dataprivacy/version.php b/admin/tool/dataprivacy/version.php
index 823a2d21f1e..1d635653db9 100644
--- a/admin/tool/dataprivacy/version.php
+++ b/admin/tool/dataprivacy/version.php
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2023052200;
+$plugin->version = 2023062700;
$plugin->requires = 2023041800;
$plugin->component = 'tool_dataprivacy';