From 5d1ca61aace49d3ac2a06749d37210851e6a6fb3 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Fri, 1 Nov 2024 15:36:21 -0700 Subject: [PATCH] fixes serialization issue with enrollment class. --- lib.php | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib.php b/lib.php index c22b067..2730d0c 100644 --- a/lib.php +++ b/lib.php @@ -36,18 +36,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class enrol_ilios_plugin extends enrol_plugin { - /** - * @var ilios The Ilios API client. - */ - protected ilios $ilios; - - /** - * Constructor. - */ - public function __construct() { - $this->ilios = di::get(ilios::class); - } - /** * Is it possible to delete enrol instance via standard UI? * @@ -206,6 +194,8 @@ public function sync($trace, $courseid = null): int { global $CFG, $DB; require_once($CFG->dirroot . '/group/lib.php'); + $ilios = di::get(ilios::class); + if (!enrol_is_enabled('ilios')) { // Purge all roles if ilios sync disabled, those can be recreated later here by cron or CLI. $trace->output('Ilios enrolment sync plugin is disabled, unassigning all plugin roles and stopping.'); @@ -239,9 +229,9 @@ public function sync($trace, $courseid = null): int { $syncid = $instance->customint1; if ('learnerGroup' === $synctype) { - $entity = $this->ilios->get_learner_group($syncid); + $entity = $ilios->get_learner_group($syncid); } else { - $entity = $this->ilios->get_cohort($syncid); + $entity = $ilios->get_cohort($syncid); } if (empty($entity)) { @@ -257,7 +247,7 @@ public function sync($trace, $courseid = null): int { if (!empty($instance->customint2)) { $instructors = []; if ('learnerGroup' === $synctype && !empty($instance->customint2)) { - $instructors = $this->ilios->get_instructor_ids_from_learner_group($entity->id); + $instructors = $ilios->get_instructor_ids_from_learner_group($entity->id); } if (!empty($instructors)) { $trace->output( @@ -269,7 +259,7 @@ public function sync($trace, $courseid = null): int { . $instance->id . "." ); - $users = $this->ilios->get_users(['id' => $instructors]); + $users = $ilios->get_users(['id' => $instructors]); } } else if (!empty($entity->users)) { $trace->output( @@ -281,7 +271,7 @@ public function sync($trace, $courseid = null): int { $instance->id . "." ); - $users = $this->ilios->get_users(['id' => $entity->users]); + $users = $ilios->get_users(['id' => $entity->users]); } $trace->output(count($users) . " Ilios users found.");