Merge branch 'MDL-73376-master-fix' of https://github.com/junpataleta/moodle

This commit is contained in:
Sara Arjona 2022-09-01 14:04:50 +02:00
commit 0ffc0b228e
8 changed files with 10 additions and 16 deletions

View File

@ -6,6 +6,6 @@ define("qbank_comment/comment",["exports","core/fragment","core/str","core/modal
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modal_events=_interopRequireDefault(_modal_events),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification);_exports.init=questionSelector=>{let target=document.querySelector(questionSelector),questionId=target.getAttribute("data-questionid"),courseID=target.getAttribute("data-courseid");target.addEventListener("click",(()=>{((questionId,courseID,contextId)=>{let args={questionid:questionId,courseid:courseID,uniqueidentifier:"question_comment_version_dropdown"};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:Str.get_string("commentheader","qbank_comment"),body:_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args),large:!0}).then((modal=>{let root=modal.getRoot();return root.on(_modal_events.default.bodyRendered,(function(){document.querySelectorAll("div.comment-area a")[0].style.display="none"})),root.on("change","#question_comment_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args))})),Str.get_strings([{key:"addcomment",component:"qbank_comment"},{key:"close",component:"qbank_comment"}]).then((strings=>{modal.setButtonText("save",strings[0]),modal.setButtonText("cancel",strings[1])})).fail(_notification.default.exception),root.on(_modal_events.default.cancel,(function(){location.reload(),modal.hide()})),root.on(_modal_events.default.save,(function(e){e.preventDefault();const submitlink=document.querySelectorAll("div.comment-area a")[0],textarea=document.querySelectorAll("div.comment-area textarea")[0];textarea.value!=textarea.getAttribute("aria-label")&&""!=textarea.value&&submitlink.click()})),root.on("click",'button[data-action="hide"]',(()=>{location.reload(),modal.hide()})),modal.show(),modal})).fail(_notification.default.exception)})(questionId,courseID,1)}))}}));
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str),_modal_events=_interopRequireDefault(_modal_events),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification);_exports.init=questionSelector=>{let target=document.querySelector(questionSelector),questionId=target.getAttribute("data-questionid"),courseID=target.getAttribute("data-courseid");target.addEventListener("click",(()=>{((questionId,courseID,contextId)=>{let args={questionid:questionId,courseid:courseID};_modal_factory.default.create({type:_modal_factory.default.types.SAVE_CANCEL,title:Str.get_string("commentheader","qbank_comment"),body:_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args),large:!0}).then((modal=>{let root=modal.getRoot();return root.on(_modal_events.default.bodyRendered,(function(){document.querySelectorAll("div.comment-area a")[0].style.display="none"})),root.on("change","#question_comment_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_comment","question_comment",contextId,args))})),Str.get_strings([{key:"addcomment",component:"qbank_comment"},{key:"close",component:"qbank_comment"}]).then((strings=>{modal.setButtonText("save",strings[0]),modal.setButtonText("cancel",strings[1])})).fail(_notification.default.exception),root.on(_modal_events.default.cancel,(function(){location.reload(),modal.hide()})),root.on(_modal_events.default.save,(function(e){e.preventDefault();const submitlink=document.querySelectorAll("div.comment-area a")[0],textarea=document.querySelectorAll("div.comment-area textarea")[0];textarea.value!=textarea.getAttribute("aria-label")&&""!=textarea.value&&submitlink.click()})),root.on("click",'button[data-action="hide"]',(()=>{location.reload(),modal.hide()})),modal.show(),modal})).fail(_notification.default.exception)})(questionId,courseID,1)}))}}));
//# sourceMappingURL=comment.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -39,8 +39,7 @@ import Notification from 'core/notification';
const commentEvent = (questionId, courseID, contextId) => {
let args = {
questionid: questionId,
courseid: courseID,
uniqueidentifier: 'question_comment_version_dropdown'
courseid: courseID
};
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,

View File

@ -109,9 +109,6 @@ function qbank_comment_preview_display($question, $courseid): string {
* @return string rendered output
*/
function qbank_comment_output_fragment_question_comment($args): string {
if (!$args['questionid'] || !$args['uniqueidentifier']) {
return '';
}
global $USER, $PAGE, $CFG, $DB;
$displaydata = [];
require_once($CFG->dirroot . '/question/engine/bank.php');
@ -136,7 +133,8 @@ function qbank_comment_output_fragment_question_comment($args): string {
$displaydata['commenstdisabled'] = true;
}
$selector = \core_question\output\question_version_selection::make_for_question($args['uniqueidentifier'], $args['questionid']);
$selector = \core_question\output\question_version_selection::make_for_question('question_comment_version_dropdown',
$args['questionid']);
$qbankrenderer = $PAGE->get_renderer('core_question', 'bank');
$displaydata['versionselection'] = $selector->export_for_template($qbankrenderer);

View File

@ -6,6 +6,6 @@ define("qbank_usage/usage",["exports","core/fragment","core/modal_factory","core
* @copyright 2021 Catalyst IT Australia Pty Ltd
* @author Safat Shahin <safatshahin@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str);_exports.init=(questionSelector,contextId)=>{let target=document.querySelector(questionSelector),questionId=target.getAttribute("data-questionid");target.addEventListener("click",(()=>{((questionId,contextId)=>{let args={questionid:questionId,uniqueidentifier:"question_usage_version_dropdown"};_modal_factory.default.create({type:_modal_factory.default.types.CANCEL,title:Str.get_string("usageheader","qbank_usage"),body:_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args),large:!0}).then((modal=>(modal.show(),modal.getRoot().on("click","a[href].page-link",(function(e){e.preventDefault();let attr=e.target.getAttribute("href");"#"!==attr&&(args.querystring=attr,modal.setBody(_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args)))})),modal.getRoot().on("change","#question_usage_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args))})),modal))).fail(_notification.default.exception)})(questionId,contextId)}))}}));
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_fragment=_interopRequireDefault(_fragment),_modal_factory=_interopRequireDefault(_modal_factory),_notification=_interopRequireDefault(_notification),Str=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}(Str);_exports.init=(questionSelector,contextId)=>{let target=document.querySelector(questionSelector),questionId=target.getAttribute("data-questionid");target.addEventListener("click",(()=>{((questionId,contextId)=>{let args={questionid:questionId};_modal_factory.default.create({type:_modal_factory.default.types.CANCEL,title:Str.get_string("usageheader","qbank_usage"),body:_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args),large:!0}).then((modal=>(modal.show(),modal.getRoot().on("click","a[href].page-link",(function(e){e.preventDefault();let attr=e.target.getAttribute("href");"#"!==attr&&(args.querystring=attr,modal.setBody(_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args)))})),modal.getRoot().on("change","#question_usage_version_dropdown",(function(e){args.questionid=e.target.value,modal.setBody(_fragment.default.loadFragment("qbank_usage","question_usage",contextId,args))})),modal))).fail(_notification.default.exception)})(questionId,contextId)}))}}));
//# sourceMappingURL=usage.min.js.map

View File

@ -1 +1 @@
{"version":3,"file":"usage.min.js","sources":["../src/usage.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Usage column selector js.\n *\n * @module qbank_usage/usage\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Safat Shahin <safatshahin@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Fragment from 'core/fragment';\nimport ModalFactory from 'core/modal_factory';\nimport Notification from 'core/notification';\nimport * as Str from 'core/str';\n\n/**\n * Event listeners for the module.\n *\n * @method clickEvent\n * @param {int} questionId\n * @param {int} contextId\n */\nconst usageEvent = (questionId, contextId) => {\n let args = {\n questionid: questionId,\n uniqueidentifier: 'question_usage_version_dropdown'\n };\n ModalFactory.create({\n type: ModalFactory.types.CANCEL,\n title: Str.get_string('usageheader', 'qbank_usage'),\n body: Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args),\n large: true,\n }).then((modal) => {\n modal.show();\n modal.getRoot().on('click', 'a[href].page-link', function(e) {\n e.preventDefault();\n let attr = e.target.getAttribute(\"href\");\n if (attr !== '#') {\n args.querystring = attr;\n modal.setBody(Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args));\n }\n });\n // Version selection event.\n modal.getRoot().on('change', '#question_usage_version_dropdown', function(e) {\n args.questionid = e.target.value;\n modal.setBody(Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args));\n });\n return modal;\n }).fail(Notification.exception);\n};\n\n/**\n * Entrypoint of the js.\n *\n * @method init\n * @param {string} questionSelector the question usage identifier.\n * @param {int} contextId the question context id.\n */\nexport const init = (questionSelector, contextId) => {\n let target = document.querySelector(questionSelector);\n let questionId = target.getAttribute('data-questionid');\n target.addEventListener('click', () => {\n // Call for the event listener to listed for clicks in any usage count row.\n usageEvent(questionId, contextId);\n });\n};\n"],"names":["questionSelector","contextId","target","document","querySelector","questionId","getAttribute","addEventListener","args","questionid","uniqueidentifier","create","type","ModalFactory","types","CANCEL","title","Str","get_string","body","Fragment","loadFragment","large","then","modal","show","getRoot","on","e","preventDefault","attr","querystring","setBody","value","fail","Notification","exception","usageEvent"],"mappings":";;;;;;;;44BAwEoB,CAACA,iBAAkBC,iBAC/BC,OAASC,SAASC,cAAcJ,kBAChCK,WAAaH,OAAOI,aAAa,mBACrCJ,OAAOK,iBAAiB,SAAS,KAvClB,EAACF,WAAYJ,iBACxBO,KAAO,CACPC,WAAYJ,WACZK,iBAAkB,0DAETC,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,OACzBC,MAAOC,IAAIC,WAAW,cAAe,eACrCC,KAAMC,kBAASC,aAAa,cAAe,iBAAkBpB,UAAWO,MACxEc,OAAO,IACRC,MAAMC,QACLA,MAAMC,OACND,MAAME,UAAUC,GAAG,QAAS,qBAAqB,SAASC,GACtDA,EAAEC,qBACEC,KAAOF,EAAE1B,OAAOI,aAAa,QACpB,MAATwB,OACAtB,KAAKuB,YAAcD,KACnBN,MAAMQ,QAAQZ,kBAASC,aAAa,cAAe,iBAAkBpB,UAAWO,WAIxFgB,MAAME,UAAUC,GAAG,SAAU,oCAAoC,SAASC,GACtEpB,KAAKC,WAAamB,EAAE1B,OAAO+B,MAC3BT,MAAMQ,QAAQZ,kBAASC,aAAa,cAAe,iBAAkBpB,UAAWO,UAE7EgB,SACRU,KAAKC,sBAAaC,YAejBC,CAAWhC,WAAYJ"}
{"version":3,"file":"usage.min.js","sources":["../src/usage.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Usage column selector js.\n *\n * @module qbank_usage/usage\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Safat Shahin <safatshahin@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Fragment from 'core/fragment';\nimport ModalFactory from 'core/modal_factory';\nimport Notification from 'core/notification';\nimport * as Str from 'core/str';\n\n/**\n * Event listeners for the module.\n *\n * @method clickEvent\n * @param {int} questionId\n * @param {int} contextId\n */\nconst usageEvent = (questionId, contextId) => {\n let args = {\n questionid: questionId\n };\n ModalFactory.create({\n type: ModalFactory.types.CANCEL,\n title: Str.get_string('usageheader', 'qbank_usage'),\n body: Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args),\n large: true,\n }).then((modal) => {\n modal.show();\n modal.getRoot().on('click', 'a[href].page-link', function(e) {\n e.preventDefault();\n let attr = e.target.getAttribute(\"href\");\n if (attr !== '#') {\n args.querystring = attr;\n modal.setBody(Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args));\n }\n });\n // Version selection event.\n modal.getRoot().on('change', '#question_usage_version_dropdown', function(e) {\n args.questionid = e.target.value;\n modal.setBody(Fragment.loadFragment('qbank_usage', 'question_usage', contextId, args));\n });\n return modal;\n }).fail(Notification.exception);\n};\n\n/**\n * Entrypoint of the js.\n *\n * @method init\n * @param {string} questionSelector the question usage identifier.\n * @param {int} contextId the question context id.\n */\nexport const init = (questionSelector, contextId) => {\n let target = document.querySelector(questionSelector);\n let questionId = target.getAttribute('data-questionid');\n target.addEventListener('click', () => {\n // Call for the event listener to listed for clicks in any usage count row.\n usageEvent(questionId, contextId);\n });\n};\n"],"names":["questionSelector","contextId","target","document","querySelector","questionId","getAttribute","addEventListener","args","questionid","create","type","ModalFactory","types","CANCEL","title","Str","get_string","body","Fragment","loadFragment","large","then","modal","show","getRoot","on","e","preventDefault","attr","querystring","setBody","value","fail","Notification","exception","usageEvent"],"mappings":";;;;;;;;44BAuEoB,CAACA,iBAAkBC,iBAC/BC,OAASC,SAASC,cAAcJ,kBAChCK,WAAaH,OAAOI,aAAa,mBACrCJ,OAAOK,iBAAiB,SAAS,KAtClB,EAACF,WAAYJ,iBACxBO,KAAO,CACPC,WAAYJ,mCAEHK,OAAO,CAChBC,KAAMC,uBAAaC,MAAMC,OACzBC,MAAOC,IAAIC,WAAW,cAAe,eACrCC,KAAMC,kBAASC,aAAa,cAAe,iBAAkBnB,UAAWO,MACxEa,OAAO,IACRC,MAAMC,QACLA,MAAMC,OACND,MAAME,UAAUC,GAAG,QAAS,qBAAqB,SAASC,GACtDA,EAAEC,qBACEC,KAAOF,EAAEzB,OAAOI,aAAa,QACpB,MAATuB,OACArB,KAAKsB,YAAcD,KACnBN,MAAMQ,QAAQZ,kBAASC,aAAa,cAAe,iBAAkBnB,UAAWO,WAIxFe,MAAME,UAAUC,GAAG,SAAU,oCAAoC,SAASC,GACtEnB,KAAKC,WAAakB,EAAEzB,OAAO8B,MAC3BT,MAAMQ,QAAQZ,kBAASC,aAAa,cAAe,iBAAkBnB,UAAWO,UAE7Ee,SACRU,KAAKC,sBAAaC,YAejBC,CAAW/B,WAAYJ"}

View File

@ -36,8 +36,7 @@ import * as Str from 'core/str';
*/
const usageEvent = (questionId, contextId) => {
let args = {
questionid: questionId,
uniqueidentifier: 'question_usage_version_dropdown'
questionid: questionId
};
ModalFactory.create({
type: ModalFactory.types.CANCEL,

View File

@ -32,9 +32,6 @@ defined('MOODLE_INTERNAL') || die();
* @return string rendered output
*/
function qbank_usage_output_fragment_question_usage(array $args): string {
if (!$args['questionid'] || !$args['uniqueidentifier']) {
return '';
}
global $USER, $PAGE, $CFG, $DB;
require_once($CFG->dirroot . '/question/engine/bank.php');
$displaydata = [];
@ -62,7 +59,8 @@ function qbank_usage_output_fragment_question_usage(array $args): string {
}
}
$displaydata['tablesql'] = $questionusagetable->export_for_fragment();
$selector = \core_question\output\question_version_selection::make_for_question($args['uniqueidentifier'], $args['questionid']);
$selector = \core_question\output\question_version_selection::make_for_question('question_usage_version_dropdown',
$args['questionid']);
$qbankrenderer = $PAGE->get_renderer('core_question', 'bank');
$displaydata['versionselection'] = $selector->export_for_template($qbankrenderer);