AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"question_slot.min.js","sources":["../src/question_slot.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 * Render the question slot template for each question in the quiz edit view.\n *\n * @module mod_quiz/question_slot\n * @copyright 2021 Catalyst IT Australia Pty Ltd\n * @author Guillermo Gomez Arias <guillerm
ogomez@catalyst-au.net>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Set the question version for the slot.\n *\n * @param {Number} slotId\n * @param {Number} newVersion\n * @return {Array} The modified question version\n */\nconst setQuestionVersion = (slotId, newVersion) => fetchMany([{\n methodname: 'mod_quiz_set_question_version',\n args: {\n slotid: slotId,\n newversion: newVersion,\n }\n}])[0];\n\n/**\n * Replace the container with a new version.\n */\nconst registerEventListeners = () => {\n document.addEventListener('change', e => {\n if (!e.target.matches('[data-action=\"mod_quiz-select_slot\"][data-slot-id]')) {\n return;\n }\n\n const slotId = e.target.dataset.slotId;\n const newVersion = parseInt(e.target.value);\n\n setQuestionVersion(slotId, newVersion)\n .then(() => {\n
location.reload();\n return;\n })\n .catch(Notification.exception);\n });\n};\n\n/** @property {Boolean} eventsRegistered If the event has been registered or not */\nlet eventsRegistered = false;\n\n/**\n * Entrypoint of the js.\n */\nexport const init = () => {\n if (eventsRegistered) {\n return;\n }\n\n registerEventListeners();\n};\n"],"names":["registerEventListeners","document","addEventListener","e","target","matches","slotId","newVersion","methodname","args","slotid","newversion","setQuestionVersion","dataset","parseInt","value","then","location","reload","catch","Notification","exception"],"mappings":";;;;;;;;4JA6CMA,uBAAyB,KAC3BC,SAASC,iBAAiB,UAAUC,QAC3BA,EAAEC,OAAOC,QAAQ,6DAbH,EAACC,OAAQC,cAAe,cAAU,CAAC,CAC1DC,WAAY,gCACZC,KAAM,CACFC,OAAQJ,OACRK,WAAYJ,eAEhB,GAcIK,CAHeT,EAAEC,OAAOS,QAAQP,OACbQ,SAASX,EAAEC,OAAOW,QAGhCC,MAAK,KACFC,SAASC,YAGZC,MAAMC,sBAAaC,6BAUZ,KAKhBrB"}