Skip to content

Commit

Permalink
Merge pull request #65 from stopfstedt/schwein_ins_uhrwerk
Browse files Browse the repository at this point in the history
fixes serialization issue with enrollment class.
  • Loading branch information
jrjohnson authored Nov 1, 2024
2 parents 1420df0 + 5d1ca61 commit 7b07e07
Showing 1 changed file with 7 additions and 17 deletions.
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

0 comments on commit 7b07e07

Please sign in to comment.