Skip to content

Commit

Permalink
Auto-correct PHP code linter errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Jun 5, 2024
1 parent 484b508 commit 973ac7d
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 306 deletions.
44 changes: 22 additions & 22 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class enrol_ucsfsis_external extends external_api {
*/
public static function get_subjects_and_courses_by_term_parameters() {
return new external_function_parameters(
array(
[
'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED),
'termid' => new external_value(PARAM_TEXT, 'Term ID', VALUE_REQUIRED)
)
'termid' => new external_value(PARAM_TEXT, 'Term ID', VALUE_REQUIRED),
]
);
}

Expand All @@ -58,19 +58,19 @@ public static function get_subjects_and_courses_by_term_parameters() {
* @throws dml_exception
* @throws moodle_exception
*/
public static function get_subjects_and_courses_by_term($courseId, $termId) {
public static function get_subjects_and_courses_by_term($courseid, $termid) {
global $DB;
$raw = array(
'courses' => array(),
'subjects' => array(),
);
$raw = [
'courses' => [],
'subjects' => [],
];

$clean = array(
'courses' => array(),
'subjects' => array(),
);
$clean = [
'courses' => [],
'subjects' => [],
];

$course = $DB->get_record('course', array('id' => $courseId), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);

if ($course->id == SITEID) {
Expand All @@ -86,8 +86,8 @@ public static function get_subjects_and_courses_by_term($courseId, $termId) {
$http = $enrol->get_http_client();

if ($http->is_logged_in()) {
$raw['courses'] = $http->get_courses_in_term($termId);
$raw['subjects'] = $http->get_subjects_in_term($termId);
$raw['courses'] = $http->get_courses_in_term($termid);
$raw['subjects'] = $http->get_subjects_in_term($termid);

foreach($raw['courses'] as $course) {
$clean['courses'][] = enrol_ucsfsis_simplify_sis_course($course);
Expand All @@ -104,25 +104,25 @@ public static function get_subjects_and_courses_by_term($courseId, $termId) {
*/
public static function get_subjects_and_courses_by_term_returns() {
return new external_function_parameters(
array(
[
'courses' => new external_multiple_structure(
new external_single_structure(
array(
[
'id' => new external_value(PARAM_TEXT, 'course id'),
'title' => new external_value(PARAM_TEXT, 'course title'),
'subjectId' => new external_value(PARAM_TEXT, 'the id of the course-owning subject'),
)
]
)
),
'subjects' => new external_multiple_structure(
new external_single_structure(
array(
[
'id' => new external_value(PARAM_TEXT, 'subject id'),
'title' => new external_value(PARAM_TEXT, 'subject title'),
)
]
)
)
)
),
]
);
}
}
2 changes: 1 addition & 1 deletion classes/sis_client_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function get($param) {
$filename = 'u'.'_'.md5(serialize($param));
if(file_exists($this->dir.$filename)) {
$lasttime = filemtime($this->dir.$filename);
if (time()-$lasttime > $this->ttl) {
if (time() - $lasttime > $this->ttl) {
return false;
} else {
$fp = fopen($this->dir.$filename, 'r');
Expand Down
20 changes: 10 additions & 10 deletions classes/task/cron_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function get_name() {
global $CFG, $DB;

// Task Name
$task_name = get_string('crontask', 'enrol_ucsfsis');
$taskname = get_string('crontask', 'enrol_ucsfsis');

// Additional information
$enrol = enrol_get_plugin('ucsfsis');
Expand All @@ -47,24 +47,24 @@ public function get_name() {
// calculate completed percentage
$index = $enrol->get_config('last_sync_course_index', 0);
if (!empty($index)) {
$total = $DB->count_records('enrol', array( 'enrol'=>'ucsfsis', 'status' => '0'));
$total = $DB->count_records('enrol', [ 'enrol' => 'ucsfsis', 'status' => '0']);
if (!empty($total)) {
$info .= '<br />'.round($index/$total * 100) . "% has been completed.";
$info .= '<br />'.round($index / $total * 100) . "% has been completed.";
}
}

// last completed time
$last_completed = $enrol->get_config('last_completed_time');
if (!empty($last_completed)) {
$info .= "<br />Last complete run was on ".userdate($last_completed).'.';
$lastcompleted = $enrol->get_config('last_completed_time');
if (!empty($lastcompleted)) {
$info .= "<br />Last complete run was on ".userdate($lastcompleted).'.';
}

// Append and format extra information
if (!empty($info)) {
$task_name .= "<small><em>$info</em></small>";
$taskname .= "<small><em>$info</em></small>";
}

return $task_name;
return $taskname;
}

/**
Expand All @@ -78,13 +78,13 @@ public function execute() {
require_once($CFG->libdir . '/weblib.php');

$enrol = enrol_get_plugin('ucsfsis');
$total = $DB->count_records('enrol', array( 'enrol'=>'ucsfsis', 'status' => '0'));
$total = $DB->count_records('enrol', [ 'enrol' => 'ucsfsis', 'status' => '0']);
$numlimit = ceil($total / 6); // Number of courses to sync on each run (Try to have a complete run within an hour.)
$numupdated = 0; // Number of courses has been sync'd on this run
$startindex = $enrol->get_config('last_sync_course_index', 0);

$courses = $DB->get_records( 'enrol',
array( 'enrol'=>'ucsfsis', 'status' => '0' ),
[ 'enrol' => 'ucsfsis', 'status' => '0' ],
'timecreated',
'id, courseid, roleid, customint1',
$startindex, $numlimit );
Expand Down
Loading

0 comments on commit 973ac7d

Please sign in to comment.