Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 1... Línea -...
1
{"version":3,"file":"add_question_modal.min.js","sources":["../src/add_question_modal.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/add_question_modal\n * @copyright  2023 Andrew Lyons <andrew@nicols.co.uk>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\n\nexport default class AddQuestionModal extends Modal {\n    configure(modalConfig) {\n        // Add question modals are always large.\n        modalConfig.large = true;\n\n        // Always show on creation.\n        modalConfig.show = true;\n        modalConfig.removeOnClose = true;\n\n        // Apply question modal configuration.\n        this.setContextId(modalConfig.contextId);\n        this.setAddOnPageId(modalConfig.addOnPage);\n\n        // Apply standard configuration.\n        super.configure(modalConfig);\n    }\n\n    constructor(root) {\n        super(root);\n\n        this.contextId = null;\n        this.addOnPageId = null;\n    }\n\n    /**\n     * Save the Moodle context id that the question bank is being\n     * rendered in.\n     *\n     * @method setContextId\n     * @param {Number} id\n     */\n    setContextId(id) {\n        this.contextId = id;\n    }\n\n    /**\n     * Retrieve the saved Moodle context id.\n     *\n     * @method getContextId\n     * @return {Number}\n     */\n    getContextId() {\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 {Number} id\n     */\n    setAddOnPageId(id) {\n        this.addOnPageId = id;\n    }\n\n    /**\n     * Returns the saved page id for the question to be added to.\n     *\n     * @method getAddOnPageId\n     * @return {Number}\n     */\n    getAddOnPageId() {\n        return this.addOnPageId;\n    }\n\n}\n"],"names":["AddQuestionModal","Modal","configure","modalConfig","large","show","removeOnClose","setContextId","contextId","setAddOnPageId","addOnPage","constructor","root","addOnPageId","id","getContextId","this","getAddOnPageId"],"mappings":";;;;;;;iJAyBqBA,yBAAyBC,eAC1CC,UAAUC,aAENA,YAAYC,OAAQ,EAGpBD,YAAYE,MAAO,EACnBF,YAAYG,eAAgB,OAGvBC,aAAaJ,YAAYK,gBACzBC,eAAeN,YAAYO,iBAG1BR,UAAUC,aAGpBQ,YAAYC,YACFA,WAEDJ,UAAY,UACZK,YAAc,KAUvBN,aAAaO,SACJN,UAAYM,GASrBC,sBACWC,KAAKR,UAUhBC,eAAeK,SACND,YAAcC,GASvBG,wBACWD,KAAKH"}
-
 
