ai/amd/src/repository.js

  1. // This file is part of Moodle - http://moodle.org/
  2. //
  3. // Moodle is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // Moodle is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  15. /**
  16. * AI Subsystem policy functions.
  17. *
  18. * @module core_ai/repository
  19. * @copyright Matt Porritt <matt.porritt@moodle.com>
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  21. * @since 4.5
  22. */
  23. import Ajax from 'core/ajax';
  24. /**
  25. * Get the policy status for a user.
  26. *
  27. * @param {Number} userid The user ID.
  28. * @return {Promise<Object>} The policy status.
  29. */
  30. export const getPolicyStatus = (userid) => Ajax.call([{
  31. methodname: 'core_ai_get_policy_status',
  32. args: {userid},
  33. }])[0];
  34. /**
  35. * Set the policy status for a user.
  36. *
  37. * @param {Number} contextId The context ID.
  38. * @return {Promise<Object>} Promise resolved with the policy set status.
  39. */
  40. export const setPolicyStatus = (contextId) => Ajax.call([{
  41. methodname: 'core_ai_set_policy_status',
  42. args: {contextid: contextId},
  43. }])[0];