course_module_viewed.php 2.1 KB

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