Browse Source

Set relateduserid correctly in event.

nwp90-nwp90-allsessionsreport
Dan Marsden 5 years ago
parent
commit
d0f62e5141
  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() { protected function validate_data() {
if (!isset($this->relateduserid)) { 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 // view params can be left out as defaults will be the same when log event is viewed as when
// it was stored. // it was stored.
// filter params are important, but stored in session so default effectively unknown, // filter params are important, but stored in session so default effectively unknown,
// hence required here. // hence required here.
if (!isset($this->other['view'])) { 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'])) { 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(); parent::validate_data();
} }

7
view.php

@ -89,8 +89,13 @@ $filterparams = array(
'enddate' => $userdata->pageparams->enddate 'enddate' => $userdata->pageparams->enddate
); );
$params = array_merge($userdata->pageparams->get_significant_params(), $filterparams); $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( $event = \mod_attendance\event\session_report_viewed::create(array(
'relateduserid' => $userdata->pageparams->studentid, 'relateduserid' => $relateduserid,
'context' => $context, 'context' => $context,
'other' => $params)); 'other' => $params));
$event->add_record_snapshot('course_modules', $cm); $event->add_record_snapshot('course_modules', $cm);

Loading…
Cancel
Save