Skip to content

Commit 6ddab83

Browse files
roland04sarjona
authored andcommitted
Fix CI errors
1 parent af1da96 commit 6ddab83

File tree

7 files changed

+60
-33
lines changed

7 files changed

+60
-33
lines changed

classes/api.php

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ class api {
8080
* @return array Messages to be displayed (related to the migration process).
8181
* @throws moodle_exception if something happens during the migration
8282
*/
83-
public static function migrate_hvp2h5p(int $hvpid, int $keeporiginal = self::KEEPORIGINAL,
84-
int $copy2cb = self::COPY2CBYESWITHLINK): array {
83+
public static function migrate_hvp2h5p(
84+
int $hvpid,
85+
int $keeporiginal = self::KEEPORIGINAL,
86+
int $copy2cb = self::COPY2CBYESWITHLINK
87+
): array {
8588
global $DB;
8689

8790
self::check_requirements($copy2cb);
@@ -126,12 +129,12 @@ public static function migrate_hvp2h5p(int $hvpid, int $keeporiginal = self::KEE
126129
$tmpkeeporiginal = self::HIDEORIGINAL;
127130
$messages[] = [
128131
get_string('migrate_gradesoverridden_notdelete', 'tool_migratehvp2h5p', $params),
129-
notification::NOTIFY_WARNING
132+
notification::NOTIFY_WARNING,
130133
];
131134
} else {
132135
$messages[] = [
133136
get_string('migrate_gradesoverridden', 'tool_migratehvp2h5p', $params),
134-
notification::NOTIFY_WARNING
137+
notification::NOTIFY_WARNING,
135138
];
136139
}
137140
}
@@ -183,13 +186,17 @@ public static function check_requirements(int $copy2cb) {
183186
* the CLI migrate.php command. The SQL is quite complex so having it in one place
184187
* is a good idea.
185188
*
186-
* @param bool $count when true, returns the count SQL.
187-
* @param string $sort sorting criteria.
188-
* @param array $libraryids List of the library ids for the mod_hvp contents to migrate. Only contents with these
189+
* @param bool $count when true, returns the count SQL.
190+
* @param string|null $sort sorting criteria.
191+
* @param array|null $libraryids List of the library ids for the mod_hvp contents to migrate. Only contents with these
189192
* main libraries will be returned.
190193
* @return array containing sql to use and an array of params.
191194
*/
192-
public static function get_sql_hvp_to_migrate(bool $count = false, ?string $sort = null, ?array $libraryids = null): array {
195+
public static function get_sql_hvp_to_migrate(
196+
bool $count = false,
197+
?string $sort = null,
198+
?array $libraryids = null
199+
): array {
193200

194201
self::fix_duplicated_hvp();
195202

@@ -292,12 +299,16 @@ private static function fix_duplicated_hvp(): void {
292299
/**
293300
* Create an h5pactivity copying information from the existing $hvp activity.
294301
*
295-
* @param stdClass $hvp The mod_hvp activity to be migrated from.
296-
* @param stdClass $hvpgradeitem This information is required to update the h5pactivity grading information.
297-
* @param int $copy2cb Whether H5P files should be added to the content bank or not.
302+
* @param stdClass $hvp The mod_hvp activity to be migrated from.
303+
* @param stdClass $hvpgradeitem This information is required to update the h5pactivity grading information.
304+
* @param int $copy2cb Whether H5P files should be added to the content bank or not.
298305
* @return stdClass|null The new h5pactivity created from the $hvp activity.
299306
*/
300-
private static function create_mod_h5pactivity(stdClass $hvp, stdClass $hvpgradeitem, int $copy2cb): ?stdClass {
307+
private static function create_mod_h5pactivity(
308+
stdClass $hvp,
309+
stdClass $hvpgradeitem,
310+
int $copy2cb
311+
): ?stdClass {
301312
global $CFG, $DB;
302313

303314
require_once($CFG->dirroot . '/mod/h5pactivity/lib.php');
@@ -368,7 +379,7 @@ private static function create_mod_h5pactivity(stdClass $hvp, stdClass $hvpgrade
368379
* @param stdClass $hvpcm the hvp course_module
369380
* @param stdClass $h5pactivity the new activity object
370381
*/
371-
private static function copy_tags($hvpcm, $h5pactivity): void {
382+
private static function copy_tags(stdClass $hvpcm, stdClass $h5pactivity): void {
372383
$tags = core_tag_tag::get_item_tags_array('core', 'course_modules', $hvpcm->id);
373384
$h5pcontext = context_module::instance($h5pactivity->coursemodule);
374385
core_tag_tag::set_item_tags('core', 'course_modules', $h5pactivity->coursemodule, $h5pcontext, $tags);
@@ -478,7 +489,7 @@ public static function get_hvp_author(stdClass $hvp): string {
478489
* @param stdClass $hvpcm the hvp course_module
479490
* @param stdClass $h5pactivity the new activity object
480491
*/
481-
private static function copy_completion($hvpcm, $h5pactivity): void {
492+
private static function copy_completion(stdClass $hvpcm, stdClass $h5pactivity): void {
482493
$course = get_course($hvpcm->course);
483494
$completion = new completion_info($course);
484495
if ($completion->is_enabled($hvpcm)) {
@@ -662,7 +673,7 @@ private static function duplicate_course_module(stdClass $cm, int $moduleid): st
662673
* Add the course module to the course section.
663674
*
664675
* @param stdClass $hvpcm
665-
* @param int $h5pcmid
676+
* @param int $h5pcmid
666677
* @return stdClass|null The course module object for the h5pactivity.
667678
*/
668679
private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcmid): ?stdClass {
@@ -693,7 +704,11 @@ private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcm
693704
* @param stdClass $h5pactivity mod_h5p object
694705
* @return int total of files copied.
695706
*/
696-
private static function copy_area_files(stdClass $hvp, stdClass $hvpcm, stdClass $h5pactivity): int {
707+
private static function copy_area_files(
708+
stdClass $hvp,
709+
stdClass $hvpcm,
710+
stdClass $h5pactivity
711+
): int {
697712
$count = 0;
698713

699714
$hvpcontext = context_module::instance($hvpcm->id);

classes/event/hvp_migrated.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ protected function validate_data() {
124124
*/
125125
public static function get_other_mapping() {
126126
$othermapped = [
127-
'h5pactivityid' => ['db' => 'h5pactivity', 'restore' => 'h5pactivity']
127+
'h5pactivityid' => [
128+
'db' => 'h5pactivity',
129+
'restore' => 'h5pactivity',
130+
],
128131
];
129132

130133
return $othermapped;

classes/output/hvpactivities_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function define_table_configs() {
116116
* @throws \moodle_exception
117117
* @throws \coding_exception
118118
*/
119-
public function col_select(stdClass $data):string {
119+
public function col_select(stdClass $data): string {
120120
global $OUTPUT;
121121

122122
$stringdata = [

classes/output/listnotmigrated.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,35 @@ public function export_for_template(renderer_base $output): stdClass {
6666
'name' => 'keeporiginal',
6767
'label' => get_string('keeporiginal', 'tool_migratehvp2h5p'),
6868
'options' => [
69-
['value' => api::HIDEORIGINAL, 'text' => get_string('keeporiginal_hide', 'tool_migratehvp2h5p')],
70-
['value' => api::DELETEORIGINAL, 'text' => get_string('keeporiginal_delete', 'tool_migratehvp2h5p')],
71-
['value' => api::KEEPORIGINAL, 'text' => get_string('keeporiginal_nothing', 'tool_migratehvp2h5p')],
72-
]
69+
[
70+
'value' => api::HIDEORIGINAL,
71+
'text' => get_string('keeporiginal_hide', 'tool_migratehvp2h5p'),
72+
],
73+
[
74+
'value' => api::DELETEORIGINAL,
75+
'text' => get_string('keeporiginal_delete', 'tool_migratehvp2h5p'),
76+
],
77+
[
78+
'value' => api::KEEPORIGINAL,
79+
'text' => get_string('keeporiginal_nothing', 'tool_migratehvp2h5p'),
80+
],
81+
],
7382
],
7483
[
7584
'name' => 'copy2cb',
7685
'label' => get_string('copy2cb', 'tool_migratehvp2h5p'),
7786
'options' => [
7887
[
7988
'value' => api::COPY2CBYESWITHLINK,
80-
'text' => get_string('copy2cb_yeswithlink', 'tool_migratehvp2h5p')
89+
'text' => get_string('copy2cb_yeswithlink', 'tool_migratehvp2h5p'),
8190
],
8291
[
8392
'value' => api::COPY2CBYESWITHOUTLINK,
84-
'text' => get_string('copy2cb_yeswithoutlink', 'tool_migratehvp2h5p')
93+
'text' => get_string('copy2cb_yeswithoutlink', 'tool_migratehvp2h5p'),
8594
],
8695
[
8796
'value' => api::COPY2CBNO,
88-
'text' => get_string('copy2cb_no', 'tool_migratehvp2h5p')
97+
'text' => get_string('copy2cb_no', 'tool_migratehvp2h5p'),
8998
],
9099
],
91100
],

classes/privacy/provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
3838
*
3939
* @return string
4040
*/
41-
public static function get_reason() : string {
41+
public static function get_reason(): string {
4242
return 'privacy:metadata';
4343
}
4444
}

lang/en/tool_migratehvp2h5p.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
$string['cannot_migrate'] = 'Cannot migrate the activity';
3030
$string['contenttype'] = 'Content-type';
3131
$string['copy2cb'] = 'Should these contents be added to the content bank?';
32+
$string['copy2cb_no'] = 'No, they should be only created in the activity.';
3233
$string['copy2cb_yeswithlink'] = 'Yes, and a link to these files should be used in the activity';
3334
$string['copy2cb_yeswithoutlink'] = 'Yes, but a copy will be used in the activity (changes in the content bank won\'t be reflected in the activity)';
34-
$string['copy2cb_no'] = 'No, they should be only created in the activity.';
3535
$string['error_contenttypeh5p_disabled'] = "H5P contentbank type is disabled. It must be enabled to migrate activities from mod_hvp
3636
and add them to the content bank too. You can enable this contentytype from 'Site administration | Plugins | Content bank | Manage
3737
content types' or run again the migration tool and select 'No, they should be only created in the activity.' (or 'copy2cb=0' if
@@ -41,8 +41,11 @@
4141
$string['graded'] = 'Graded users';
4242
$string['hvpactivities'] = 'Pending mod_hvp activities';
4343
$string['id'] = 'Id';
44+
$string['keeporiginal'] = 'Select what to do with the original activity once migrated';
45+
$string['keeporiginal_delete'] = 'Delete the original activity';
46+
$string['keeporiginal_hide'] = 'Hide the original activity';
47+
$string['keeporiginal_nothing'] = 'Leave the original activity as it is';
4448
$string['migrate'] = 'Migrate';
45-
$string['migrate_success'] = 'Hvp activity with id {$a} migrated successfully';
4649
$string['migrate_fail'] = 'Error migrating hvp activity with id {$a}';
4750
$string['migrate_gradesoverridden'] = 'Original mod_hvp activity "{$a->name}", with id {$a->id}, migrated successfully. However,
4851
it has some grading information overridden, such as feedback, which hasn\'t been migrated because the original activity is
@@ -51,12 +54,9 @@
5154
However, it has some grading information overridden, such as feedback, which hasn\'t been migrated because the original activity
5255
is configured with an invalid maximum grade (it has to be higher than 0 in order to be migrated to the gradebook).
5356
The original activity has been hidden instead of removing it.';
57+
$string['migrate_success'] = 'Hvp activity with id {$a} migrated successfully';
5458
$string['nohvpactivities'] = 'There are no mod_hvp activities to migrate to the mod_h5pactivity.';
5559
$string['pluginname'] = 'Migrate content from mod_hvp to mod_h5pactivity';
56-
$string['keeporiginal'] = 'Select what to do with the original activity once migrated';
57-
$string['keeporiginal_hide'] = 'Hide the original activity';
58-
$string['keeporiginal_delete'] = 'Delete the original activity';
59-
$string['keeporiginal_nothing'] = 'Leave the original activity as it is';
6060
$string['privacy:metadata'] = 'Migrate content from mod_hvp to mod_h5pactivity does not store any personal data';
6161
$string['savedstate'] = 'Saved state';
6262
$string['selecthvpactivity'] = 'Select {$a} mod_hvp activity';

tests/author_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3131
* @coversDefaultClass \tool_migratehvp2h5p\api
3232
*/
33-
class author_test extends advanced_testcase {
33+
final class author_test extends advanced_testcase {
3434

3535
/**
3636
* @var int The HVP module id.

0 commit comments

Comments
 (0)