Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
namespace core\event;
18
 
19
use core\url;
20
 
21
/**
22
 * Event course_overview_viewed
23
 *
24
 * @package    core
25
 * @copyright  2025 Ferran Recio <ferran@moodle.com>
26
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
class course_overview_viewed extends \core\event\base {
29
 
30
    /**
31
     * Set basic properties for the event.
32
     */
33
    protected function init() {
34
        $this->data['crud'] = 'r';
35
        $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
36
    }
37
 
38
    /**
39
     * Returns description of what happened.
40
     *
41
     * @return string
42
     */
43
    public function get_description(): string {
44
        return "The user with id '$this->userid' viewed the course activity overview for the course with id '$this->courseid'.";
45
    }
46
 
47
    /**
48
     * Return localised event name.
49
     *
50
     * @return string
51
     */
52
    public static function get_name(): string {
53
        return get_string('eventcourseoverviewviewed', 'core');
54
    }
55
 
56
    /**
57
     * Get URL related to the action.
58
     *
59
     * @return url|null
60
     */
61
    public function get_url() {
62
        return new url('/course/overview.php', ['id' => $this->courseid]);
63
    }
64
 
65
    /**
66
     * Custom validation.
67
     *
68
     * @throws \coding_exception
69
     * @return void
70
     */
71
    protected function validate_data() {
72
        parent::validate_data();
73
        if ($this->contextlevel != CONTEXT_COURSE) {
74
            throw new \coding_exception('Context level must be CONTEXT_COURSE.');
75
        }
76
    }
77
}