moodle-local_course_complet.../classes/observer.php

26 lines
641 B
PHP
Raw Normal View History

<?php
namespace local_course_completion_checker;
defined('MOODLE_INTERNAL') || die();
class observer
{
public static function check_course_completion(\mod_quiz\event\attempt_submitted $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);
}
}