Skip to content

Commit 93212e4

Browse files
author
Laur0r
authored
Merge pull request #300 from learnweb/update/m404
Update/m404
2 parents c9c969f + 028ab0f commit 93212e4

File tree

75 files changed

+1757
-960
lines changed

Some content is hidden

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

75 files changed

+1757
-960
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 32 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ jobs:
88

99
strategy:
1010
matrix:
11-
php: ['8.2']
12-
moodle-branch: ['MOODLE_403_STABLE']
11+
php: ['8.3']
12+
moodle-branch: ['MOODLE_404_STABLE']
1313
database: ['pgsql']
1414

1515
steps:
1616
- name: Start PostgreSQL
1717
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
1818

1919
- name: Check out repository code
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
path: plugin
2323

@@ -28,29 +28,9 @@ jobs:
2828
ini-values: max_input_vars=5000
2929
coverage: none
3030

31-
- name: Get composer cache directory
32-
id: composer-cache
33-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34-
35-
- name: Composer cache
36-
uses: actions/cache@v3
37-
with:
38-
path: ${{ steps.composer-cache.outputs.dir }}
39-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40-
restore-keys: |
41-
${{ runner.os }}-composer-
42-
43-
- name: npm cache
44-
uses: actions/cache@v3
45-
with:
46-
path: ~/.npm
47-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
48-
restore-keys: |
49-
${{ runner.os }}-node-
50-
5131
- name: Initialise moodle-plugin-ci
5232
run: |
53-
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
33+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
5434
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
5535
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
5636
sudo locale-gen en_AU.UTF-8
@@ -67,11 +47,6 @@ jobs:
6747
if: ${{ always() }}
6848
run: moodle-plugin-ci phplint
6949

70-
- name: PHP Copy/Paste Detector
71-
if: ${{ always() }}
72-
run: moodle-plugin-ci phpcpd
73-
continue-on-error: true
74-
7550
- name: PHP Mess Detector
7651
if: ${{ always() }}
7752
run: moodle-plugin-ci phpmd
@@ -108,19 +83,27 @@ jobs:
10883
strategy:
10984
fail-fast: false
11085
matrix:
111-
php: ['8.0', '8.1', '8.2']
112-
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE']
86+
php: ['8.0', '8.1', '8.2', '8.3']
87+
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE']
11388
database: ['mariadb', 'pgsql']
11489
exclude:
90+
- php: '8.0'
91+
moodle-branch: 'MOODLE_404_STABLE'
11592
- php: '8.2'
11693
moodle-branch: 'MOODLE_401_STABLE'
94+
- php: '8.3'
95+
moodle-branch: 'MOODLE_401_STABLE'
96+
- php: '8.3'
97+
moodle-branch: 'MOODLE_402_STABLE'
98+
- php: '8.3'
99+
moodle-branch: 'MOODLE_403_STABLE'
117100
include:
118-
- php: '8.0'
119-
moodle-branch: 'MOODLE_400_STABLE'
120-
database: 'mariadb'
121-
- php: '8.0'
122-
moodle-branch: 'MOODLE_400_STABLE'
101+
- php: '7.4'
102+
moodle-branch: 'MOODLE_401_STABLE'
123103
database: 'pgsql'
104+
- php: '7.4'
105+
moodle-branch: 'MOODLE_401_STABLE'
106+
database: 'mariadb'
124107

125108
steps:
126109
- name: Start MariaDB
@@ -132,7 +115,7 @@ jobs:
132115
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
133116

134117
- name: Check out repository code
135-
uses: actions/checkout@v3
118+
uses: actions/checkout@v4
136119
with:
137120
path: plugin
138121

@@ -143,24 +126,6 @@ jobs:
143126
ini-values: max_input_vars=5000
144127
coverage: none
145128

146-
- name: Get composer cache directory
147-
id: composer-cache
148-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
149-
- name: Composer cache
150-
uses: actions/cache@v3
151-
with:
152-
path: ${{ steps.composer-cache.outputs.dir }}
153-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
154-
restore-keys: |
155-
${{ runner.os }}-composer-
156-
- name: npm cache
157-
uses: actions/cache@v3
158-
with:
159-
path: ~/.npm
160-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
161-
restore-keys: |
162-
${{ runner.os }}-node-
163-
164129
- name: Initialise moodle-plugin-ci
165130
run: |
166131
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
@@ -183,3 +148,15 @@ jobs:
183148
- name: Behat features
184149
if: ${{ always() }}
185150
run: moodle-plugin-ci behat --profile chrome --auto-rerun 0
151+
152+
# This step allows to upload Behat faildump (screenshots) as workflow artifact,
153+
# so it can be downloaded and inspected. You do not need this step if you
154+
# are not running Behat test. Artifact will be retained for 7 days.
155+
- name: Upload Behat Faildump
156+
if: ${{ failure() && steps.behat.outcome == 'failure' }}
157+
uses: actions/upload-artifact@v4
158+
with:
159+
name: Behat Faildump (${{ join(matrix.*, ', ') }})
160+
path: ${{ github.workspace }}/moodledata/behat_dump
161+
retention-days: 7
162+
if-no-files-found: ignore

