Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"mod_form.min.js","sources":["../src/mod_form.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 * Event handlers for the mod_lti mod_form.\n *\n * @module      mod_lti/mod_form\n * @copyright   2023 Jake Dallimore <jrhdallimore@gmail.com>\n * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n\"use strict\";\n\nimport ContentItem from 'mod_lti/contentitem';\n\n/**\n * Initialise module.\n *\n * @param {int} courseId the course id.\n */\nconst init = (courseId) => {\n    const contentItemButton = document.querySelector('[name=\"selectcontent\"]');\n\n    if (!contentItemButton) {\n        return;\n    }\n\n    contentItemButton.addEventListener('click', () => {\n        const contentItemUrl = contentItemButton.getAttribute('data-contentitemurl');\n        const contentItemId = document.querySelector('#hidden_typeid').value;\n        if (contentItemId) {\n            const title = document.querySelector('#id_name').value.trim();\n            const text = document.querySelector('#id_introeditor').value.trim();\n            const postData = {\n                id: contentItemId,\n                course: courseId,\n                title: title,\n                text: text\n            };\n\n            // The callback below is called after the content item has been returned and processed.\n            ContentItem.init(contentItemUrl, postData, (returnData) => {\n                if (!returnData.multiple) {\n                    // The state of the grade checkbox has already been set by processContentItemReturnData() but that\n                    // hasn't fired the click/change event required by formslib to show/hide the dependent grade fields.\n                    // Fire it now.\n                    const allowGrades = document.querySelector('#id_instructorchoiceacceptgrades');\n                    let allowGradesChangeEvent = new Event('change');\n                    allowGrades.dispatchEvent(allowGradesChangeEvent);\n\n                    // If the tool is set to accept grades, make sure \"Point\" is selected.\n                    if (allowGrades.checked) {\n                        const gradeType = document.querySelector('#id_grade_modgrade_type');\n                        gradeType.value = \"point\";\n                        let gradeTypeChangeEvent = new Event('change');\n                        gradeType.dispatchEvent(gradeTypeChangeEvent);\n                    }\n                }\n            });\n        }\n    });\n};\n\nexport default {\n    init: init\n};\n"],"names":["init","courseId","contentItemButton","document","querySelector","addEventListener","contentItemUrl","getAttribute","contentItemId","value","title","trim","text","postData","id","course","returnData","multiple","allowGrades","allowGradesChangeEvent","Event","dispatchEvent","checked","gradeType","gradeTypeChangeEvent"],"mappings":"oQA2Ee,CACXA,KA5CUC,iBACJC,kBAAoBC,SAASC,cAAc,0BAE5CF,mBAILA,kBAAkBG,iBAAiB,SAAS,WAClCC,eAAiBJ,kBAAkBK,aAAa,uBAChDC,cAAgBL,SAASC,cAAc,kBAAkBK,SAC3DD,cAAe,OACTE,MAAQP,SAASC,cAAc,YAAYK,MAAME,OACjDC,KAAOT,SAASC,cAAc,mBAAmBK,MAAME,OACvDE,SAAW,CACbC,GAAIN,cACJO,OAAQd,SACRS,MAAOA,MACPE,KAAMA,2BAIEZ,KAAKM,eAAgBO,UAAWG,iBACnCA,WAAWC,SAAU,OAIhBC,YAAcf,SAASC,cAAc,wCACvCe,uBAAyB,IAAIC,MAAM,aACvCF,YAAYG,cAAcF,wBAGtBD,YAAYI,QAAS,OACfC,UAAYpB,SAASC,cAAc,2BACzCmB,UAAUd,MAAQ,YACde,qBAAuB,IAAIJ,MAAM,UACrCG,UAAUF,cAAcG"}