%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/vacivi36/ava/mod/quiz/amd/build/
Upload File :
Create Path :
Current File : /home/vacivi36/ava/mod/quiz/amd/build/modal_add_random_question.min.js.map

{"version":3,"file":"modal_add_random_question.min.js","sources":["../src/modal_add_random_question.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 * Contain the logic for the add random question modal.\n *\n * @module     mod_quiz/modal_add_random_question\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/notification',\n    'core/modal',\n    'core/modal_events',\n    'core/modal_registry',\n    'core/fragment',\n    'core/templates',\n    'core_form/changechecker',\n],\nfunction(\n    $,\n    Notification,\n    Modal,\n    ModalEvents,\n    ModalRegistry,\n    Fragment,\n    Templates,\n    FormChangeChecker,\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 stop the user from navigating away from the\n            // page once the modal is hidden.\n            FormChangeChecker.disableAllChecks();\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"],"names":["define","$","Notification","Modal","ModalEvents","ModalRegistry","Fragment","Templates","FormChangeChecker","registered","SELECTORS","ModalAddRandomQuestion","root","call","this","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","disableAllChecks","fail","exception","show","register"],"mappings":";;;;;;;AAsBAA,4CAAO,CACH,SACA,oBACA,aACA,oBACA,sBACA,gBACA,iBACA,4BAEJ,SACIC,EACAC,aACAC,MACAC,YACAC,cACAC,SACAC,UACAC,uBAGIC,YAAa,EACbC,sCAC6B,8CAD7BA,yCAEgC,6BAFhCA,iCAGwB,yCAHxBA,oCAI2B,wBAJ3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