mod/lti/amd/src/external_registration_return.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. * Handles the return params from the external registration page after it
  17. * redirects back to Moodle.
  18. *
  19. * See also: mod/lti/externalregistrationreturn.php
  20. *
  21. * @module mod_lti/external_registration_return
  22. * @copyright 2015 Ryan Wyllie <ryan@moodle.com>
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24. * @since 3.1
  25. */
  26. define([], function() {
  27. return {
  28. /**
  29. * If this was rendered in an iframe then trigger the external registration
  30. * complete behaviour in the parent page and provide the params returned from
  31. * the external registration page.
  32. *
  33. * @param {String} message The registration message from the external registration page
  34. * @param {String} error The registration error message from the external registration page, if
  35. * there was an error.
  36. * @param {Integer} id The tool proxy id for the external registration.
  37. * @param {String} status Whether the external registration was successful or not.
  38. */
  39. init: function(message, error, id, status) {
  40. if (window.parent) {
  41. window.parent.triggerExternalRegistrationComplete({
  42. message: message,
  43. error: error,
  44. id: id,
  45. status: status
  46. });
  47. }
  48. }
  49. };
  50. });