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 * Event observers used by the weeks course format.
20 * @package format_weeks
21 * @copyright 2017 Mark Nelson <markn@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
28 * Event observer for format_weeks.
30 * @package format_weeks
31 * @copyright 2017 Mark Nelson <markn@moodle.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 class format_weeks_observer {
37 * Triggered via \core\event\course_updated event.
39 * @param \core\event\course_updated $event
41 public static function course_updated(\core\event\course_updated $event) {
42 if (class_exists('format_weeks', false)) {
43 // If class format_weeks was never loaded, this is definitely not a course in 'weeks' format.
44 // Course may still be in another format but format_weeks::update_end_date() will check it.
45 format_weeks::update_end_date($event->courseid);
50 * Triggered via \core\event\course_section_created event.
52 * @param \core\event\course_section_created $event
54 public static function course_section_created(\core\event\course_section_created $event) {
55 if (class_exists('format_weeks', false)) {
56 // If class format_weeks was never loaded, this is definitely not a course in 'weeks' format.
57 // Course may still be in another format but format_weeks::update_end_date() will check it.
58 format_weeks::update_end_date($event->courseid);
63 * Triggered via \core\event\course_section_deleted event.
65 * @param \core\event\course_section_deleted $event
67 public static function course_section_deleted(\core\event\course_section_deleted $event) {
68 if (class_exists('format_weeks', false)) {
69 // If class format_weeks was never loaded, this is definitely not a course in 'weeks' format.
70 // Course may still be in another format but format_weeks::update_end_date() will check it.
71 format_weeks::update_end_date($event->courseid);