nasatlx_deleted.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * The mod_nasatlx deleted event.
  4. *
  5. * @author Leônidas O. Brandão
  6. * @version v 0.1 2019/03/04
  7. * @package mod_nasatlx
  8. * @category event
  9. * @since 2019/03/04
  10. * @copyright LInE (line.ime.usp.br) - Computer Science Dep. of IME-USP (Brazil)
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  12. */
  13. namespace mod_nasatlx\event;
  14. defined('MOODLE_INTERNAL') || die();
  15. class nasatlx_deleted extends \core\event\base {
  16. /// Init method.
  17. protected function init () {
  18. $this->data['crud'] = 'd'; // c(reate), r(ead), u(pdate), d(elete)
  19. $this->data['edulevel'] = self::LEVEL_TEACHING; // LEVEL_TEACHING , LEVEL_PARTICIPATING, LEVEL_OTHER
  20. $this->data['objecttable'] = 'nasatlx';
  21. }
  22. /// Returns localised general event name.
  23. // @return string
  24. public static function get_name () {
  25. return get_string('eventnasatlxdeleted', 'mod_nasatlx');
  26. }
  27. /// Returns non-localised event description with id's for admin use only.
  28. // @return string
  29. public function get_description () {
  30. return "The user with id '$this->userid' has deleted the NASA-TLX/LInE with id '$this->objectid' in " .
  31. "the NASA-TLX/LInE activity with course module id '$this->contextinstanceid'.";
  32. }
  33. /// Get URL related to the action.
  34. // @return \moodle_url
  35. public function get_url () {
  36. return new \moodle_url('/mod/nasatlx/view.php', array('id' => $this->contextinstanceid));
  37. }
  38. /// Return the legacy event log data.
  39. // @return array|null
  40. public function get_legacy_logdata () {
  41. return array($this->courseid, 'nasatlx', 'delete nasatlx',
  42. "view.php?id={$this->contextinstanceid}", $this->objectid, $this->contextinstanceid);
  43. }
  44. /// Custom validation.
  45. // @throws \coding_exception
  46. // @return void
  47. protected function validate_data () {
  48. parent::validate_data();
  49. // Make sure this class is never used without proper object details.
  50. if (!$this->contextlevel === CONTEXT_MODULE) {
  51. throw new \coding_exception('Context level must be CONTEXT_MODULE.');
  52. }
  53. }
  54. }