Browse Source

Set relateduserid correctly in event.

MOODLE_37_STABLE
Dan Marsden 5 years ago
parent
commit
6d2af13983
  1. 6
      classes/event/session_report_viewed.php
  2. 7
      view.php

6
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();
}

7
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);

Loading…
Cancel
Save