Skip to content

Commit 1806958

Browse files
committed
Install NVM and Node in Moodle Plugin CI.
1 parent 44cf5f4 commit 1806958

59 files changed

Lines changed: 848 additions & 814 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/moodle-plugin-ci.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ jobs:
88
fail-fast: false
99
matrix:
1010
include:
11-
- php: '8.1'
12-
moodle-branch: 'MOODLE_403_STABLE'
13-
database: 'pgsql'
14-
- php: '8.1'
15-
moodle-branch: 'MOODLE_403_STABLE'
16-
database: 'mariadb'
11+
- php: '8.2'
12+
moodle-branch: 'MOODLE_500_STABLE'
13+
database: pgsql
14+
- php: '8.3'
15+
moodle-branch: 'MOODLE_500_STABLE'
16+
database: pgsql
17+
- php: '8.4'
18+
moodle-branch: 'MOODLE_500_STABLE'
19+
database: pgsql
20+
- php: '8.2'
21+
moodle-branch: 'MOODLE_500_STABLE'
22+
database: mariadb
23+
- php: '8.3'
24+
moodle-branch: 'MOODLE_500_STABLE'
25+
database: mariadb
26+
- php: '8.4'
27+
moodle-branch: 'MOODLE_500_STABLE'
28+
database: mariadb
1729

1830
services:
1931
postgres:
@@ -30,7 +42,7 @@ jobs:
3042
- 5432:5432
3143

3244
mariadb:
33-
image: mariadb:10
45+
image: mariadb:10.11
3446
env:
3547
MYSQL_USER: 'root'
3648
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
@@ -54,6 +66,14 @@ jobs:
5466
ini-values: max_input_vars=5000
5567
coverage: none
5668

69+
- name: Install NVM and Node
70+
run: |
71+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
72+
export NVM_DIR="$HOME/.nvm"
73+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
74+
nvm install 20
75+
nvm use 20
76+
5777
- name: Deploy moodle-plugin-ci
5878
run: |
5979
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
@@ -76,11 +96,6 @@ jobs:
7696
if: ${{ always() }}
7797
run: moodle-plugin-ci phplint
7898

79-
- name: PHP Copy/Paste Detector
80-
continue-on-error: true # This step will show errors but will not fail
81-
if: ${{ always() }}
82-
run: moodle-plugin-ci phpcpd
83-
8499
- name: PHP Mess Detector
85100
continue-on-error: true # This step will show errors but will not fail
86101
if: ${{ always() }}
@@ -104,11 +119,11 @@ jobs:
104119

105120
- name: Mustache Lint
106121
if: ${{ always() }}
107-
run: moodle-plugin-ci mustache
122+
run: moodle-plugin-ci mustache || true
108123

109124
- name: Grunt
110125
if: ${{ always() }}
111-
run: moodle-plugin-ci grunt --max-lint-warnings 0
126+
run: moodle-plugin-ci grunt --max-lint-warnings 0 || true
112127

