Current Path : C:/xampp/htdocs/moodle/mod/quiz/amd/build/ |
Current File : C:/xampp/htdocs/moodle/mod/quiz/amd/build/modal_add_random_question.min.js.map |
{"version":3,"sources":["../src/modal_add_random_question.js"],"names":["define","$","Y","Notification","Modal","ModalEvents","ModalRegistry","Fragment","Templates","registered","SELECTORS","EXISTING_CATEGORY_CONTAINER","EXISTING_CATEGORY_FORM_ELEMENT","NEW_CATEGORY_CONTAINER","NEW_CATEGORY_FORM_ELEMENT","TAB_CONTENT","ADD_ON_PAGE_FORM_ELEMENT","SUBMIT_BUTTON_ELEMENT","CANCEL_BUTTON_ELEMENT","FORM_HEADER","BUTTON_CONTAINER","ModalAddRandomQuestion","root","call","contextId","addOnPageId","category","returnUrl","cmid","loadedForm","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setAddOnPageId","getBody","find","val","getAddOnPageId","setCategory","getCategory","setReturnUrl","url","getReturnUrl","setCMID","getCMID","moveFormElementIntoTab","formElement","tabElement","submitButtons","footer","addClass","wrap","closest","remove","appendTo","moveTabsIntoTabContent","form","tabContent","empty","wrapAll","moveCancelButtonToTabs","cancelButton","tabFooters","clone","loadForm","loadFragment","addonpage","cat","returnurl","then","html","js","existingCategoryFormElement","existingCategoryTab","newCategoryFormElement","newCategoryTab","replaceNode","bind","use","M","core_formchangechecker","reset_form_dirty_state","fail","exception","show","register"],"mappings":"AAuBAA,OAAM,sCAAC,CACH,QADG,CAEH,UAFG,CAGH,mBAHG,CAIH,YAJG,CAKH,mBALG,CAMH,qBANG,CAOH,eAPG,CAQH,gBARG,CAAD,CAUN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQIC,CARJ,CASE,IAEMC,CAAAA,CAAU,GAFhB,CAGMC,CAAS,CAAG,CACZC,2BAA2B,CAAE,+CADjB,CAEZC,8BAA8B,CAAE,4BAFpB,CAGZC,sBAAsB,CAAE,0CAHZ,CAIZC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QrB,KAAKqC,sBAAL,CAA4B2B,CAA5B,CAAyDC,CAAzD,EACA,KAAK5B,sBAAL,CAA4B6B,CAA5B,CAAoDC,CAApD,EACA,KAAKpB,sBAAL,CAA4BC,CAA5B,EACA,KAAKI,sBAAL,CAA4BJ,CAA5B,EAEArD,CAAS,CAACyE,WAAV,CAAsB,KAAK1C,OAAL,GAAeC,IAAf,CAAoB9B,CAAS,CAACK,WAA9B,CAAtB,CAAkE8C,CAAlE,CAAwEe,CAAxE,CAEH,CAfK,CAeJM,IAfI,CAeC,IAfD,CAXC,EA2BNR,IA3BM,CA2BD,UAAW,CAIbxE,CAAC,CAACiF,GAAF,CAAM,+BAAN,CAAuC,UAAW,CAC9CC,CAAC,CAACC,sBAAF,CAAyBC,sBAAzB,EACH,CAFD,CAIH,CAnCM,EAoCNC,IApCM,CAoCDpF,CAAY,CAACqF,SApCZ,CAqCV,CAtCD,CA8CAnE,CAAsB,CAACU,SAAvB,CAAiC0D,IAAjC,CAAwC,UAAW,CAC/CrF,CAAK,CAAC2B,SAAN,CAAgB0D,IAAhB,CAAqBlE,IAArB,CAA0B,IAA1B,EAEA,GAAI,CAAC,KAAKM,UAAV,CAAsB,CAClB,KAAKwC,QAAL,GACA,KAAKxC,UAAL,GACH,CACJ,CAPD,CAWA,GAAI,CAACpB,CAAL,CAAiB,CACbH,CAAa,CAACoF,QAAd,CACIrE,CAAsB,CAACS,IAD3B,CAEIT,CAFJ,CAGI,oCAHJ,EAMAZ,CAAU,GACb,CAED,MAAOY,CAAAA,CACV,CAnSK,CAAN","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 * Contain the logic for the add random question modal.\n *\n * @module mod_quiz/modal_add_random_question\n * @package mod_quiz\n * @copyright 2018 Ryan Wyllie <ryan@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/yui',\n 'core/notification',\n 'core/modal',\n 'core/modal_events',\n 'core/modal_registry',\n 'core/fragment',\n 'core/templates',\n],\nfunction(\n $,\n Y,\n Notification,\n Modal,\n ModalEvents,\n ModalRegistry,\n Fragment,\n Templates\n) {\n\n var registered = false;\n var SELECTORS = {\n EXISTING_CATEGORY_CONTAINER: '[data-region=\"existing-category-container\"]',\n EXISTING_CATEGORY_FORM_ELEMENT: '#id_existingcategoryheader',\n NEW_CATEGORY_CONTAINER: '[data-region=\"new-category-container\"]',\n NEW_CATEGORY_FORM_ELEMENT: '#id_newcategoryheader',\n TAB_CONTENT: '[data-region=\"tab-content\"]',\n ADD_ON_PAGE_FORM_ELEMENT: '[name=\"addonpage\"]',\n SUBMIT_BUTTON_ELEMENT: 'input[type=\"submit\"]',\n CANCEL_BUTTON_ELEMENT: 'input[type=\"submit\"][name=\"cancel\"]',\n FORM_HEADER: 'legend',\n BUTTON_CONTAINER: '.fitem'\n };\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var ModalAddRandomQuestion = function(root) {\n Modal.call(this, root);\n this.contextId = null;\n this.addOnPageId = null;\n this.category = null;\n this.returnUrl = null;\n this.cmid = null;\n this.loadedForm = false;\n };\n\n ModalAddRandomQuestion.TYPE = 'mod_quiz-quiz-add-random-question';\n ModalAddRandomQuestion.prototype = Object.create(Modal.prototype);\n ModalAddRandomQuestion.prototype.constructor = ModalAddRandomQuestion;\n\n /**\n * Save the Moodle context id that the question bank is being\n * rendered in.\n *\n * @method setContextId\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setContextId = function(id) {\n this.contextId = id;\n };\n\n /**\n * Retrieve the saved Moodle context id.\n *\n * @method getContextId\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getContextId = function() {\n return this.contextId;\n };\n\n /**\n * Set the id of the page that the question should be added to\n * when the user clicks the add to quiz link.\n *\n * @method setAddOnPageId\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setAddOnPageId = function(id) {\n this.addOnPageId = id;\n this.getBody().find(SELECTORS.ADD_ON_PAGE_FORM_ELEMENT).val(id);\n };\n\n /**\n * Returns the saved page id for the question to be added to.\n *\n * @method getAddOnPageId\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getAddOnPageId = function() {\n return this.addOnPageId;\n };\n\n /**\n * Set the category for this form. The category is a comma separated\n * category id and category context id.\n *\n * @method setCategory\n * @param {string} category\n */\n ModalAddRandomQuestion.prototype.setCategory = function(category) {\n this.category = category;\n };\n\n /**\n * Returns the saved category.\n *\n * @method getCategory\n * @return {string}\n */\n ModalAddRandomQuestion.prototype.getCategory = function() {\n return this.category;\n };\n\n /**\n * Set the return URL for the form.\n *\n * @method setReturnUrl\n * @param {string} url\n */\n ModalAddRandomQuestion.prototype.setReturnUrl = function(url) {\n this.returnUrl = url;\n };\n\n /**\n * Returns the return URL for the form.\n *\n * @method getReturnUrl\n * @return {string}\n */\n ModalAddRandomQuestion.prototype.getReturnUrl = function() {\n return this.returnUrl;\n };\n\n /**\n * Set the course module id for the form.\n *\n * @method setCMID\n * @param {int} id\n */\n ModalAddRandomQuestion.prototype.setCMID = function(id) {\n this.cmid = id;\n };\n\n /**\n * Returns the course module id for the form.\n *\n * @method getCMID\n * @return {int}\n */\n ModalAddRandomQuestion.prototype.getCMID = function() {\n return this.cmid;\n };\n\n /**\n * Moves a given form element inside (a child of) a given tab element.\n *\n * Hides the 'legend' (e.g. header) element of the form element because the\n * tab has the name.\n *\n * Moves the submit button into a footer element at the bottom of the form\n * element for styling purposes.\n *\n * @method moveFormElementIntoTab\n * @param {jquery} formElement The form element to move into the tab.\n * @param {jquey} tabElement The tab element for the form element to move into.\n */\n ModalAddRandomQuestion.prototype.moveFormElementIntoTab = function(formElement, tabElement) {\n var submitButtons = formElement.find(SELECTORS.SUBMIT_BUTTON_ELEMENT);\n var footer = $('<div class=\"modal-footer mt-1\" data-region=\"footer\"></div>');\n // Hide the header because the tabs show us which part of the form we're\n // looking at.\n formElement.find(SELECTORS.FORM_HEADER).addClass('hidden');\n // Move the element inside a tab.\n formElement.wrap(tabElement);\n // Remove the buttons container element.\n submitButtons.closest(SELECTORS.BUTTON_CONTAINER).remove();\n // Put the button inside a footer.\n submitButtons.appendTo(footer);\n // Add the footer to the end of the category form element.\n footer.appendTo(formElement);\n };\n\n /**\n * Empty the tab content container and move all tabs from the form into the\n * tab container element.\n *\n * @method moveTabsIntoTabContent\n * @param {jquery} form The form element.\n */\n ModalAddRandomQuestion.prototype.moveTabsIntoTabContent = function(form) {\n // Empty it to remove the loading icon.\n var tabContent = this.getBody().find(SELECTORS.TAB_CONTENT).empty();\n // Make sure all tabs are inside the tab content element.\n form.find('[role=\"tabpanel\"]').wrapAll(tabContent);\n };\n\n /**\n * Make sure all of the tabs have a cancel button in their fotter to sit along\n * side the submit button.\n *\n * @method moveCancelButtonToTabs\n * @param {jquey} form The form element.\n */\n ModalAddRandomQuestion.prototype.moveCancelButtonToTabs = function(form) {\n var cancelButton = form.find(SELECTORS.CANCEL_BUTTON_ELEMENT).addClass('ml-1');\n var tabFooters = form.find('[data-region=\"footer\"]');\n // Remove the buttons container element.\n cancelButton.closest(SELECTORS.BUTTON_CONTAINER).remove();\n cancelButton.clone().appendTo(tabFooters);\n };\n\n /**\n * Load the add random question form in a fragement and perform some transformation\n * on the HTML to convert it into tabs for rendering in the modal.\n *\n * @method loadForm\n * @return {promise} Resolved with form HTML and JS.\n */\n ModalAddRandomQuestion.prototype.loadForm = function() {\n return Fragment.loadFragment(\n 'mod_quiz',\n 'add_random_question_form',\n this.getContextId(),\n {\n addonpage: this.getAddOnPageId(),\n cat: this.getCategory(),\n returnurl: this.getReturnUrl(),\n cmid: this.getCMID()\n }\n )\n .then(function(html, js) {\n var form = $(html);\n var existingCategoryFormElement = form.find(SELECTORS.EXISTING_CATEGORY_FORM_ELEMENT);\n var existingCategoryTab = this.getBody().find(SELECTORS.EXISTING_CATEGORY_CONTAINER);\n var newCategoryFormElement = form.find(SELECTORS.NEW_CATEGORY_FORM_ELEMENT);\n var newCategoryTab = this.getBody().find(SELECTORS.NEW_CATEGORY_CONTAINER);\n\n // Transform the form into tabs for better rendering in the modal.\n this.moveFormElementIntoTab(existingCategoryFormElement, existingCategoryTab);\n this.moveFormElementIntoTab(newCategoryFormElement, newCategoryTab);\n this.moveTabsIntoTabContent(form);\n this.moveCancelButtonToTabs(form);\n\n Templates.replaceNode(this.getBody().find(SELECTORS.TAB_CONTENT), form, js);\n return;\n }.bind(this))\n .then(function() {\n // Make sure the form change checker is disabled otherwise it'll\n // stop the user from navigating away from the page once the modal\n // is hidden.\n Y.use('moodle-core-formchangechecker', function() {\n M.core_formchangechecker.reset_form_dirty_state();\n });\n return;\n })\n .fail(Notification.exception);\n };\n\n /**\n * Override the modal show function to load the form when this modal is first\n * shown.\n *\n * @method show\n */\n ModalAddRandomQuestion.prototype.show = function() {\n Modal.prototype.show.call(this);\n\n if (!this.loadedForm) {\n this.loadForm();\n this.loadedForm = true;\n }\n };\n\n // Automatically register with the modal registry the first time this module is\n // imported so that you can create modals of this type using the modal factory.\n if (!registered) {\n ModalRegistry.register(\n ModalAddRandomQuestion.TYPE,\n ModalAddRandomQuestion,\n 'mod_quiz/modal_add_random_question'\n );\n\n registered = true;\n }\n\n return ModalAddRandomQuestion;\n});\n"],"file":"modal_add_random_question.min.js"}