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

Upgrade to Moodle 4.4 and addition of test coverage. #49

Merged
merged 24 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9ce3ee0
corrects closing of the users loop.
stopfstedt Oct 1, 2024
dc22137
prevents learner enrolment on instructor sync if no instructors could…
stopfstedt Oct 1, 2024
b7523d0
check offering instructor groups before falling back to default instr…
stopfstedt Oct 1, 2024
328b6b1
Merge pull request #53 from stopfstedt/50_enrolment_toggling_bug
stopfstedt Oct 1, 2024
255444d
Merge pull request #54 from stopfstedt/51_learner_enrolment_on_instru…
stopfstedt Oct 1, 2024
ca7fefb
Merge pull request #55 from stopfstedt/52_check_offering_instructor_g…
stopfstedt Oct 1, 2024
0ecfc66
increment version to indicate a patch release.
stopfstedt Oct 1, 2024
14e3d4a
Merge pull request #56 from stopfstedt/version-bump
stopfstedt Oct 1, 2024
3bfda0c
minimal upgrade to Moodle 4.4.
stopfstedt Sep 18, 2024
0c3d020
adds the new Ilios API client and supporting infrastructure.
stopfstedt Sep 18, 2024
1b6697c
wip: replace ilios client in enrollment plugin
stopfstedt Sep 18, 2024
08d83f8
rm obsolete dependency on ilios_apiclient plugin.
stopfstedt Sep 26, 2024
4616810
updates copyright annotations in source files.
stopfstedt Sep 26, 2024
e159f62
adds test coverage for enrolment workflows.
stopfstedt Sep 30, 2024
96562e4
adds unenrolment notification back in.
stopfstedt Oct 1, 2024
06d5456
corrects closing of users loop.
stopfstedt Oct 1, 2024
c07d8ec
put output to Ilios API (http requests) under test coverage.
stopfstedt Oct 2, 2024
decfeaf
put logging output from sync under test coverage.
stopfstedt Oct 2, 2024
c8b24b4
add test scenario for changing enrolment status.
stopfstedt Oct 2, 2024
399d0d2
test return value of sync method.
stopfstedt Oct 2, 2024
f80439e
renamed test methods to reflect the method-under-test.
stopfstedt Oct 2, 2024
8b2a94a
add test coverage for disabled sync run.
stopfstedt Oct 2, 2024
3a2e6f1
adds more user sync tests.
stopfstedt Oct 3, 2024
c31e72d
stub out future tests.
stopfstedt Oct 3, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.1", "8.2"]
moodle-branch: ["MOODLE_403_STABLE"]
php: ["8.2", "8.3"]
moodle-branch: ["MOODLE_404_STABLE"]
database: [pgsql, mariadb]

steps:
Expand Down
65 changes: 20 additions & 45 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
*
* @package enrol_ilios
* @author Carson Tam <[email protected]>
* @copyright 2017 The Regents of the University of California
* @copyright The Regents of the University of California
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use core\di;
use enrol_ilios\ilios;

define('AJAX_SCRIPT', true);

require('../../config.php');
Expand Down Expand Up @@ -63,15 +66,17 @@
$outcome->response = new stdClass();
$outcome->error = '';

/** @var enrol_ilios_plugin $enrol */
$enrol = enrol_get_plugin('ilios');
$apiclient = $enrol->get_api_client();
$accesstoken = $enrol->get_api_access_token();
try {
$ilios = di::get(ilios::class);
} catch (Exception $e) {
// Re-throw exception.
throw new Exception('ERROR: Failed to instantiate Ilios client.', $e);
}

