Skip to content

Commit 03e16a9

Browse files
committed
Code cleanup and support for 4.4
1 parent a297885 commit 03e16a9

File tree

92 files changed

+1816
-2836
lines changed

Some content is hidden

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

92 files changed

+1816
-2836
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 60 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,113 @@
1-
name: Moodle plugin CI
1+
name: Moodle Plugin CI
2+
23
on: [push, pull_request]
34

45
jobs:
56
test:
6-
runs-on: 'ubuntu-latest'
7-
strategy:
8-
fail-fast: false
9-
matrix:
10-
include:
11-
- php: '8.1'
12-
moodle-branch: 'MOODLE_402_STABLE'
13-
database: 'mariadb'
14-
- php: '8.1'
15-
moodle-branch: 'MOODLE_402_STABLE'
16-
database: 'mariadb'
17-
- php: '8.0'
18-
moodle-branch: 'MOODLE_402_STABLE'
19-
database: 'mariadb'
20-
- php: '8.0'
21-
moodle-branch: 'MOODLE_402_STABLE'
22-
database: 'mariadb'
23-
- php: '8.1'
24-
moodle-branch: 'MOODLE_401_STABLE'
25-
database: 'mariadb'
26-
- php: '8.1'
27-
moodle-branch: 'MOODLE_401_STABLE'
28-
database: 'mariadb'
29-
- php: '8.0'
30-
moodle-branch: 'MOODLE_401_STABLE'
31-
database: 'mariadb'
32-
- php: '8.0'
33-
moodle-branch: 'MOODLE_401_STABLE'
34-
database: 'mariadb'
35-
- php: '7.4'
36-
moodle-branch: 'MOODLE_401_STABLE'
37-
database: 'mariadb'
38-
- php: '7.4'
39-
moodle-branch: 'MOODLE_401_STABLE'
40-
database: 'mariadb'
41-
- php: '7.4'
42-
moodle-branch: 'MOODLE_400_STABLE'
43-
database: 'mariadb'
44-
- php: '7.4'
45-
moodle-branch: 'MOODLE_400_STABLE'
46-
database: 'mariadb'
7+
runs-on: ubuntu-22.04
478

489
services:
4910
postgres:
50-
image: postgres
11+
image: postgres:13
5112
env:
5213
POSTGRES_USER: 'postgres'
5314
POSTGRES_HOST_AUTH_METHOD: 'trust'
54-
options: >-
55-
--health-cmd pg_isready
56-
--health-interval 10s
57-
--health-timeout 5s
58-
--health-retries 3
5915
ports:
6016
- 5432:5432
17+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
6118

6219
mariadb:
63-
image: mariadb:10.5
20+
image: mariadb:10
6421
env:
6522
MYSQL_USER: 'root'
6623
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
24+
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
25+
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
6726
ports:
6827
- 3306:3306
6928
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
7029

30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
php: ['8.0']
34+
moodle-branch: ['MOODLE_403_STABLE', 'MOODLE_404_STABLE']
35+
database: [pgsql, mariadb]
36+
7137
steps:
72-
- name: Checkout
73-
uses: actions/checkout@v3
38+
- name: Check out repository code
39+
uses: actions/checkout@v4
7440
with:
7541
path: plugin
7642

77-
- name: Setup PHP
43+
- name: Setup PHP ${{ matrix.php }}
7844
uses: shivammathur/setup-php@v2
7945
with:
8046
php-version: ${{ matrix.php }}
81-
extensions: zip, gd, mbstring, pgsql, mysqli
47+
extensions: ${{ matrix.extensions }}
48+
ini-values: max_input_vars=5000
49+
coverage: none
8250

83-
- name: Deploy moodle-plugin-ci
51+
- name: Initialise moodle-plugin-ci
8452
run: |
85-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
86-
# Add dirs to $PATH
53+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
8754
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
8855
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
89-
# PHPUnit depends on en_AU.UTF-8 locale
9056
sudo locale-gen en_AU.UTF-8
91-
- name: Install Moodle
92-
# Need explicit IP to stop mysql client fail on attempt to use unix socket.
57+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
58+
59+
- name: Install moodle-plugin-ci
9360
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
9461
env:
9562
DB: ${{ matrix.database }}
9663
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
97-
IGNORE_NAMES: 'mobile_*.mustache'
98-
IGNORE_PATHS: 'templates/local/mobile'
9964