2
1
{"version":3,"file":"add_question_modal.min.js","sources":["../src/add_question_modal.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/add_question_modal\n * @copyright  2023 Andrew Lyons <andrew@nicols.co.uk>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Modal from 'core/modal';\nimport * as Fragment from 'core/fragment';\nimport {getString} from 'core/str';\nimport AutoComplete from 'core/form-autocomplete';\n\nexport default class AddQuestionModal extends Modal {\n    configure(modalConfig) {\n        // Add question modals are always large.\n        modalConfig.large = true;\n\n        // Always show on creation.\n        modalConfig.show = true;\n        modalConfig.removeOnClose = true;\n\n        // Apply question modal configuration.\n        this.setContextId(modalConfig.contextId);\n        this.setAddOnPageId(modalConfig.addOnPage);\n\n        // Store the quiz module id for when we need to POST to the quiz.\n        // This is because the URL cmid param will change during filter operations as we will be in another bank context.\n        this.quizCmId = modalConfig.quizCmId;\n        this.bankCmId = modalConfig.bankCmId;\n\n        // Store the original title of the modal, so we can revert back to it once we have switched to another bank.\n        this.originalTitle = modalConfig.title;\n\n        // Apply standard configuration.\n        super.configure(modalConfig);\n    }\n\n    constructor(root) {\n        super(root);\n\n        this.contextId = null;\n        this.addOnPageId = null;\n    }\n\n    /**\n     * Save the Moodle context id that the question bank is being\n     * rendered in.\n     *\n     * @method setContextId\n     * @param {Number} id\n     */\n    setContextId(id) {\n        this.contextId = id;\n    }\n\n    /**\n     * Retrieve the saved Moodle context id.\n     *\n     * @method getContextId\n     * @return {Number}\n     */\n    getContextId() {\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 {Number} id\n     */\n    setAddOnPageId(id) {\n        this.addOnPageId = id;\n    }\n\n    /**\n     * Returns the saved page id for the question to be added to.\n     *\n     * @method getAddOnPageId\n     * @return {Number}\n     */\n    getAddOnPageId() {\n        return this.addOnPageId;\n    }\n\n    /**\n     * Update the modal with a list of banks to switch to and enhance the standard selects to Autocomplete fields.\n     *\n     * @param {String} Selector for the original select element.\n     * @return {Promise} Modal.\n     */\n    async handleSwitchBankContentReload(Selector) {\n        this.setTitle(getString('selectquestionbank', 'mod_quiz'));\n\n        // Create a 'Go back' button and set it in the footer.\n        const el = document.createElement('button');\n        el.classList.add('btn', 'btn-primary');\n        el.textContent = await getString('gobacktoquiz', 'mod_quiz');\n        el.setAttribute('data-action', 'go-back');\n        el.setAttribute('value', this.bankCmId);\n        this.setFooter(el);\n\n        this.setBody(\n            Fragment.loadFragment(\n                'mod_quiz',\n                'switch_question_bank',\n                this.getContextId(),\n                {\n                    'quizcmid': this.quizCmId,\n                    'bankcmid': this.bankCmId,\n                })\n        );\n        const placeholder = await getString('searchbyname', 'mod_quiz');\n        await this.getBodyPromise();\n        await AutoComplete.enhance(\n            Selector,\n            false,\n            'core_question/question_banks_datasource',\n            placeholder,\n            false,\n            true,\n            '',\n            true\n        );\n\n        // Hide the selection element as we don't need it.\n        document.querySelector('.search-banks .form-autocomplete-selection')?.classList.add('d-none');\n\n        return this;\n    }\n}\n"],"names":["AddQuestionModal","Modal","configure","modalConfig","large","show","removeOnClose","setContextId","contextId","setAddOnPageId","addOnPage","quizCmId","bankCmId","originalTitle","title","constructor","root","addOnPageId","id","getContextId","this","getAddOnPageId","Selector","setTitle","el","document","createElement","classList","add","textContent","setAttribute","setFooter","setBody","Fragment","loadFragment","placeholder","getBodyPromise","AutoComplete","enhance","querySelector"],"mappings":";;;;;;;61BA4BqBA,yBAAyBC,eAC1CC,UAAUC,aAENA,YAAYC,OAAQ,EAGpBD,YAAYE,MAAO,EACnBF,YAAYG,eAAgB,OAGvBC,aAAaJ,YAAYK,gBACzBC,eAAeN,YAAYO,gBAI3BC,SAAWR,YAAYQ,cACvBC,SAAWT,YAAYS,cAGvBC,cAAgBV,YAAYW,YAG3BZ,UAAUC,aAGpBY,YAAYC,YACFA,WAEDR,UAAY,UACZS,YAAc,KAUvBV,aAAaW,SACJV,UAAYU,GASrBC,sBACWC,KAAKZ,UAUhBC,eAAeS,SACND,YAAcC,GASvBG,wBACWD,KAAKH,gDASoBK,yCAC3BC,UAAS,kBAAU,qBAAsB,mBAGxCC,GAAKC,SAASC,cAAc,UAClCF,GAAGG,UAAUC,IAAI,MAAO,eACxBJ,GAAGK,kBAAoB,kBAAU,eAAgB,YACjDL,GAAGM,aAAa,cAAe,WAC/BN,GAAGM,aAAa,QAASV,KAAKR,eACzBmB,UAAUP,SAEVQ,QACDC,SAASC,aACL,WACA,uBACAd,KAAKD,eACL,UACgBC,KAAKT,kBACLS,KAAKR,kBAGvBuB,kBAAoB,kBAAU,eAAgB,yBAC9Cf,KAAKgB,uBACLC,0BAAaC,QACfhB,UACA,EACA,0CACAa,aACA,GACA,EACA,IACA,iCAIJV,SAASc,cAAc,sGAA+CZ,UAAUC,IAAI,UAE7ER"}
-
 
2
3
3