Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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   * Event observers used by the weeks course format.
  19   *
  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
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Event observer for format_weeks.
  29   *
  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
  33   */
  34  class format_weeks_observer {
  35  
  36      /**
  37       * Triggered via \core\event\course_updated event.
  38       *
  39       * @param \core\event\course_updated $event
  40       */
  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);
  46          }
  47      }
  48  
  49      /**
  50       * Triggered via \core\event\course_section_created event.
  51       *
  52       * @param \core\event\course_section_created $event
  53       */
  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);
  59          }
  60      }
  61  
  62      /**
  63       * Triggered via \core\event\course_section_deleted event.
  64       *
  65       * @param \core\event\course_section_deleted $event
  66       */
  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);
  72          }
  73      }
  74  }