MDL-41101 mod_assign: replaced 'view' add_to_log call for the submission status page...
[moodle.git] / mod / assign / classes / event / submission_status_viewed.php
CommitLineData
cf2d7bfb
MN
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
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.
8//
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.
13//
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/>.
16
17/**
18 * The mod_assign submission status viewed event.
19 *
20 * @property-read array $other {
21 * Extra information about event.
22 *
23 * - int assignid: the id of the assignment.
24 * }
25 *
26 * @package mod_assign
27 * @since Moodle 2.7
28 * @copyright 2014 Mark Nelson <markn@moodle.com>
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 */
31
32namespace mod_assign\event;
33
34defined('MOODLE_INTERNAL') || die();
35
36class submission_status_viewed extends base {
37
38 /**
39 * Init method.
40 *
41 * @return void
42 */
43 protected function init() {
44 $this->data['crud'] = 'r';
45 $this->data['edulevel'] = self::LEVEL_OTHER;
46 }
47
48 /**
49 * Return localised event name.
50 *
51 * @return string
52 */
53 public static function get_name() {
54 return get_string('eventsubmissionstatusviewed', 'mod_assign');
55 }
56
57 /**
58 * Returns description of what happened.
59 *
60 * @return string
61 */
62 public function get_description() {
63 return "The user with the id {$this->userid} has viewed the status of their submission for the assignment with
64 the id {$this->other['assignid']}.";
65 }
66
67 /**
68 * Custom validation.
69 *
70 * @throws \coding_exception
71 */
72 protected function validate_data() {
73 parent::validate_data();
74
75 if (!isset($this->other['assignid'])) {
76 throw new \coding_exception('The \'assignid\' must be set in other.');
77 }
78 }
79}