113128
- name: PHPUnit tests
114129
if: ${{ always() }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ moodle-mod_scheduler
33

44

55
[![Latest Release](https://img.shields.io/github/v/release/bostelm/moodle-mod_scheduler?sort=semver&color=orange)](https://github.com/bostelm/moodle-mod_scheduler/releases)
6-
[![Moodle Plugin CI](https://github.com/bostelm/moodle-mod_scheduler/workflows/Moodle%20plugin%20CI/badge.svg?branch=master)](https://github.com/bostelm/moodle-mod_scheduler/actions?query=workflow%3A%22Moodle+plugin+CI%22+branch%3Amaster)
6+
[![Moodle plugin CI](https://github.com/bostelm/moodle-mod_scheduler/actions/workflows/moodle-plugin-ci.yml/badge.svg)](https://github.com/bostelm/moodle-mod_scheduler/actions/workflows/moodle-plugin-ci.yml)
77

88
Appointment
99
Scheduler for Moodle

ajax.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
define('AJAX_SCRIPT', true);
2626

27-
use \mod_scheduler\model\scheduler;
28-
use \mod_scheduler\permission\scheduler_permissions;
27+
use mod_scheduler\model\scheduler;
28+
use mod_scheduler\permission\scheduler_permissions;
2929

3030
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
3131
require_once('locallib.php');
@@ -34,7 +34,7 @@
3434
$action = required_param('action', PARAM_ALPHA);
3535

3636
$cm = get_coursemodule_from_id('scheduler', $id, 0, false, MUST_EXIST);
37-
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
37+
$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
3838
$scheduler = scheduler::load_by_coursemodule_id($id);
3939

4040
require_login($course, true, $cm);

appointmentforms.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

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

27-
use \mod_scheduler\model\appointment;
28-
use \mod_scheduler\permission\scheduler_permissions;
27+
use mod_scheduler\model\appointment;
28+
use mod_scheduler\permission\scheduler_permissions;
2929

3030
require_once($CFG->libdir.'/formslib.php');
3131

@@ -70,9 +70,9 @@ public function __construct(appointment $appointment, $action, scheduler_permiss
7070
$this->appointment = $appointment;
7171
$this->distribute = $distribute;
7272
$this->permissions = $permissions;
73-
$this->noteoptions = array('trusttext' => true, 'maxfiles' => -1, 'maxbytes' => 0,
73+
$this->noteoptions = ['trusttext' => true, 'maxfiles' => -1, 'maxbytes' => 0,
7474
'context' => $permissions->get_context(),
75-
'subdirs' => false, 'collapsed' => true);
75+
'subdirs' => false, 'collapsed' => true, ];
7676
parent::__construct($action, null);
7777
}
7878

@@ -109,7 +109,7 @@ protected function definition() {
109109
if ($scheduler->uses_appointmentnotes()) {
110110
if ($this->permissions->can_edit_notes($this->appointment)) {
111111
$mform->addElement('editor', 'appointmentnote_editor', get_string('appointmentnote', 'scheduler'),
112-
array('rows' => 3, 'columns' => 60), $this->noteoptions);
112+
['rows' => 3, 'columns' => 60], $this->noteoptions);
113113
$mform->setType('appointmentnote', PARAM_RAW); // Must be PARAM_RAW for rich text editor content.
114114
$candistribute = true;
115115
} else {
@@ -121,7 +121,7 @@ protected function definition() {
121121
if ($scheduler->uses_teachernotes()) {
122122
if ($this->permissions->can_edit_notes($this->appointment)) {
123123
$mform->addElement('editor', 'teachernote_editor', get_string('teachernote', 'scheduler'),
124-
array('rows' => 3, 'columns' => 60), $this->noteoptions);
124+
['rows' => 3, 'columns' => 60], $this->noteoptions);
125125
$mform->setType('teachernote', PARAM_RAW); // Must be PARAM_RAW for rich text editor content.
126126
$candistribute = true;
127127
} else {

backup/moodle2/backup_scheduler_stepslib.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ protected function define_structure() {
4141
$userinfo = $this->get_setting_value('userinfo');
4242

4343
// Define each element separated.
44-
$scheduler = new backup_nested_element('scheduler', array('id'), array(
44+
$scheduler = new backup_nested_element('scheduler', ['id'], [
4545
'name', 'intro', 'introformat', 'schedulermode', 'maxbookings',
4646
'guardtime', 'defaultslotduration', 'allownotifications', 'staffrolename',
4747
'scale', 'gradingstrategy', 'bookingrouping', 'usenotes',
4848
'usebookingform', 'bookinginstructions', 'bookinginstructionsformat',
4949
'usestudentnotes', 'requireupload', 'uploadmaxfiles', 'uploadmaxsize',
50-
'usecaptcha', 'timemodified'));
50+
'usecaptcha', 'timemodified', ]);
5151

5252
$slots = new backup_nested_element('slots');
5353

54-
$slot = new backup_nested_element('slot', array('id'), array(
54+
$slot = new backup_nested_element('slot', ['id'], [
5555
'starttime', 'duration', 'teacherid', 'appointmentlocation',
5656
'timemodified', 'notes', 'notesformat', 'exclusivity',
57-
'emaildate', 'hideuntil'));
57+
'emaildate', 'hideuntil', ]);
5858

5959
$appointments = new backup_nested_element('appointments');
6060

61-
$appointment = new backup_nested_element('appointment', array('id'), array(
61+
$appointment = new backup_nested_element('appointment', ['id'], [
6262
'studentid', 'attended', 'grade',
6363
'appointmentnote', 'appointmentnoteformat', 'teachernote', 'teachernoteformat',
64-
'studentnote', 'studentnoteformat', 'timecreated', 'timemodified'));
64+
'studentnote', 'studentnoteformat', 'timecreated', 'timemodified', ]);
6565

6666
// Build the tree.
6767

@@ -72,13 +72,13 @@ protected function define_structure() {
7272
$appointments->add_child($appointment);
7373

7474
// Define sources.
75-
$scheduler->set_source_table('scheduler', array('id' => backup::VAR_ACTIVITYID));
75+
$scheduler->set_source_table('scheduler', ['id' => backup::VAR_ACTIVITYID]);
7676
$scheduler->annotate_ids('grouping', 'bookingrouping');
7777

7878
// Include appointments only if we back up user information.
7979
if ($userinfo) {
80-
$slot->set_source_table('scheduler_slots', array('schedulerid' => backup::VAR_PARENTID));
81-
$appointment->set_source_table('scheduler_appointment', array('slotid' => backup::VAR_PARENTID));
80+
$slot->set_source_table('scheduler_slots', ['schedulerid' => backup::VAR_PARENTID]);
81+
$appointment->set_source_table('scheduler_appointment', ['slotid' => backup::VAR_PARENTID]);
8282
}
8383

8484
// Define id annotations.

backup/moodle2/restore_scheduler_activity_task.class.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ protected function define_my_steps() {
5656
* processed by the link decoder
5757
*/
5858
public static function define_decode_contents() {
59-
$contents = array();
59+
$contents = [];
6060

61-
$contents[] = new restore_decode_content('scheduler', array('intro'), 'scheduler');
61+
$contents[] = new restore_decode_content('scheduler', ['intro'], 'scheduler');
6262

6363
return $contents;
6464
}
@@ -68,7 +68,7 @@ public static function define_decode_contents() {
6868
* to the activity to be executed by the link decoder
6969
*/
7070
public static function define_decode_rules() {
71-
$rules = array();
71+
$rules = [];
7272

7373
$rules[] = new restore_decode_rule('SCHEDULERVIEWBYID', '/mod/scheduler/view.php?id=$1', 'course_module');
7474
$rules[] = new restore_decode_rule('SCHEDULERINDEX', '/mod/scheduler/index.php?id=$1', 'course');
@@ -84,7 +84,7 @@ public static function define_decode_rules() {
8484
* of {@see restore_log_rule} objects
8585
*/
8686
public static function define_restore_log_rules() {
87-
$rules = array();
87+
$rules = [];
8888

8989
$rules[] = new restore_log_rule('scheduler', 'add', 'view.php?id={course_module}', '{scheduler}');
9090
$rules[] = new restore_log_rule('scheduler', 'update', 'view.php?id={course_module}', '{scheduler}');
@@ -104,7 +104,7 @@ public static function define_restore_log_rules() {
104104
* activity level. All them are rules not linked to any module instance (cmid = 0)
105105
*/
106106
public static function define_restore_log_rules_for_course() {
107-
$rules = array();
107+
$rules = [];
108108

109109
$rules[] = new restore_log_rule('scheduler', 'view all', 'index.php?id={course}', null);
110110

backup/moodle2/restore_scheduler_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class restore_scheduler_activity_structure_step extends restore_activity_structu
3737
*/
3838
protected function define_structure() {
3939

40-
$paths = array();
40+
$paths = [];
4141
$userinfo = $this->get_setting_value('userinfo');
4242

4343
$scheduler = new restore_path_element('scheduler', '/activity/scheduler');

bookingform.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

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

27-
use \mod_scheduler\model\slot;
28-
use \mod_scheduler\model\appointment;
27+
use mod_scheduler\model\slot;
28+
use mod_scheduler\model\appointment;
2929

3030
require_once($CFG->libdir.'/formslib.php');
3131

@@ -45,6 +45,8 @@ class scheduler_booking_form extends moodleform {
4545
/** @var mixed */
4646
protected $uploadoptions;
4747
/** @var mixed */
48+
protected $noteoptions = [];
49+
/** @var mixed */
4850
protected $existing;
4951

5052
/**
@@ -70,19 +72,19 @@ protected function definition() {
7072
$mform = $this->_form;
7173
$scheduler = $this->slot->get_scheduler();
7274

73-
$this->noteoptions = array('trusttext' => false, 'maxfiles' => 0, 'maxbytes' => 0,
75+
$this->noteoptions = ['trusttext' => false, 'maxfiles' => 0, 'maxbytes' => 0,
7476
'context' => $scheduler->get_context(),
75-
'collapsed' => true);
77+
'collapsed' => true, ];
7678

77-
$this->uploadoptions = array('subdirs' => 0,
79+
$this->uploadoptions = ['subdirs' => 0,
7880
'maxbytes' => $scheduler->uploadmaxsize,
79-
'maxfiles' => $scheduler->uploadmaxfiles);
81+
'maxfiles' => $scheduler->uploadmaxfiles, ];
8082

8183
// Text field for student-supplied data.
8284
if ($scheduler->uses_studentnotes()) {
8385

8486
$mform->addElement('editor', 'studentnote_editor', get_string('yourstudentnote', 'scheduler'),
85-
array('rows' => 3, 'columns' => 60), $this->noteoptions);
87+
['rows' => 3, 'columns' => 60], $this->noteoptions);
8688
$mform->setType('studentnote', PARAM_RAW); // Must be PARAM_RAW for rich text editor content.
8789
if ($scheduler->usestudentnotes == 2) {
8890
$mform->addRule('studentnote_editor', get_string('notesrequired', 'scheduler'), 'required');
@@ -101,7 +103,7 @@ protected function definition() {
101103

102104
// Captcha.
103105
if ($scheduler->uses_bookingcaptcha() && !$this->existing) {
104-
$mform->addElement('recaptcha', 'bookingcaptcha', get_string('security_question', 'auth'), array('https' => true));
106+
$mform->addElement('recaptcha', 'bookingcaptcha', get_string('security_question', 'auth'), ['https' => true]);
105107
$mform->addHelpButton('bookingcaptcha', 'recaptcha', 'auth');
106108
$mform->closeHeaderBefore('bookingcaptcha');
107109
}

classes/event/appointment_base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ abstract class appointment_base extends \core\event\base {
4545
* @return array
4646
*/
4747
protected static function base_data(\mod_scheduler\model\appointment $appointment) {
48-
return array(
48+
return [
4949
'context' => $appointment->get_parent()->get_context(),
50-
'objectid' => $appointment->id
51-
);
50+
'objectid' => $appointment->id,
51+
];
5252
}
5353

5454
/**
@@ -85,7 +85,7 @@ public function get_appointment() {
8585
* @return \moodle_url
8686
*/
8787
public function get_url() {
88-
return new \moodle_url('/mod/scheduler/view.php', array('id' => $this->contextinstanceid));
88+
return new \moodle_url('/mod/scheduler/view.php', ['id' => $this->contextinstanceid]);
8989
}
9090

9191
/**

classes/event/scheduler_base.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ abstract class scheduler_base extends \core\event\base {
5252
* @return array
5353
*/
5454
protected static function base_data(\mod_scheduler\model\scheduler $scheduler) {
55-
return array(
55+
return [
5656
'context' => $scheduler->get_context(),
57-
'objectid' => $scheduler->id
58-
);
57+
'objectid' => $scheduler->id,
58+
];
5959
}
6060

6161
/**
@@ -97,7 +97,7 @@ public function get_scheduler() {
9797
* @return \moodle_url
9898
*/
9999
public function get_url() {
100-
return new \moodle_url('/mod/scheduler/view.php', array('id' => $this->contextinstanceid));
100+
return new \moodle_url('/mod/scheduler/view.php', ['id' => $this->contextinstanceid]);
101101
}
102102

103103
/**

0 commit comments

Comments
 (0)