gradeimporter_submission_created.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace mod_gradeimporter\event;
  3. defined('MOODLE_INTERNAL') || die();
  4. class gradeimporter_submission_created extends \core\event\base {
  5. protected function init() {
  6. $this->data['crud'] = 'c';
  7. $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
  8. }
  9. /**
  10. *Returns the description of what happened
  11. *
  12. *@return string
  13. */
  14. public function get_description(){
  15. return "The user with id '$this->userid' has created a submission " .
  16. "on the grade importer with the course module id '$this->contextinstanceid'." ;
  17. }
  18. /**
  19. * Returns localised event name
  20. *
  21. * @return string
  22. */
  23. public static function get_name(){
  24. return get_string('eventmodelsubmissioncreated', 'mod_gradeimporter');
  25. }
  26. /**
  27. * Get URL related to the action
  28. *
  29. * @return \moodle_url
  30. */
  31. public function get_url(){
  32. $url = new \moodle_url('/mod/gradeimporter/view.php', array('id' => $this->contextinstanceid));
  33. return $url;
  34. }
  35. /**
  36. * Return the legacy event log data.
  37. *
  38. * @return array|null
  39. */
  40. protected function get_legacy_logdata(){
  41. //the legacy log table expects a relative path to /mod/model/
  42. $logurl = new \moodle_url('/mod/gradeimporter/view.php', array('id' => $this->contextinstanceid));
  43. return array($this->courseid, 'gradeimporter', 'editgradeimporter', $logurl,
  44. $this->other['gradeimporterid'], $this->gradeimporterid);
  45. }
  46. /**
  47. * Custom validation
  48. *
  49. * @throws \coding_exception
  50. * @return void
  51. */
  52. protected function validate_data(){
  53. parent::validate_data();
  54. if ($this->contextlevel != CONTEXT_MODULE) {
  55. throw new \coding_exception('Context level must be CONTEXT_MODULE');
  56. }
  57. }
  58. }