Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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 availability_relativedate;
18
 
19
/**
20
 * Autoupdate for handling deleted course modules
21
 *
22
 * @package   availability_relativedate
23
 * @copyright 2022 eWallah.net
24
 * @author    Stefan Hanauska <stefan.hanauska@altmuehlnet.de>
25
 * @author    Renaat Debleu <info@eWallah.net>
26
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
class autoupdate {
29
    /**
30
     * Called when a course_module_deleted event is triggered. Updates the completion state for all
31
     * availability_relativedate instances in the course of the activity.
32
     *
33
     * @param \core\event\base $event
34
     * @return void
35
     */
36
    public static function update_from_event(\core\event\base $event): void {
37
        $data = $event->get_data();
38
        $courseid = $data['courseid'];
39
        if (isset($courseid) && $courseid > 0) {
40
            $modid = $data['objectid'];
41
            if (condition::completion_value_used($courseid, $modid)) {
42
                \core_availability\info::update_dependency_id_across_course($courseid, 'course_modules', $modid, -1);
43
                // Added to be sure no errors are thrown (issue #22).
44
                rebuild_course_cache($courseid, true);
45
                get_fast_modinfo(0, 0, true);
46
            }
47
        }
48
    }
49
}