commit 4a7f631532648e7b6189505d5fba4bf9ea3aa691 Author: Kumi Date: Mon Oct 21 12:47:50 2024 +0200 feat: add course completion check functionality Introduced a new observer to handle 'course_module_completion_updated' events, updating course completion status automatically. This streamlines the user experience by notifying users of their course completion status changes. Added observer registration to events configuration and updated the plugin version details. diff --git a/classes/observer.php b/classes/observer.php new file mode 100644 index 0000000..ddb7a41 --- /dev/null +++ b/classes/observer.php @@ -0,0 +1,25 @@ +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); + } +} diff --git a/db/events.php b/db/events.php new file mode 100644 index 0000000..9f1407c --- /dev/null +++ b/db/events.php @@ -0,0 +1,9 @@ + '\core\event\course_module_completion_updated', + 'callback' => 'local_course_completion_checker_observer::check_course_completion', + ], +]; diff --git a/version.php b/version.php new file mode 100644 index 0000000..8ed2cc9 --- /dev/null +++ b/version.php @@ -0,0 +1,6 @@ +version = 2024102100; +$plugin->requires = 2021051700; +$plugin->component = 'local_course_completion_checker';