mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-41123 report_completion: Add context validations to the events
This commit is contained in:
parent
df13233697
commit
e5f4487194
@ -71,5 +71,18 @@ class report_viewed extends \core\event\base {
|
|||||||
public function get_url() {
|
public function get_url() {
|
||||||
return new \moodle_url('/report/completion/index.php', array('course' => $this->courseid));
|
return new \moodle_url('/report/completion/index.php', array('course' => $this->courseid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* custom validations.
|
||||||
|
*
|
||||||
|
* @throws \coding_exception when validation fails.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function validate_data() {
|
||||||
|
parent::validate_data();
|
||||||
|
if ($this->contextlevel != CONTEXT_COURSE) {
|
||||||
|
throw new \coding_exception('Context passed must be course context.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,5 +81,18 @@ class user_report_viewed extends \core\event\base {
|
|||||||
public function get_url() {
|
public function get_url() {
|
||||||
return new \moodle_url('/report/completion/user.php', array('course' => $this->courseid, 'id' => $this->relateduserid));
|
return new \moodle_url('/report/completion/user.php', array('course' => $this->courseid, 'id' => $this->relateduserid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* custom validations.
|
||||||
|
*
|
||||||
|
* @throws \coding_exception when validation fails.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function validate_data() {
|
||||||
|
parent::validate_data();
|
||||||
|
if ($this->contextlevel != CONTEXT_COURSE) {
|
||||||
|
throw new \coding_exception('Context passed must be course context.');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user