Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/mod/quiz/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/mod/quiz/amd/build/modal_quiz_question_bank.min.js.map

{"version":3,"sources":["../src/modal_quiz_question_bank.js"],"names":["define","$","Y","Notification","Modal","ModalEvents","ModalRegistry","Fragment","registered","SELECTORS","ADD_TO_QUIZ_CONTAINER","ANCHOR","PREVIEW_CONTAINER","SEARCH_OPTIONS","DISPLAY_OPTIONS","ADD_QUESTIONS_FORM","ModalQuizQuestionBank","root","call","contextId","addOnPageId","TYPE","prototype","Object","create","constructor","setContextId","id","getContextId","setAddOnPageId","getAddOnPageId","show","reloadBodyContent","window","location","search","queryString","promise","loadFragment","querystring","fail","exception","setBody","handleAddToQuizEvent","e","anchorElement","href","attr","handlePreviewContainerEvent","openpopup","url","name","options","join","handleDisplayOptionFormEvent","stopPropagation","preventDefault","form","target","closest","serialize","registerDisplayOptionListeners","getModal","on","modifiedElement","bind","registerEventListeners","formElement","currentTarget","appendTo","length","prop","getRoot","bodyRendered","use","M","core_formchangechecker","reset_form_dirty_state","register"],"mappings":"AAuBAA,OAAM,qCAAC,CACH,QADG,CAEH,UAFG,CAGH,mBAHG,CAIH,YAJG,CAKH,mBALG,CAMH,qBANG,CAOH,eAPG,CAAD,CASN,SACIC,CADJ,CAEIC,CAFJ,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAMIC,CANJ,CAOIC,CAPJ,CAQE,IAEMC,CAAAA,CAAU,GAFhB,CAGMC,CAAS,CAAG,CACZC,qBAAqB,CAAE,oBADX,CAEZC,MAAM,CAAE,SAFI,CAGZC,iBAAiB,CAAE,kBAHP,CAIZC,cAAc,CAAE,iBAJJ,CAKZC,eAAe,CAAE,iBALL,CAMZC,kBAAkB,CAAE,2BANR,CAHlB,CAiBMC,CAAqB,CAAG,SAASC,CAAT,CAAe,CACvCb,CAAK,CAACc,IAAN,CAAW,IAAX,CAAiBD,CAAjB,EAEA,KAAK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AC/D,KAAK3B,oBAAL,CAA0BC,CAA1B,CAA6BC,CAA7B,EACA,MACH,CAGD,GAAIA,CAAa,CAACc,OAAd,CAAsBlD,CAAS,CAACG,iBAAhC,EAAmD0D,MAAvD,CAA+D,CAC3D,KAAKtB,2BAAL,CAAiCJ,CAAjC,CAAoCC,CAApC,EACA,MACH,CAID,GAAIA,CAAa,CAACc,OAAd,CAAsBlD,CAAS,CAACI,cAAhC,EAAgDyD,MAApD,CAA4D,CACxD,MACH,CAGD1B,CAAC,CAACY,cAAF,GACA,KAAKxB,iBAAL,CAAuBa,CAAa,CAAC0B,IAAd,CAAmB,QAAnB,CAAvB,CACH,CAxB6C,CAwB5CN,IAxB4C,CAwBvC,IAxBuC,CAA9C,EA2BA,KAAKO,OAAL,GAAeT,EAAf,CAAkB1D,CAAW,CAACoE,YAA9B,CAA4C,UAAW,CAInDvE,CAAC,CAACwE,GAAF,CAAM,+BAAN,CAAuC,UAAW,CAC9CC,CAAC,CAACC,sBAAF,CAAyBC,sBAAzB,EACH,CAFD,CAGH,CAPD,CAQH,CAtDD,CA0DA,GAAI,CAACrE,CAAL,CAAiB,CACbF,CAAa,CAACwE,QAAd,CACI9D,CAAqB,CAACK,IAD1B,CAEIL,CAFJ,CAGI,YAHJ,EAMAR,CAAU,GACb,CAED,MAAOQ,CAAAA,CACV,CA5SK,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 question bank modal.\n *\n * @module     mod_quiz/modal_quiz_question_bank\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],\nfunction(\n    $,\n    Y,\n    Notification,\n    Modal,\n    ModalEvents,\n    ModalRegistry,\n    Fragment\n) {\n\n    var registered = false;\n    var SELECTORS = {\n        ADD_TO_QUIZ_CONTAINER: 'td.addtoquizaction',\n        ANCHOR: 'a[href]',\n        PREVIEW_CONTAINER: 'td.previewaction',\n        SEARCH_OPTIONS: '#advancedsearch',\n        DISPLAY_OPTIONS: '#displayoptions',\n        ADD_QUESTIONS_FORM: 'form[action=\"edit.php\"]',\n    };\n\n    /**\n     * Constructor for the Modal.\n     *\n     * @param {object} root The root jQuery element for the modal\n     */\n    var ModalQuizQuestionBank = function(root) {\n        Modal.call(this, root);\n\n        this.contextId = null;\n        this.addOnPageId = null;\n    };\n\n    ModalQuizQuestionBank.TYPE = 'mod_quiz-quiz-question-bank';\n    ModalQuizQuestionBank.prototype = Object.create(Modal.prototype);\n    ModalQuizQuestionBank.prototype.constructor = ModalQuizQuestionBank;\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    ModalQuizQuestionBank.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    ModalQuizQuestionBank.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    ModalQuizQuestionBank.prototype.setAddOnPageId = function(id) {\n        this.addOnPageId = id;\n    };\n\n    /**\n     * Returns the saved page id for the question to be added it.\n     *\n     * @method getAddOnPageId\n     * @return {int}\n     */\n    ModalQuizQuestionBank.prototype.getAddOnPageId = function() {\n        return this.addOnPageId;\n    };\n\n    /**\n     * Override the parent show function.\n     *\n     * Reload the body contents when the modal is shown. The current\n     * window URL is used to inform the new content that should be\n     * displayed.\n     *\n     * @method show\n     * @return {void}\n     */\n    ModalQuizQuestionBank.prototype.show = function() {\n        this.reloadBodyContent(window.location.search);\n        return Modal.prototype.show.call(this);\n    };\n\n    /**\n     * Replaces the current body contents with a new version of the question\n     * bank.\n     *\n     * The contents of the question bank are generated using the provided\n     * query string.\n     *\n     * @method reloadBodyContent\n     * @param {string} queryString URL encoded string.\n     */\n    ModalQuizQuestionBank.prototype.reloadBodyContent = function(queryString) {\n        // Load the question bank fragment to be displayed in the modal.\n        var promise = Fragment.loadFragment(\n            'mod_quiz',\n            'quiz_question_bank',\n            this.getContextId(),\n            {\n                querystring: queryString\n            }\n        ).fail(Notification.exception);\n\n        this.setBody(promise);\n    };\n\n    /**\n     * Update the URL of the anchor element that the user clicked on to make\n     * sure that the question is added to the correct page.\n     *\n     * @method handleAddToQuizEvent\n     * @param {event} e A JavaScript event\n     * @param {object} anchorElement The anchor element that was triggered\n     */\n    ModalQuizQuestionBank.prototype.handleAddToQuizEvent = function(e, anchorElement) {\n        // If the user clicks the plus icon to add the question to the page\n        // directly then we need to intercept the click in order to adjust the\n        // href and include the correct add on page id before the page is\n        // redirected.\n        var href = anchorElement.attr('href') + '&addonpage=' + this.getAddOnPageId();\n        anchorElement.attr('href', href);\n    };\n\n    /**\n     * Open a popup window to show the preview of the question.\n     *\n     * @method handlePreviewContainerEvent\n     * @param {event} e A JavaScript event\n     * @param {object} anchorElement The anchor element that was triggered\n     */\n    ModalQuizQuestionBank.prototype.handlePreviewContainerEvent = function(e, anchorElement) {\n        var popupOptions = [\n            'height=600',\n            'width=800',\n            'top=0',\n            'left=0',\n            'menubar=0',\n            'location=0',\n            'scrollbars',\n            'resizable',\n            'toolbar',\n            'status',\n            'directories=0',\n            'fullscreen=0',\n            'dependent'\n        ];\n        window.openpopup(e, {\n            url: anchorElement.attr('href'),\n            name: 'questionpreview',\n            options: popupOptions.join(',')\n        });\n    };\n\n    /**\n     * Reload the modal body with the new display options the user has selected.\n     *\n     * A query string is built using the form elements to be used to generate the\n     * new body content.\n     *\n     * @method handleDisplayOptionFormEvent\n     * @param {event} e A JavaScript event\n     */\n    ModalQuizQuestionBank.prototype.handleDisplayOptionFormEvent = function(e) {\n        // Stop propagation to prevent other wild event handlers\n        // from submitting the form on change.\n        e.stopPropagation();\n        e.preventDefault();\n\n        var form = $(e.target).closest(SELECTORS.DISPLAY_OPTIONS);\n        var queryString = '?' + form.serialize();\n        this.reloadBodyContent(queryString);\n    };\n\n    /**\n     * Listen for changes to the display options form.\n     *\n     * This handles the user changing:\n     *      - The quiz category select box\n     *      - The tags to filter by\n     *      - Show/hide questions from sub categories\n     *      - Show/hide old questions\n     *\n     * @method registerDisplayOptionListeners\n     */\n    ModalQuizQuestionBank.prototype.registerDisplayOptionListeners = function() {\n        // Listen for changes to the display options form.\n        this.getModal().on('change', SELECTORS.DISPLAY_OPTIONS, function(e) {\n            // Get the element that was changed.\n            var modifiedElement = $(e.target);\n            if (modifiedElement.attr('aria-autocomplete')) {\n                // If the element that was change is the autocomplete\n                // input then we should ignore it because that is for\n                // display purposes only.\n                return;\n            }\n\n            this.handleDisplayOptionFormEvent(e);\n        }.bind(this));\n\n        // Listen for the display options form submission because the tags\n        // filter will submit the form when it is changed.\n        this.getModal().on('submit', SELECTORS.DISPLAY_OPTIONS, function(e) {\n            this.handleDisplayOptionFormEvent(e);\n        }.bind(this));\n    };\n\n    /**\n     * Set up all of the event handling for the modal.\n     *\n     * @method registerEventListeners\n     */\n    ModalQuizQuestionBank.prototype.registerEventListeners = function() {\n        // Apply parent event listeners.\n        Modal.prototype.registerEventListeners.call(this);\n\n        // Set up the event handlers for all of the display options.\n        this.registerDisplayOptionListeners();\n\n        this.getModal().on('submit', SELECTORS.ADD_QUESTIONS_FORM, function(e) {\n            // If the user clicks on the \"Add selected questions to the quiz\" button to add some questions to the page\n            // then we need to intercept the submit in order to include the correct \"add on page id\" before the form is\n            // submitted.\n            var formElement = $(e.currentTarget);\n\n            $('<input />').attr('type', 'hidden')\n                .attr('name', \"addonpage\")\n                .attr('value', this.getAddOnPageId())\n                .appendTo(formElement);\n        }.bind(this));\n\n        this.getModal().on('click', SELECTORS.ANCHOR, function(e) {\n            var anchorElement = $(e.currentTarget);\n\n            // If the anchor element was the add to quiz link.\n            if (anchorElement.closest(SELECTORS.ADD_TO_QUIZ_CONTAINER).length) {\n                this.handleAddToQuizEvent(e, anchorElement);\n                return;\n            }\n\n            // If the anchor element was a preview question link.\n            if (anchorElement.closest(SELECTORS.PREVIEW_CONTAINER).length) {\n                this.handlePreviewContainerEvent(e, anchorElement);\n                return;\n            }\n\n            // Click on expand/collaspse search-options. Has its own handler.\n            // We should not interfere.\n            if (anchorElement.closest(SELECTORS.SEARCH_OPTIONS).length) {\n                return;\n            }\n\n            // Anything else means reload the pop-up contents.\n            e.preventDefault();\n            this.reloadBodyContent(anchorElement.prop('search'));\n        }.bind(this));\n\n        // Disable the form change checker when the body is rendered.\n        this.getRoot().on(ModalEvents.bodyRendered, 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        });\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            ModalQuizQuestionBank.TYPE,\n            ModalQuizQuestionBank,\n            'core/modal'\n        );\n\n        registered = true;\n    }\n\n    return ModalQuizQuestionBank;\n});\n"],"file":"modal_quiz_question_bank.min.js"}