Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes serialization issue with enrollment class. #65

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?
*
Expand Down Expand Up @@ -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.');
Expand Down Expand Up @@ -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)) {
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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.");

Expand Down