submission_created.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  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. /**
  17. * The mod_iassign submission created event.
  18. *
  19. * @author Patricia Alves Rodrigues
  20. * @author Leônidas O. Brandão
  21. * @version v 1.0 2015/07/12
  22. * @package mod_iassign
  23. * @since 2015/07/12
  24. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  25. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26. */
  27. namespace mod_iassign\event;
  28. defined('MOODLE_INTERNAL') || die();
  29. class submission_created extends \core\event\base {
  30. /**
  31. * Init method.
  32. */
  33. protected function init () {
  34. $this->data['crud'] = 'c'; // c(reate), r(ead), u(pdate), d(elete)
  35. $this->data['edulevel'] = self::LEVEL_PARTICIPATING; // LEVEL_TEACHING , LEVEL_PARTICIPATING, LEVEL_OTHER
  36. $this->data['objecttable'] = 'iassign';
  37. }
  38. /**
  39. * Returns localised general event name.
  40. *
  41. * @return string
  42. */
  43. public static function get_name () {
  44. return get_string('eventsubmissioncreated', 'mod_iassign');
  45. }
  46. /**
  47. * Returns non-localised event description with id's for admin use only.
  48. *
  49. * @return string
  50. */
  51. public function get_description () {
  52. return "The user with id '$this->userid' has created submission the iAssign with id '$this->objectid' in " .
  53. "the iAssign activity with course module id '$this->contextinstanceid'.";
  54. }
  55. /**
  56. * Get URL related to the action.
  57. *
  58. * @return \moodle_url
  59. */
  60. public function get_url () {
  61. return new \moodle_url('/mod/iassign/view.php', array('id' => $this->contextinstanceid));
  62. }
  63. /**
  64. * Return the legacy event log data.
  65. *
  66. * @return array|null
  67. */
  68. public function get_legacy_logdata () {
  69. return array($this->courseid, 'iassign', 'add submission',
  70. "view.php?id={$this->contextinstanceid}",
  71. $this->objectid, $this->contextinstanceid);
  72. }
  73. /**
  74. * Custom validation.
  75. *
  76. * @throws \coding_exception
  77. * @return void
  78. */
  79. protected function validate_data () {
  80. parent::validate_data();
  81. // Make sure this class is never used without proper object details.
  82. if(!$this->contextlevel === CONTEXT_MODULE) {
  83. throw new \coding_exception('Context level must be CONTEXT_MODULE.');
  84. }
  85. }
  86. }