Skip to content

Commit 6dae304

Browse files
authored
Merge pull request #4 from KrisBax/wip918773
Update for plugin for release
2 parents 0a7d897 + 8009861 commit 6dae304

File tree

13 files changed

+120
-118
lines changed

13 files changed

+120
-118
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@ jobs:
88
fail-fast: false
99
matrix:
1010
include:
11-
- php: '7.4'
12-
moodle-branch: 'master'
11+
- php: '8.3'
12+
moodle-branch: 'main'
1313
database: 'pgsql'
14-
- php: '7.4'
15-
moodle-branch: 'MOODLE_311_STABLE'
14+
- php: '8.3'
15+
moodle-branch: 'MOODLE_500_STABLE'
16+
database: 'mariadb'
17+
- php: '8.2'
18+
moodle-branch: 'MOODLE_405_STABLE'
19+
database: 'pgsql'
20+
- php: '8.2'
21+
moodle-branch: 'MOODLE_404_STABLE'
1622
database: 'mariadb'
1723

1824
services:
1925
postgres:
20-
image: postgres
26+
image: postgres:15
2127
env:
2228
POSTGRES_USER: 'postgres'
2329
POSTGRES_HOST_AUTH_METHOD: 'trust'
@@ -30,77 +36,85 @@ jobs:
3036
- 5432:5432
3137

3238
mariadb:
33-
image: mariadb
39+
image: mariadb:10
3440
env:
3541
MYSQL_USER: 'root'
3642
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
43+
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
44+
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
3745
ports:
3846
- 3306:3306
3947
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
4048

4149
steps:
42-
- name: Checkout
50+
- name: Check out repository code
4351
uses: actions/checkout@v2
4452
with:
4553
path: plugin
4654

47-
- name: Setup PHP
55+
- name: Setup PHP ${{ matrix.php }}
4856
uses: shivammathur/setup-php@v2
4957
with:
5058
php-version: ${{ matrix.php }}
51-
extensions: mbstring, pgsql, mysqli
59+
extensions: ${{ matrix.extensions }}
60+
ini-values: max_input_vars=5000
61+
coverage: none
5262

53-
- name: Deploy moodle-plugin-ci
63+
- name: Initialise moodle-plugin-ci
5464
run: |
55-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
65+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
5666
# Add dirs to $PATH
5767
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
5868
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
59-
# PHPUnit depends on en_AU.UTF-8 locale
6069
sudo locale-gen en_AU.UTF-8
70+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
6171
6272
- name: Install Moodle
6373
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
6474
env:
6575
DB: ${{ matrix.database }}
6676
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
6777

68-
- name: phplint
78+
- name: PHP Lint
6979
if: ${{ always() }}
7080
run: moodle-plugin-ci phplint
7181

72-
- name: phpcpd
82+
- name: PHP Copy/Paste Detector
7383
if: ${{ always() }}
7484
run: moodle-plugin-ci phpcpd
7585

76-
- name: phpmd
86+
- name: PHP Mess Detector
7787
if: ${{ always() }}
7888
run: moodle-plugin-ci phpmd
7989

80-
- name: codechecker
90+
- name: Moodle Code Checker
8191
if: ${{ always() }}
82-
run: moodle-plugin-ci codechecker
92+
run: moodle-plugin-ci codechecker --max-warnings 0
8393

84-
- name: validate
94+
- name: Moodle PHPDoc Checker
95+
if: ${{ always() }}
96+
run: moodle-plugin-ci phpdoc
97+
98+
- name: Validating
8599
if: ${{ always() }}
86100
run: moodle-plugin-ci validate
87101

88-
- name: savepoints
102+
- name: Check upgrade savepoints
89103
if: ${{ always() }}
90104
run: moodle-plugin-ci savepoints
91105

92-
- name: mustache
106+
- name: Mustache Lint
107+
continue-on-error: true # We are getting a false positive due to MDLSITE-6744 so ignore.
93108
if: ${{ always() }}
94109
run: moodle-plugin-ci mustache
95110

96-
- name: grunt
97-
if: ${{ always() }}
98-
run: moodle-plugin-ci grunt
111+
- name: Grunt
112+
run: moodle-plugin-ci grunt --max-lint-warnings 4
99113