backup/moodle2/backup_ratingallocate_activity_stepslib.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ protected function define_structure() {
9393

9494
// Define sources.
9595
$ratingallocate->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate'),
96-
array(this_db\ratingallocate::ID => backup::VAR_ACTIVITYID), this_db\ratingallocate_choices::ID . ' ASC');
96+
[this_db\ratingallocate::ID => backup::VAR_ACTIVITYID], this_db\ratingallocate_choices::ID . ' ASC');
9797
$ratingallocatechoice->set_source_table(get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_choices'),
98-
array(this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID),
98+
[this_db\ratingallocate_choices::RATINGALLOCATEID => backup::VAR_PARENTID],
9999
this_db\ratingallocate_choices::ID . ' ASC');
100100
$groupchoice->set_source_table(get_tablename_for_tableClass($groupchoiceclass), ['choiceid' => backup::VAR_PARENTID]);
101101
$ratingallocatechoicegroup->set_source_table(
@@ -106,13 +106,14 @@ protected function define_structure() {
106106
if ($userinfo) {
107107
$ratingallocaterating->set_source_table(get_tablename_for_tableClass(
108108
'mod_ratingallocate\db\ratingallocate_ratings'),
109-
array(this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID),
109+
[this_db\ratingallocate_ratings::CHOICEID => backup::VAR_PARENTID],
110110
this_db\ratingallocate_ratings::ID . ' ASC');
111111
$ratingallocateallocation->set_source_table(
112112
get_tablename_for_tableClass('mod_ratingallocate\db\ratingallocate_allocations'),
113-
array(
114-
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
115-
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID),
113+
[
114+
this_db\ratingallocate_allocations::RATINGALLOCATEID => backup::VAR_ACTIVITYID,
115+
this_db\ratingallocate_allocations::CHOICEID => backup::VAR_PARENTID,
116+
],
116117
this_db\ratingallocate_allocations::ID . ' ASC'
117118
);
118119
}

backup/moodle2/backup_restore_helper.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,55 @@
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

1717
/**
18-
* @package moodlecore
18+
* Backup restore helper.
19+
*
20+
* @package mod_ratingallocate
1921
* @subpackage backup-moodle2
2022
* @copyright 2014 C. Usener
2123
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2224
*/
2325

26+
/**
27+
* Get fields for tableclass
28+
*
29+
* @param $class
30+
* @return array
31+
* @throws ReflectionException
32+
*/
2433
function get_fields_for_tableclass($class) {
2534
$class = new ReflectionClass($class);
2635
$constants = $class->getConstants();
27-
$keystoremove = array('ID', 'TABLE');
36+
$keystoremove = ['ID', 'TABLE'];
2837
foreach ($constants as $key => $value) {
29-
if (count(array_intersect(array($key), $keystoremove)) > 0) {
38+
if (count(array_intersect([$key], $keystoremove)) > 0) {
3039
unset($constants[$key]);
3140
}
3241
}
3342
return array_values($constants);
3443
}
3544

45+
/**
46+
* Get tablename for tableclass.
47+
*
48+
* @param $class
49+
* @return mixed
50+
* @throws ReflectionException
51+
*/
3652
function get_tablename_for_tableclass($class) {
3753
$class = new ReflectionClass($class);
3854
$constants = $class->getConstants();
3955
return $constants['TABLE'];
4056
}
4157

58+
/**
59+
* Get id for tableclass.
60+
*
61+
* @param $class
62+
* @return array
63+
* @throws ReflectionException
64+
*/
4265
function get_id_for_tableclass($class) {
4366
$class = new ReflectionClass($class);
4467
$constants = $class->getConstants();
45-
return array($constants['ID']);
68+
return [$constants['ID']];
4669
}

backup/moodle2/restore_ratingallocate_activity_stepslib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/**
2020
*
21-
* @package moodlecore
21+
* @package mod_ratingallocate
2222
* @subpackage backup-moodle2
2323
* @copyright 2014 C. Usener
2424
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

backup/moodle2/restore_ratingallocate_activity_task.class.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
*/
2828
require_once($CFG->dirroot . '/mod/ratingallocate/backup/moodle2/restore_ratingallocate_activity_stepslib.php');
2929

30+
/**
31+
* Restore ratingallocate activity class
32+
*
33+
* @package mod_ratingallocate
34+
* @copyright 214 C. Usener
35+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36+
*/
3037
class restore_ratingallocate_activity_task extends restore_activity_task {
3138

3239
/**
@@ -49,7 +56,7 @@ protected function define_my_steps() {
4956
* processed by the link decoder
5057
*/
5158
public static function define_decode_contents() {
52-
$contents = array();
59+
$contents = [];
5360

5461
return $contents;
5562
}
@@ -59,7 +66,7 @@ public static function define_decode_contents() {
5966
* to the activity to be executed by the link decoder
6067
*/
6168
public static function define_decode_rules() {
62-
$rules = array();
69+
$rules = [];
6370

6471
return $rules;
6572
}
@@ -72,7 +79,7 @@ public static function define_decode_rules() {
7279
* of {@link restore_log_rule} objects
7380
*/
7481
public static function define_restore_log_rules() {
75-
$rules = array();
82+
$rules = [];
7683

7784
return $rules;
7885
}
@@ -89,7 +96,7 @@ public static function define_restore_log_rules() {
8996
* activity level. All them are rules not linked to any module instance (cmid = 0)
9097
*/
9198
public static function define_restore_log_rules_for_course() {
92-
$rules = array();
99+
$rules = [];
93100
return $rules;
94101
}
95102
}

classes/algorithm_status.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,20 @@
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
2525
class algorithm_status {
26-
const FAILURE = -1; // Algorithm did not finish correctly.
27-
const NOTSTARTED = 0; // Default status for new instances.
28-
const RUNNING = 1; // Algorithm is currently running.
29-
const FINISHED = 2; // Algorithm finished correctly.
26+
/**
27+
* Algorithm did not finish correctly.
28+
*/
29+
const FAILURE = -1;
30+
/**
31+
* Default status for new instances.
32+
*/
33+
const NOTSTARTED = 0;
34+
/**
35+
* Algorithm is currently running.
36+
*/
37+
const RUNNING = 1;
38+
/**
39+
* Algorithm finished correctly.
40+
*/
41+
const FINISHED = 2;
3042
}

classes/allocations_table.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
require_once($CFG->libdir . '/tablelib.php');
3030
require_once($CFG->dirroot . '/user/lib.php');
3131

32+
/**
33+
* Allocations table.
34+
*
35+
* @package mod_ratingallocate
36+
*/
3237
class allocations_table extends \table_sql {
3338

3439
/**
@@ -44,7 +49,7 @@ public function __construct($ratingallocate) {
4449
parent::__construct('mod_ratingallocate_allocation_table');
4550
global $PAGE;
4651
$url = $PAGE->url;
47-
$url->params(array("action" => ACTION_SHOW_ALLOCATION_TABLE));
52+
$url->params(["action" => ACTION_SHOW_ALLOCATION_TABLE]);
4853
$PAGE->set_url($url);
4954
$this->ratingallocate = $ratingallocate;
5055
if (has_capability('mod/ratingallocate:export_ratings', $ratingallocate->get_context())) {
@@ -203,10 +208,10 @@ private function get_user_link($user) {
203208
$name = fullname($user);
204209

205210
if ($COURSE->id == SITEID) {
206-
$profileurl = new \moodle_url('/user/profile.php', array('id' => $user->id));
211+
$profileurl = new \moodle_url('/user/profile.php', ['id' => $user->id]);
207212
} else {
208213
$profileurl = new \moodle_url('/user/view.php',
209-
array('id' => $user->id, 'course' => $COURSE->id));
214+
['id' => $user->id, 'course' => $COURSE->id]);
210215
}
211216
return \html_writer::link($profileurl, $name);
212217
}
@@ -229,7 +234,7 @@ public function init_sql() {
229234

230235
$where = "c.ratingallocateid = :ratingallocateid";
231236

232-
$params = array();
237+
$params = [];
233238
$params['ratingallocateid'] = $this->ratingallocate->ratingallocate->id;
234239

235240
$this->set_sql($fields, $from, $where, $params);

0 commit comments

Comments
 (0)