2024-10-21 10:47:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace local_course_completion_checker;
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
|
|
|
|
class observer
|
|
|
|
{
|
2024-10-21 12:45:07 +00:00
|
|
|
public static function check_course_completion(\mod_quiz\event\attempt_submitted $event)
|
2024-10-21 10:47:50 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|