Skip to content

Commit

Permalink
updates to comply latest GHA requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Opitz committed Jan 26, 2024
1 parent 926f4cc commit 3fba8c4
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion block_lifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function init() {
* @return bool[]
*/
public function applicable_formats() {
return array('site-index' => true);
return ['site-index' => true];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions classes/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function get_course_lifecycle_info(int $courseid) {
}

$text = 'Moodle ' . $courseacademicyear . '/' . ((int) substr($courseacademicyear, -2) + 1);
$result = array('class' => $class, 'text' => $text);
$result = ['class' => $class, 'text' => $text];
}

return $result;
Expand Down Expand Up @@ -94,7 +94,7 @@ public static function get_potential_academic_years() : array {
WHERE cf.id = :fieldid AND cd.value <> '' AND cd.value IS NOT NULL
ORDER BY cd.value DESC";

return $DB->get_records_sql($sql, array('fieldid' => $fieldid));
return $DB->get_records_sql($sql, ['fieldid' => $fieldid]);
}

/**
Expand Down Expand Up @@ -122,7 +122,7 @@ public static function get_clc_custom_course_fields(): array {
public static function get_courses_for_context_freezing(): array {
global $DB;

$eligiblecourses = array();
$eligiblecourses = [];

// Get weeks delay in seconds.
$enddateextend = self::get_weeks_delay_in_seconds();
Expand All @@ -133,7 +133,7 @@ public static function get_courses_for_context_freezing(): array {
AND c.enddate <> 0 AND (c.enddate + :enddateextend) < :currenttime";

$potentialcourses = $DB->get_records_sql($sql,
array('siteid' => SITEID, 'enddateextend' => $enddateextend, 'currenttime' => time()));
['siteid' => SITEID, 'enddateextend' => $enddateextend, 'currenttime' => time()]);

if (!empty($potentialcourses)) {
foreach ($potentialcourses as $course) {
Expand Down Expand Up @@ -322,7 +322,7 @@ public static function get_scheduled_freeze_date(int $courseid) {

return [
'defaultfreezedate' => date('Y-m-d', $defaultscheduledfreezedate),
'scheduledfreezedate' => date('d/m/Y', $scheduledfreezedate)
'scheduledfreezedate' => date('d/m/Y', $scheduledfreezedate),
];
}

Expand Down
34 changes: 17 additions & 17 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,36 @@

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

$capabilities = array(
$capabilities = [
// Add this to prevent getting errors on certain pages according to moodle dev docs.
'block/lifecycle:myaddinstance' => array(
'block/lifecycle:myaddinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
),
'block/lifecycle:addinstance' => array(
],
'block/lifecycle:addinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
'block/lifecycle:overridecontextfreeze' => array(
],
'clonepermissionsfrom' => 'moodle/site:manageblocks',
],
'block/lifecycle:overridecontextfreeze' => [
'riskbitmask' => RISK_CONFIG,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
),
),
'block/lifecycle:view' => array(
],
],
'block/lifecycle:view' => [
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
),
),
);
],
],
];
16 changes: 8 additions & 8 deletions db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@
defined('MOODLE_INTERNAL') || die();

// We defined the web service functions to install.
$functions = array(
'block_lifecycle_update_auto_freezing_preferences' => array(
$functions = [
'block_lifecycle_update_auto_freezing_preferences' => [
'classname' => 'block_lifecycle_external',
'methodname' => 'update_auto_freezing_preferences',
'classpath' => 'blocks/lifecycle/externallib.php',
'description' => 'Update auto context freezing preferences',
'ajax' => true,
'type' => 'write',
'loginrequired' => true
),
'block_lifecycle_get_scheduled_freeze_date' => array(
'loginrequired' => true,
],
'block_lifecycle_get_scheduled_freeze_date' => [
'classname' => 'block_lifecycle_external',
'methodname' => 'get_scheduled_freeze_date',
'classpath' => 'blocks/lifecycle/externallib.php',
'description' => 'Get scheduled freeze date',
'ajax' => true,
'type' => 'read',
'loginrequired' => true
),
);
'loginrequired' => true,
],
];


10 changes: 5 additions & 5 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@

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

$tasks = array(
array(
$tasks = [
[
'classname' => '\block_lifecycle\task\freezecontext',
'blocking' => 0,
'minute' => 0,
'hour' => 0,
'day' => '*',
'month' => '*',
'dayofweek' => '*',
'disabled' => 0
)
);
'disabled' => 0,
],
];

26 changes: 13 additions & 13 deletions externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class block_lifecycle_external extends external_api {
*/
public static function update_auto_freezing_preferences_parameters() {
return new external_function_parameters(
array(
[
'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED),
'preferences' => new external_value(PARAM_RAW, 'Preferences', VALUE_REQUIRED),
)
]
);
}

Expand All @@ -48,11 +48,11 @@ public static function update_auto_freezing_preferences_parameters() {
public static function update_auto_freezing_preferences_returns() {
return
new external_single_structure(
array(
[
'success' => new external_value(PARAM_TEXT, 'Request result'),
'message' => new external_value(PARAM_TEXT, 'Message', VALUE_OPTIONAL),
'error' => new external_value(PARAM_TEXT, 'Error message', VALUE_OPTIONAL)
)
'error' => new external_value(PARAM_TEXT, 'Error message', VALUE_OPTIONAL),
]
);
}

Expand All @@ -69,7 +69,7 @@ public static function update_auto_freezing_preferences(int $courseid, string $p
// Parameters validation.
$params = self::validate_parameters(
self::update_auto_freezing_preferences_parameters(),
array('courseid' => $courseid, 'preferences' => $preferences));
['courseid' => $courseid, 'preferences' => $preferences]);

return (array) manager::update_auto_freezing_preferences($params['courseid'], json_decode($params['preferences']));
}
Expand All @@ -80,9 +80,9 @@ public static function update_auto_freezing_preferences(int $courseid, string $p
*/
public static function get_scheduled_freeze_date_parameters() {
return new external_function_parameters(
array(
'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED)
)
[
'courseid' => new external_value(PARAM_INT, 'Course ID', VALUE_REQUIRED),
]
);
}

Expand All @@ -93,12 +93,12 @@ public static function get_scheduled_freeze_date_parameters() {
public static function get_scheduled_freeze_date_returns() {
return
new external_single_structure(
array(
[
'success' => new external_value(PARAM_TEXT, 'Request result'),
'defaultfreezedate' => new external_value(PARAM_TEXT, 'Default freeze date'),
'scheduledfreezedate' => new external_value(PARAM_TEXT, 'Scheduled freeze date'),
'error' => new external_value(PARAM_TEXT, 'Error message', VALUE_OPTIONAL)
),
'error' => new external_value(PARAM_TEXT, 'Error message', VALUE_OPTIONAL),
],
);
}

Expand All @@ -115,7 +115,7 @@ public static function get_scheduled_freeze_date(int $courseid): array {
// Parameters validation.
$params = self::validate_parameters(
self::get_scheduled_freeze_date_parameters(),
array('courseid' => $courseid));
['courseid' => $courseid]);

$success = 'true';
$result = manager::get_scheduled_freeze_date($params['courseid']);
Expand Down
6 changes: 3 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function fetch_block_content(int $courseid): string {
$content .= html_writer::div(
'<h6>' . get_string('label:readonlydate', 'block_lifecycle') . '</h6>'.
'<div class="scheduled-freeze-date" id="scheduled-freeze-date"></div>',
'', array('id' => 'scheduled-freeze-date-container'));
'', ['id' => 'scheduled-freeze-date-container']);

$content .= html_writer::div('<a class="btn btn-success"><i class="fa-edit fa fa-fw"></i>' .
get_string('button:editsettings', 'block_lifecycle') .
'</a>',
'override-freeze-date-button', array('id' => 'override-freeze-date-button'));
$content .= html_writer::start_div('automatic-read-only-settings', array('id' => 'automatic-read-only-settings'));
'override-freeze-date-button', ['id' => 'override-freeze-date-button']);
$content .= html_writer::start_div('automatic-read-only-settings', ['id' => 'automatic-read-only-settings']);
$content .= html_writer::div(
'<label>' . get_string('button:toggleautoreadonly', 'block_lifecycle') . '</label>'. $helpicontogglefreezinghtml .
'<div class="form-check form-switch">'.
Expand Down
4 changes: 2 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
));

// The number of weeks to delay the context freezing.
$options = array();
$options = [];
for ($i = 0; $i <= 14; $i++) {
$options[$i] = "$i";
}
Expand All @@ -47,7 +47,7 @@
get_string('settings:weeksdelay:desc', 'block_lifecycle'), 0, $options));

