moodle-local_course_complet.../classes/observer.php
Kumi 897724127c
fix(observer): update event type for course completion check
Changed event type from 'course_module_completion_updated' to 'attempt_submitted' within the observer to correctly trigger course completion checks upon quiz attempt submission. This aligns with the intended workflow of updating completion status when a quiz is attempted instead of a module update. This change ensures that the system accurately reflects users' progress and achieves synchronization with the quiz completion logic.
2024-10-21 14:45:07 +02:00

25 lines
641 B
PHP

<?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);
}
}