Feature: Prevent students from sharing device while self-marking.
[moodle-mod_attendance.git] / classes / event / session_ip_shared.php
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 * This file contains an event for when self-marking is blocked because
19 * another student used the same IP address to self-mark.
20 *
21 * @package mod_attendance
22 * @author Dan Marsden <dan@danmarsden.com>
23 * @copyright 2018 Catalyst IT
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26 namespace mod_attendance\event;
27
28 defined('MOODLE_INTERNAL') || die();
29
30 /**
31 * Event for when self-marking is blocked
32 *
33 * @property-read array $other {
34 * Extra information about event properties.
35 *
36 * string mode Mode of the report viewed.
37 * }
38 * @package mod_attendance
39 * @author Dan Marsden <dan@danmarsden.com>
40 * @copyright 2018 Catalyst IT
41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42 */
43 class session_ip_shared extends \core\event\base {
44
45 /**
46 * Init method.
47 */
48 protected function init() {
49 $this->data['crud'] = 'r';
50 $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
51 $this->data['objecttable'] = 'attendance_log';
52 }
53
54 /**
55 * Returns non-localised description of what happened.
56 *
57 * @return string
58 */
59 public function get_description() {
60 return 'User with id ' . $this->userid . ' was blocked from taking attendance for sessionid: ' . $this->other['sessionid'] .
61 ' because user with id '.$this->other['otheruser'] . ' previously marked attendance with the same IP address.';
62 }
63
64 /**
65 * Returns localised general event name.
66 *
67 * @return string
68 */
69 public static function get_name() {
70 return get_string('eventsessionipshared', 'mod_attendance');
71 }
72
73 /**
74 * Get URL related to the action
75 *
76 * @return \moodle_url
77 */
78 public function get_url() {
79 return new \moodle_url('/mod/attendance/attendance.php');
80 }
81
82 /**
83 * Get objectid mapping
84 *
85 * @return array of parameters for object mapping.
86 */
87 public static function get_objectid_mapping() {
88 return array(
89 'db' => 'attendance',
90 'restore' => 'attendance'
91 );
92 }
93 }