// The CLC course custom field use for getting potential academic years.
$options = array();
$options = [];
$fields = manager::get_clc_custom_course_fields();
if (!empty($fields)) {
foreach ($fields as $field) {
Expand Down
14 changes: 7 additions & 7 deletions tests/manager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ protected function setUp(): void {

// Create roles.
$this->teacherroleid = $dg->create_role(
array('shortname' => 'test_teacher',
['shortname' => 'test_teacher',
'name' => 'test_teacher',
'description' => 'test teacher role',
'archetype' => 'editingteacher'));
'archetype' => 'editingteacher']);

$this->studentroleid = $dg->create_role(
array('shortname' => 'test_student',
['shortname' => 'test_student',
'name' => 'test_student',
'description' => 'student role',
'archetype' => 'student'));
'archetype' => 'student']);

// Create users.
$this->user1 = $dg->create_user();
Expand Down Expand Up @@ -272,15 +272,15 @@ public function test_get_course_clc_academic_year() {
public function test_get_course_lifecycle_info() {
// Test course academic year is 2020.
$result = manager::get_course_lifecycle_info($this->course1->id);
$this->assertEquals(array('class' => '', 'text' => 'Moodle 2020/21'), $result);
$this->assertEquals(['class' => '', 'text' => 'Moodle 2020/21'], $result);

// Test course academic year is current academic year.
$result = manager::get_course_lifecycle_info($this->course3->id);
$this->assertEquals(array('class' => 'current', 'text' => 'Moodle 2022/23'), $result);
$this->assertEquals(['class' => 'current', 'text' => 'Moodle 2022/23'], $result);

// Test course academic year is future academic year.
$result = manager::get_course_lifecycle_info($this->course4->id);
$this->assertEquals(array('class' => 'future', 'text' => 'Moodle 2023/24'), $result);
$this->assertEquals(['class' => 'future', 'text' => 'Moodle 2023/24'], $result);
}

/**
Expand Down

0 comments on commit 3fba8c4

Please sign in to comment.