Skip to content

Commit

Permalink
manually correct any outstanding PHP code linter errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Jun 3, 2024
1 parent 2cb096d commit 4e53576
Show file tree
Hide file tree
Showing 8 changed files with 486 additions and 311 deletions.
17 changes: 8 additions & 9 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This file processes AJAX enrolment actions and returns JSON for the ilios plugin
* This file processes AJAX enrolment actions and returns JSON for the ilios plugin.
*
* The general idea behind this file is that any errors should throw exceptions
* which will be returned and acted upon by the calling AJAX script.
Expand All @@ -33,7 +33,7 @@
require_once($CFG->dirroot.'/group/lib.php');

// Must have the sesskey.
$id = required_param('id', PARAM_INT); // course id
$id = required_param('id', PARAM_INT); // Course ID.
$action = required_param('action', PARAM_ALPHANUMEXT);

$PAGE->set_url(new moodle_url('/enrol/ilios/ajax.php', ['id' => $id, 'action' => $action]));
Expand Down Expand Up @@ -81,7 +81,7 @@

case 'getselectprogramoptions':
require_capability('moodle/course:enrolconfig', $context);
$sid = required_param('filterid', PARAM_INT); // school id
$sid = required_param('filterid', PARAM_INT); // School ID.
$programs = [];
$programs = $apiclient->get($accesstoken, 'programs', ['school' => $sid], ['title' => "ASC"]);
$programarray = [];
Expand Down Expand Up @@ -131,8 +131,8 @@

case 'getselectlearnergroupoptions':
require_capability('moodle/course:enrolconfig', $context);
$cid = required_param('filterid', PARAM_INT); // cohort id
$usertype = optional_param('usertype', 0, PARAM_INT); // learner or instructor
$cid = required_param('filterid', PARAM_INT); // Cohort ID.
$usertype = optional_param('usertype', 0, PARAM_INT); // Learner or instructor.
$learnergroups = $apiclient->get(
$accesstoken,
'learnerGroups',
Expand All @@ -150,8 +150,8 @@

case 'getselectsubgroupoptions':
require_capability('moodle/course:enrolconfig', $context);
$gid = required_param('filterid', PARAM_INT); // group id
$usertype = optional_param('usertype', 0, PARAM_INT); // learner or instructor
$gid = required_param('filterid', PARAM_INT); // Group ID.
$usertype = optional_param('usertype', 0, PARAM_INT); // Learner or instructor.
$subgroupoptions = [];
$subgroups = $apiclient->get(
$accesstoken,
Expand Down Expand Up @@ -190,14 +190,13 @@

case 'getselectinstructorgroupoptions':
require_capability('moodle/course:enrolconfig', $context);
$gid = required_param('filterid', PARAM_INT); // group id
$gid = required_param('filterid', PARAM_INT); // Group ID.
$instructorgroupoptions = [];
$learnergroup = $apiclient->get_by_id($accesstoken, 'learnerGroups', $gid);
if (!empty($learnergroup->instructorGroups)) {
$instructorgroups = $apiclient->get(
$accesstoken,
'instructorGroups',
// array("id" => $learnergroup->instructorGroups),
'',
["title" => "ASC"]
);
Expand Down
19 changes: 11 additions & 8 deletions classes/task/ilios_sync_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,32 @@

namespace enrol_ilios\task;

defined('MOODLE_INTERNAL') || die;
use coding_exception;
use core\task\scheduled_task;

/**
* Simple task to run sync enrolments.
*
* @package enrol_ilios
* @copyright 2018 The Regents of the University of California
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class ilios_sync_task extends \core\task\scheduled_task {
class ilios_sync_task extends scheduled_task {

/**
* @inheritdoc
* Gets the task name.
*
* @return string The task name.
* @throws coding_exception
*/
public function get_name() {
return get_string('iliossync', 'enrol_ilios');
}

/**
* @inheritdoc
* Executes the task.
*/
public function execute() {
public function execute(): void {
global $CFG;

require_once($CFG->dirroot . '/enrol/ilios/lib.php');
Expand All @@ -54,8 +59,6 @@ public function execute() {
}

$plugin = enrol_get_plugin('ilios');
$result = $plugin->sync(new \text_progress_trace());
return $result;

$plugin->sync(new \text_progress_trace());
}
}
10 changes: 8 additions & 2 deletions db/uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Callback to run during plugin uninstallation.
* Deletes all Ilios enrolments and removes any user role assignments for this plugin.
*
* @return bool Always TRUE.
* @throws coding_exception
* @throws dml_exception
*/
function xmldb_enrol_ilios_uninstall() {
global $CFG, $DB;

Expand Down
39 changes: 26 additions & 13 deletions edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
$instance->id = null;
$instance->courseid = $course->id;
$instance->enrol = 'ilios';
$instance->customchar1 = ''; // cohort / learnerGroup
$instance->customint1 = 0; // cohort / leaner group id.
$instance->customint2 = 0; // 0 - learner / 1 - instructor
$instance->customtext1 = ''; // json string of all useful values
$instance->customint6 = 0; // group id.
$instance->customchar1 = ''; // Cohort / learnerGroup.
$instance->customint1 = 0; // Cohort / leaner group id.
$instance->customint2 = 0; // Learner = 0, Instructor = 1.
$instance->customtext1 = ''; // JSON string of all useful values.
$instance->customint6 = 0; // Group ID.
}

// Try and make the manage instances node on the navigation active.
Expand Down Expand Up @@ -125,7 +125,14 @@
// NOTE: no cohort or learner group changes here!!!
if ($data->roleid != $instance->roleid) {
// The sync script can only add roles, for perf reasons it does not modify them.
role_unassign_all(['contextid' => $context->id, 'roleid' => $instance->roleid, 'component' => 'enrol_ilios', 'itemid' => $instance->id]);
role_unassign_all(
[
'contextid' => $context->id,
'roleid' => $instance->roleid,
'component' => 'enrol_ilios',
'itemid' => $instance->id,
]
);
}

$instance->name = $data->name;
Expand All @@ -140,13 +147,19 @@

$DB->update_record('enrol', $instance);
} else {
$enrol->add_instance($course, ['name' => $data->name, 'status' => $data->status,
'customchar1' => $synctype,
'customint1' => $syncid,
'customtext1' => json_encode($syncinfo),
'roleid' => $data->roleid,
'customint2' => $data->selectusertype,
'customint6' => $data->customint6]);
$enrol->add_instance(
$course,
[
'name' => $data->name,
'status' => $data->status,
'customchar1' => $synctype,
'customint1' => $syncid,
'customtext1' => json_encode($syncinfo),
'roleid' => $data->roleid,
'customint2' => $data->selectusertype,
'customint6' => $data->customint6,
],
);
}

$trace = new null_progress_trace();
Expand Down
Loading

0 comments on commit 4e53576

Please sign in to comment.