gradeimporter_submission_created.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. // This file is part of
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. namespace mod_gradeimporter\event;
  17. class gradeimporter_submission_created extends \core\event\base {
  18. protected function init() {
  19. $this->data['crud'] = 'c';
  20. $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
  21. }
  22. /**
  23. * Returns the description of what happened
  24. *
  25. * @return string
  26. */
  27. public function get_description () {
  28. return "The user with id '$this->userid' has created a submission " .
  29. "on the grade importer with the course module id '$this->contextinstanceid'.";
  30. }
  31. /**
  32. * Returns localised event name
  33. *
  34. * @return string
  35. */
  36. public static function get_name () {
  37. return get_string('eventmodelsubmissioncreated', 'mod_gradeimporter');
  38. }
  39. /**
  40. * Get URL related to the action
  41. *
  42. * @return \moodle_url
  43. */
  44. public function get_url () {
  45. $url = new \moodle_url('/mod/gradeimporter/view.php', array('id' => $this->contextinstanceid));
  46. return $url;
  47. }
  48. /**
  49. * Return the legacy event log data.
  50. *
  51. * @return array|null
  52. */
  53. protected function get_legacy_logdata () {
  54. // The legacy log table expects a relative path to /mod/model/ !!
  55. $logurl = new \moodle_url('/mod/gradeimporter/view.php', array('id' => $this->contextinstanceid));
  56. return array($this->courseid, 'gradeimporter', 'editgradeimporter', $logurl,
  57. $this->other['gradeimporterid'], $this->gradeimporterid);
  58. }
  59. /**
  60. * Custom validation
  61. *
  62. * @throws \coding_exception
  63. * @return void
  64. */
  65. protected function validate_data () {
  66. parent::validate_data();
  67. if ($this->contextlevel != CONTEXT_MODULE) {
  68. throw new \coding_exception('Context level must be CONTEXT_MODULE');
  69. }
  70. }
  71. }