100-
- name: phpunit
114+
- name: PHPUnit tests
101115
if: ${{ always() }}
102-
run: moodle-plugin-ci phpunit
116+
run: moodle-plugin-ci phpunit --fail-on-warning
103117

104-
- name: behat
118+
- name: Behat features
105119
if: ${{ always() }}
106120
run: moodle-plugin-ci behat --profile chrome

changes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change log for the Edit ID numbers report
22

3+
## Changes in 2.7
4+
5+
* This version is compatible with Moodle 5.0.
6+
* Fixed code checker issues.
7+
* Updated behat tests to work with Moodle 4.4.
8+
* Log events: removed legacy logging methods for compatibility with Moodle 4.2.
9+
10+
311
## Changes in 2.6
412

513
* This version works with Moodle 4.0.

classes/event/report_viewed.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
namespace report_editidnumber\event;
2525

26-
defined('MOODLE_INTERNAL') || die();
27-
2826
/**
2927
*
3028
* @package report_editdates
@@ -72,30 +70,10 @@ public static function get_name() {
7270
* @return \moodle_url
7371
*/
7472
public function get_url() {
75-
$params = array('id' => $this->courseid);
73+
$params = ['id' => $this->courseid];
7674
if ($this->other['activitytype']) {
7775
$params['activitytype'] = $this->other['activitytype'];
7876
}
7977
return new \moodle_url('/report/editidnumber/index.php', $params);
8078
}
81-
82-
public static function get_legacy_eventname() {
83-
return 'report id number';
84-
}
85-
86-
/**
87-
* Return the legacy event log data.
88-
*
89-
* @return array|null
90-
*/
91-
protected function get_legacy_logdata() {
92-
return array(
93-
$this->courseid,
94-
"course",
95-
"report id number",
96-
"report/editidnumber/index.php?id={$this->courseid}",
97-
$this->contextinstanceid
98-
);
99-
}
100-
10179
}

classes/privacy/provider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
1617
/**
1718
* Privacy Subsystem implementation for report_editidnumber.
1819
*
@@ -21,7 +22,7 @@
2122
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2223
*/
2324
namespace report_editidnumber\privacy;
24-
defined('MOODLE_INTERNAL') || die();
25+
2526
/**
2627
* Privacy Subsystem for report_editidnumber implementing null_provider.
2728
*
@@ -33,9 +34,9 @@ class provider implements \core_privacy\local\metadata\null_provider {
3334
* Get the language string identifier with the component's language
3435
* file to explain why this plugin stores no data.
3536
*
36-
* @return string
37+
* @return string
3738
*/
38-
public static function get_reason() : string {
39+
public static function get_reason(): string {
3940
return 'privacy:metadata';
4041
}
4142
}

db/access.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
defined('MOODLE_INTERNAL') || die;
2626

2727

28-
$capabilities = array(
29-
'report/editidnumber:view' => array(
28+
$capabilities = [
29+
'report/editidnumber:view' => [
3030
'riskbitmask' => RISK_PERSONAL,
3131
'captype' => 'read',
3232
'contextlevel' => CONTEXT_COURSE,
33-
'archetypes' => array(
33+
'archetypes' => [
3434
'editingteacher' => CAP_ALLOW,
35-
'manager' => CAP_ALLOW
36-
),
35+
'manager' => CAP_ALLOW,
36+
],
3737
'clonepermissionsfrom' => 'moodle/site:viewreports',
38-
),
39-
);
38+
],
39+
];

db/install.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424