switch ($action) {
case 'getselectschooloptions':
require_capability('moodle/course:enrolconfig', $context);
$schools = $apiclient->get($accesstoken, 'schools', '', ['title' => "ASC"]);
$schools = $ilios->get_schools(['title' => "ASC"]);
$schoolarray = [];
foreach ($schools as $school) {
$schoolarray["$school->id:$school->title"] = $school->title;
Expand All @@ -83,7 +88,7 @@
require_capability('moodle/course:enrolconfig', $context);
$sid = required_param('filterid', PARAM_INT); // School ID.
$programs = [];
$programs = $apiclient->get($accesstoken, 'programs', ['school' => $sid], ['title' => "ASC"]);
$programs = $ilios->get_programs(['school' => $sid], ['title' => "ASC"]);
$programarray = [];
foreach ($programs as $program) {
$key = $program->id;
Expand All @@ -101,25 +106,15 @@
case 'getselectcohortoptions':
require_capability('moodle/course:enrolconfig', $context);
$pid = required_param('filterid', PARAM_INT);
$programyears = $apiclient->get(
$accesstoken,
'programYears',
["program" => $pid],
["startYear" => "ASC"]
);
$programyears = $ilios->get_program_years(["program" => $pid], ["startYear" => "ASC"]);
$programyeararray = [];
$cohortoptions = [];
foreach ($programyears as $progyear) {
$programyeararray[] = $progyear->id;
}

if (!empty($programyeararray)) {
$cohorts = $apiclient->get(
$accesstoken,
'cohorts',
["programYear" => $programyeararray],
["title" => "ASC"]
);
$cohorts = $ilios->get_cohorts(["programYear" => $programyeararray], ["title" => "ASC"]);
foreach ($cohorts as $cohort) {
$cohortoptions["$cohort->id:$cohort->title"] = $cohort->title
.' ('.count($cohort->learnerGroups).')'
Expand All @@ -133,12 +128,7 @@
require_capability('moodle/course:enrolconfig', $context);
$cid = required_param('filterid', PARAM_INT); // Cohort ID.
$usertype = optional_param('usertype', 0, PARAM_INT); // Learner or instructor.
$learnergroups = $apiclient->get(
$accesstoken,
'learnerGroups',
['cohort' => $cid, 'parent' => 'null'],
['title' => "ASC"]
);
$learnergroups = $ilios->get_learner_groups(['cohort' => $cid, 'parent' => 'null'], ['title' => "ASC"]);
$grouparray = [];
foreach ($learnergroups as $group) {
$grouparray["$group->id:$group->title"] = $group->title.
Expand All @@ -153,25 +143,15 @@
$gid = required_param('filterid', PARAM_INT); // Group ID.
$usertype = optional_param('usertype', 0, PARAM_INT); // Learner or instructor.
$subgroupoptions = [];
$subgroups = $apiclient->get(
$accesstoken,
'learnerGroups',
["parent" => $gid],
["title" => "ASC"]
);
$subgroups = $ilios->get_learner_groups(["parent" => $gid], ["title" => "ASC"]);
foreach ($subgroups as $subgroup) {
$subgroupoptions["$subgroup->id:$subgroup->title"] = $subgroup->title.
' ('. count($subgroup->children) .')';
$subgroupoptions["$subgroup->id:$subgroup->title"] .= ' ('. count($subgroup->users) .')';

if (!empty($subgroup->children)) {
$processchildren = function ($parent) use (&$processchildren, &$subgroupoptions, $apiclient, $accesstoken) {
$subgrps = $apiclient->get(
$accesstoken,
'learnerGroups',
[ 'parent' => $parent->id],
[ 'title' => "ASC"]
);
$processchildren = function ($parent) use (&$processchildren, &$subgroupoptions, $ilios) {
$subgrps = $ilios->get_learner_groups([ 'parent' => $parent->id], [ 'title' => "ASC"]);
foreach ($subgrps as $subgrp) {
$subgroupoptions["$subgrp->id:$parent->title / $subgrp->title"] = $parent->title.' / '.$subgrp->title.
' ('. count($subgrp->children) .')';
Expand All @@ -192,14 +172,9 @@
require_capability('moodle/course:enrolconfig', $context);
$gid = required_param('filterid', PARAM_INT); // Group ID.
$instructorgroupoptions = [];
$learnergroup = $apiclient->get_by_id($accesstoken, 'learnerGroups', $gid);
$learnergroup = $ilios->get_learner_group('learnerGroups', $gid);
if (!empty($learnergroup->instructorGroups)) {
$instructorgroups = $apiclient->get(
$accesstoken,
'instructorGroups',
'',
["title" => "ASC"]
);
$instructorgroups = $ilios->get_instructor_groups(sortby: ["title" => "ASC"]);
foreach ($instructorgroups as $instructorgroup) {
$instructorgroupoptions["$instructorgroup->id:$instructorgroup->title"] = $instructorgroup->title.
' ('. count($instructorgroup->users) .')';
Expand Down
Loading