1441 |
ariadna |
1 |
{"version":3,"file":"policy.min.js","sources":["../src/policy.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\nimport {getPolicyStatus, setPolicyStatus} from \"./repository\";\n\n/**\n * The Javascript module to handle the policy acceptance.\n *\n * @module core_ai/policy\n * @copyright 2024 Andrew Lyons <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class {\n static #policyAcceptedFor = {};\n\n static preconfigurePolicyState(userid, state) {\n if (!this.#policyAcceptedFor.hasOwnProperty(userid)) {\n this.#policyAcceptedFor[userid] = state;\n }\n }\n\n /**\n * Get the policy status for a user.\n *\n * @param {Number} userid The user ID.\n * @return {Promise<Object>} The policy status.\n */\n static async getPolicyStatus(userid) {\n if (this.#policyAcceptedFor[userid]) {\n return this.#policyAcceptedFor[userid];\n }\n\n const accepted = await getPolicyStatus(userid);\n\n this.#policyAcceptedFor[userid] = accepted.status;\n\n return accepted.status;\n }\n\n static acceptPolicy() {\n this.#policyAcceptedFor[M.cfg.userId] = true;\n\n return setPolicyStatus(M.cfg.contextid);\n }\n}\n"],"names":["userid","state","_classStaticPrivateFieldSpecGet","hasOwnProperty","accepted","status","M","cfg","userId","contextid"],"mappings":";;;;;;;uJA2BmCA,OAAQC,OAC9BC,gEAAwBC,eAAeH,0EAChBA,QAAUC,oCAUbD,WACrBE,gEAAwBF,eACjBE,gEAAwBF,cAG7BI,eAAiB,+BAAgBJ,+EAEfA,QAAUI,SAASC,OAEpCD,SAASC,oGAIQC,EAAEC,IAAIC,SAAU,GAEjC,+BAAgBF,EAAEC,IAAIE,8EA7BL"}
|