26 lines
652 B
PHP
26 lines
652 B
PHP
|
<?php
|
||
|
|
||
|
namespace local_course_completion_checker;
|
||
|
|
||
|
defined('MOODLE_INTERNAL') || die();
|
||
|
|
||
|
class observer
|
||
|
{
|
||
|
public static function check_course_completion(\core\event\course_module_completion_updated $event)
|
||
|
{
|
||
|
global $DB;
|
||
|
|
||
|
$userid = $event->relateduserid;
|
||
|
$courseid = $event->courseid;
|
||
|
|
||
|
$completion = new \completion_info($event->get_course());
|
||
|
|
||
|
if (!$completion->is_enabled()) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$completion->update_state();
|
||
|
\core\notification::add("Course completion status updated for user $userid in course $courseid.", \core\output\notification::NOTIFY_SUCCESS);
|
||
|
}
|
||
|
}
|