25-
defined('MOODLE_INTERNAL') || die;
26-
25+
/**
26+
* Executes post-installation and migration tasks for the report_editidnumber plugin.
27+
*
28+
* Handles permission migration and cleanup from previous plugin versions.
29+
*
30+
* @return void
31+
*/
2732
function xmldb_report_editidnumber_install() {
2833
global $DB;
2934

@@ -32,10 +37,10 @@ function xmldb_report_editidnumber_install() {
3237
// and clone the permissions from moodle/site:viewreports, but if we are upgrading
3338
// a Moodle that had the old course report plugin installed, then we get rid of the
3439
// new cloned capabilities, and transfer the old permissions.
35-
if ($DB->record_exists('role_capabilities', array('capability' => 'coursereport/editidnumber:view'))) {
36-
$DB->delete_records('role_capabilities', array('capability' => 'report/editidnumber:view'));
40+
if ($DB->record_exists('role_capabilities', ['capability' => 'coursereport/editidnumber:view'])) {
41+
$DB->delete_records('role_capabilities', ['capability' => 'report/editidnumber:view']);
3742
$DB->set_field('role_capabilities', 'capability', 'report/editidnumber:view',
38-
array('capability' => 'coursereport/editidnumber:view'));
43+
['capability' => 'coursereport/editidnumber:view']);
3944
}
4045

4146
// This is a hack which is needed for cleanup of original coursereport_completion stuff.
@@ -44,6 +49,6 @@ function xmldb_report_editidnumber_install() {
4449

4550
// Update existing block page patterns.
4651
$DB->set_field('block_instances', 'pagetypepattern', 'report-editidnumber-index',
47-
array('pagetypepattern' => 'course-report-editidnumber-index'));
52+
['pagetypepattern' => 'course-report-editidnumber-index']);
4853
}
4954

form.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
*/
3838
class report_editidnumber_form extends moodleform {
3939

40+
#[\Override]
4041
public function definition() {
4142
global $CFG, $COURSE, $DB;
4243
$mform = $this->_form;
@@ -53,7 +54,7 @@ public function definition() {
5354

5455
// Defining array for providing (see above) link from grade items
5556
// which are associated with course modules.
56-
$modgradeitemmap = array();
57+
$modgradeitemmap = [];
5758

5859
// Store current activity type.
5960
$mform->addElement('hidden', 'activitytype', $activitytype);
@@ -103,10 +104,10 @@ public function definition() {
103104
$elname = '';
104105

105106
// Display activity name.
106-
$iconmarkup = html_writer::empty_tag('img', array(
107-
'src' => $cm->get_icon_url(), 'class' => 'activityicon', 'alt' => '' ));
107+
$iconmarkup = html_writer::empty_tag('img', [
108+
'src' => $cm->get_icon_url(), 'class' => 'activityicon', 'alt' => '']);
108109
$stractivityname = html_writer::tag('strong' , $iconmarkup . $cm->name,
109-
array('id' => null, 'class' => renderer_base::prepare_classes('main')));
110+
['id' => null, 'class' => renderer_base::prepare_classes('main')]);
110111

111112
$elname = 'idnumber[cm]['.$cm->id.']';
112113
// Creating element id.
@@ -125,7 +126,7 @@ public function definition() {
125126

126127
// Element to display ID number.
127128
$mform->addElement('text', $elname, get_string('idnumbermod'),
128-
array("id" => $elid), array("id" => $elid));
129+
["id" => $elid], ["id" => $elid]);
129130
$mform->setType($elname, PARAM_RAW);
130131
$mform->addHelpButton($elname, 'idnumbermod');
131132
if (isset($cm->idnumber)) {
@@ -142,7 +143,7 @@ public function definition() {
142143
$readonlygrades = !has_capability('moodle/grade:manage', $coursecontext);
143144

144145
// Fetching Gradebook items.
145-
$gradeitems = grade_item::fetch_all(array('courseid' => $course->id));
146+
$gradeitems = grade_item::fetch_all(['courseid' => $course->id]);
146147

147148
// Course module will be always fetched,
148149
// so lenghth will always be 1 if no gread item is fetched.
@@ -177,7 +178,7 @@ public function definition() {
177178
// In case of itemtype category,
178179
// fetching the category fullname from grade_categories table.
179180
$gradecategory = $DB->get_record("grade_categories",
180-
array("id" => $gradeitem->iteminstance));
181+
["id" => $gradeitem->iteminstance]);
181182
$mform->addElement('text', $elname, $gradecategory->fullname);
182183
$mform->setType($elname, PARAM_RAW);
183184
$mform->setDefault($elname, $gradeitem->idnumber);
@@ -203,6 +204,7 @@ public function definition() {
203204
}
204205
}
205206

207+
#[\Override]
206208
// Perform some extra moodle validation.
207209
public function validation($data, $files) {
208210

@@ -226,7 +228,7 @@ public function validation($data, $files) {
226228
}
227229
ksort($data['idnumber']['cm']);
228230

229-
$errors = array();
231+
$errors = [];
230232
$cmidnumbers = $data['idnumber']['cm']; // Array for course module id numbers.
231233
if (!empty($cmidnumbers)) {
232234
$possibleduplicates = $cmidnumbers;

0 commit comments

Comments
 (0)