2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 * The mod_assign submission form viewed event.
20 * @property-read array $other {
21 * Extra information about event.
23 * - int assignid: the id of the assignment.
28 * @copyright 2014 Mark Nelson <markn@moodle.com>
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 namespace mod_assign\event;
34 defined('MOODLE_INTERNAL') || die();
36 class submission_form_viewed extends base {
41 protected function init() {
42 $this->data['crud'] = 'r';
43 $this->data['edulevel'] = self::LEVEL_OTHER;
47 * Returns localised general event name.
51 public static function get_name() {
52 return get_string('eventsubmissionformviewed', 'mod_assign');
56 * Returns description of what happened.
60 public function get_description() {
61 if ($this->userid != $this->relateduserid) {
62 return "The user with the id {$this->userid} viewed the submission form for the user with the id {$this->relateduserid}
63 for the assignment with the id {$this->other['assignid']}.";
66 return "The user with the id {$this->userid} viewed their submission for the assignment with the id
67 {$this->other['assignid']}.";
73 * @throws \coding_exception
75 protected function validate_data() {
76 parent::validate_data();
78 if (!isset($this->relateduserid)) {
79 throw new \coding_exception('The \'relateduserid\' must be set.');
82 if (!isset($this->other['assignid'])) {
83 throw new \coding_exception('The \'assignid\' must be set in other.');