100-
- name: phplint
101-
if: ${{ always() }}
65+
- name: PHP Lint
66+
if: ${{ !cancelled() }}
10267
run: moodle-plugin-ci phplint
10368

104-
- name: phpcpd
105-
if: ${{ always() }}
106-
run: moodle-plugin-ci phpcpd || true
69+
- name: PHP Copy/Paste Detector
70+
continue-on-error: true # This step will show errors but will not fail
71+
if: ${{ !cancelled() }}
72+
run: moodle-plugin-ci phpcpd
10773

108-
- name: phpmd
109-
if: ${{ always() }}
74+
- name: PHP Mess Detector
75+
continue-on-error: true # This step will show errors but will not fail
76+
if: ${{ !cancelled() }}
11077
run: moodle-plugin-ci phpmd
11178

112-
- name: codechecker
113-
if: ${{ always() }}
114-
run: moodle-plugin-ci codechecker
79+
- name: Moodle Code Checker
80+
if: ${{ !cancelled() }}
81+
run: moodle-plugin-ci phpcs --max-warnings 0
11582

116-
- name: validate
117-
if: ${{ always() }}
83+
- name: Moodle PHPDoc Checker
84+
if: ${{ !cancelled() }}
85+
run: moodle-plugin-ci phpdoc --max-warnings 0
86+
87+
- name: Validating
88+
if: ${{ !cancelled() }}
11889
run: moodle-plugin-ci validate
11990

120-
- name: savepoints
121-
if: ${{ always() }}
91+
- name: Check upgrade savepoints
92+
if: ${{ !cancelled() }}
12293
run: moodle-plugin-ci savepoints
12394

124-
- name: mustache
125-
if: ${{ always() }}
95+
- name: Mustache Lint
96+
if: ${{ !cancelled() }}
12697
run: moodle-plugin-ci mustache
12798

128-
- name: grunt
129-
if: ${{ always() }}
130-
run: moodle-plugin-ci grunt
99+
- name: Grunt
100+
if: ${{ !cancelled() }}
101+
run: moodle-plugin-ci grunt --max-lint-warnings 0
131102

132-
- name: phpunit
133-
if: ${{ always() }}
134-
run: moodle-plugin-ci phpunit
103+
- name: PHPUnit tests
104+
if: ${{ !cancelled() }}
105+
run: moodle-plugin-ci phpunit --fail-on-warning
135106

136-
- name: behat
137-
if: ${{ always() }}
107+
- name: Behat features
108+
if: ${{ !cancelled() }}
138109
run: moodle-plugin-ci behat --profile chrome
110+
111+
- name: Mark cancelled jobs as failed.
112+
if: ${{ cancelled() }}
113+
run: exit 1

.travis.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

action.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@
3333
$cmid = capquiz_urls::require_course_module_id_param();
3434
$cm = get_coursemodule_from_id('capquiz', $cmid, 0, false, MUST_EXIST);
3535
require_login($cm->course, false, $cm);
36+
3637
$context = \context_module::instance($cmid);
3738
require_capability('mod/capquiz:instructor', $context);
3839

3940
$action = required_param('action', PARAM_TEXT);
4041

41-
$cmid = capquiz_urls::require_course_module_id_param();
4242
$capquiz = new capquiz($cmid);
43-
if ($capquiz) {
44-
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync);
45-
capquiz_action_performer::perform($action, $capquiz);
46-
}
43+
capquiz_urls::set_page_url($capquiz, capquiz_urls::$urlasync);
44+
capquiz_action_performer::perform($action, $capquiz);
4745

4846
capquiz_urls::redirect_to_dashboard();

0 commit comments

Comments
 (0)