%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_quiz_question_bank.min.js.map

{"version":3,"file":"modal_quiz_question_bank.min.js","sources":["../src/modal_quiz_question_bank.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 question bank modal.\n *\n * @module     mod_quiz/modal_quiz_question_bank\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_form/changechecker',\n],\nfunction(\n    $,\n    Notification,\n    Modal,\n    ModalEvents,\n    ModalRegistry,\n    Fragment,\n    FormChangeChecker,\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#questionsubmit',\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 stop the user from navigating away from the\n            // page once the modal is hidden.\n            FormChangeChecker.disableAllChecks();\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"],"names":["define","$","Notification","Modal","ModalEvents","ModalRegistry","Fragment","FormChangeChecker","registered","SELECTORS","ModalQuizQuestionBank","root","call","this","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","target","closest","serialize","registerDisplayOptionListeners","getModal","on","bind","registerEventListeners","formElement","currentTarget","appendTo","length","prop","getRoot","bodyRendered","disableAllChecks","register"],"mappings":";;;;;;;AAsBAA,2CAAO,CACH,SACA,oBACA,aACA,oBACA,sBACA,gBACA,4BAEJ,SACIC,EACAC,aACAC,MACAC,YACAC,cACAC,SACAC,uBAGIC,YAAa,EACbC,gCACuB,qBADvBA,iBAEQ,UAFRA,4BAGmB,mBAHnBA,yBAIgB,kBAJhBA,0BAKiB,kBALjBA,6BAMoB,sBAQpBC,sBAAwB,SAASC,MACjCR,MAAMS,KAAKC,KAAMF,WAEZG,UAAY,UACZC,YAAc,aAGvBL,sBAAsBM,KAAO,+BAC7BN,sBAAsBO,UAAYC,OAAOC,OAAOhB,MAAMc,YACtBG,YAAcV,sBAS9CA,sBAAsBO,UAAUI,aAAe,SAASC,SAC/CR,UAAY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