{"version":3,"file":"attempt_answers_distribution_chart_manager.min.js","sources":["../src/attempt_answers_distribution_chart_manager.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 * Module to manage appearance of the answers distribution chart.\n *\n * @module mod_adaptivequiz/attempt_answers_distribution_chart_manager\n * @copyright 2024 Vitaly Potenko <potenkov@gmail.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Ajax from 'core/ajax';\nimport Notification from 'core/notification';\n\n/**\n * Entry point of the module.\n *\n * @param {Object} chartOutput An instance of Output.\n * @param {Object} chartBar An instance of Bar.\n * @param {Number} userId Current user to set the preferences for.\n * @param {Number} adaptiveQuizId Adaptive quiz instance to set the preferences for.\n */\nexport const init = (chartOutput, chartBar, userId, adaptiveQuizId) => {\n let stackedFlagControl = document.querySelector('[data-action=\"set-answers-distribution-chart-stacked\"]');\n\n stackedFlagControl.addEventListener('change', (e) => {\n const setStacked = e.target.checked;\n\n chartBar.setStacked(setStacked);\n chartOutput.update();\n\n Ajax.call([{\n methodname: 'core_user_set_user_preferences',\n args: {\n preferences: [{\n name: `mod_adaptivequiz_answers_distribution_chart_settings_${adaptiveQuizId}`,\n value: JSON.stringify({\n showstacked: setStacked,\n }),\n userid: userId,\n }]\n }\n }])[0].catch(Notification.exception);\n });\n};\n"],"names":["chartOutput","chartBar","userId","adaptiveQuizId","document","querySelector","addEventListener","e","setStacked","target","checked","update","call","methodname","args","preferences","name","value","JSON","stringify","showstacked","userid","catch","Notification","exception"],"mappings":";;;;;;;wLAkCoB,CAACA,YAAaC,SAAUC,OAAQC,kBACvBC,SAASC,cAAc,0DAE7BC,iBAAiB,UAAWC,UACrCC,WAAaD,EAAEE,OAAOC,QAE5BT,SAASO,WAAWA,YACpBR,YAAYW,uBAEPC,KAAK,CAAC,CACPC,WAAY,iCACZC,KAAM,CACFC,YAAa,CAAC,CACVC,oEAA8Db,gBAC9Dc,MAAOC,KAAKC,UAAU,CAClBC,YAAaZ,aAEjBa,OAAQnB,aAGhB,GAAGoB,MAAMC,sBAAaC"}