Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"answers.min.js","sources":["../src/answers.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 * Handles events related to the multiple-choice question type answers.\n *\n * @module     qtype_multichoice/answers\n * @copyright  2020 Jun Pataleta <jun@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Selectors for this module.\n *\n * @type {{ANSWER_LABEL: string}}\n */\nconst SELECTORS = {\n    ANSWER_LABEL: '[data-region=answer-label]',\n};\n\n/**\n * Init method.\n *\n * @param {string} rootId The ID of the question container.\n */\nconst init = (rootId) => {\n    const root = document.getElementById(rootId);\n\n    // Add click event handlers for the divs containing the answer since these cannot be enclosed in a label element.\n    const answerLabels = root.querySelectorAll(SELECTORS.ANSWER_LABEL);\n    answerLabels.forEach((answerLabel) => {\n        answerLabel.addEventListener('click', (e) => {\n            const labelId = e.currentTarget.id;\n            // Fetch the answer this label is assigned to.\n            const linkedOption = root.querySelector(`[aria-labelledby=\"${labelId}\"]`);\n            // Trigger the click event.\n            linkedOption.click();\n        });\n    });\n};\n\nexport default {\n    init: init\n};\n"],"names":["SELECTORS","init","rootId","root","document","getElementById","querySelectorAll","forEach","answerLabel","addEventListener","e","labelId","currentTarget","id","querySelector","click"],"mappings":";;;;;;;;MA4BMA,uBACY,0CAwBH,CACXC,KAjBUC,eACJC,KAAOC,SAASC,eAAeH,QAGhBC,KAAKG,iBAAiBN,wBAC9BO,SAASC,cAClBA,YAAYC,iBAAiB,SAAUC,UAC7BC,QAAUD,EAAEE,cAAcC,GAEXV,KAAKW,0CAAmCH,eAEhDI"}