diff --git a/classes/event/session_report_viewed.php b/classes/event/session_report_viewed.php index de625ba..36e26a2 100644 --- a/classes/event/session_report_viewed.php +++ b/classes/event/session_report_viewed.php @@ -119,17 +119,17 @@ class session_report_viewed extends \core\event\base { */ protected function validate_data() { if (!isset($this->relateduserid)) { - throw new \coding_exception('The event mod_attendance\\event\\student_attendance_sessions_viewed must specify relateduserid.'); + throw new \coding_exception('The event mod_attendance\\event\\session_report_viewed must specify relateduserid.'); } // view params can be left out as defaults will be the same when log event is viewed as when // it was stored. // filter params are important, but stored in session so default effectively unknown, // hence required here. if (!isset($this->other['view'])) { - throw new \coding_exception('The event mod_attendance\\event\\student_attendance_sessions_viewed must specify view.'); + throw new \coding_exception('The event mod_attendance\\event\\session_report_viewed must specify view.'); } if (!isset($this->other['curdate'])) { - throw new \coding_exception('The event mod_attendance\\event\\student_attendance_sessions_viewed must specify curdate.'); + throw new \coding_exception('The event mod_attendance\\event\\session_report_viewed must specify curdate.'); } parent::validate_data(); } diff --git a/view.php b/view.php index 4be6a1b..5ac3294 100644 --- a/view.php +++ b/view.php @@ -89,8 +89,13 @@ $filterparams = array( 'enddate' => $userdata->pageparams->enddate ); $params = array_merge($userdata->pageparams->get_significant_params(), $filterparams); +if (empty($userdata->pageparams->studentid)) { + $relateduserid = $USER->id; +} else { + $relateduserid = $userdata->pageparams->studentid; +} $event = \mod_attendance\event\session_report_viewed::create(array( - 'relateduserid' => $userdata->pageparams->studentid, + 'relateduserid' => $relateduserid, 'context' => $context, 'other' => $params)); $event->add_record_snapshot('course_modules', $cm);