Skip to content

Commit 88db9f8

Browse files
committed
New release 0.1.7
Also: - Improve markdown - Fix coding style
1 parent 2fc8146 commit 88db9f8

File tree

7 files changed

+53
-47
lines changed

7 files changed

+53
-47
lines changed

CHANGES.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
1-
# VERSIONS HISTORY #
1+
# VERSIONS HISTORY
2+
3+
## Changes in version 0.1.7 (20250120) - I'm still alive
4+
5+
- Add Moodle 4.4 and 4.5 support
6+
- Replace deprecated calls
7+
- Improve markdown and fix coding style
8+
9+
## Changes in version 0.1.6 (20240111) - RIP master
210

3-
Changes in version 0.1.6 (20240111) - RIP master
4-
---------------------------------------------------
511
- Move from master to main (#51)
612
- Bump GHA environments
713

8-
Changes in version 0.1.5 (20221129) - I'm now stable!
9-
---------------------------------------------------
14+
## Changes in version 0.1.5 (20221129) - I'm now stable
15+
1016
- Include author, if possible, when migrating to content bank (#46)
1117
- Fix SQL limit with Oracle (#34)
1218

1319
Thanks to Jonathan Harker from Catalyst and all the contributors who have created issues, fixes and improvements.
1420

15-
Changes in version 0.1.4 (20210204) - Let's make it better!
16-
---------------------------------------------------
21+
## Changes in version 0.1.4 (20210204) - Let's make it better
22+
1723
- Copy completion information related to grades too (#27)
1824
- Check if contentbank repository is enabled or not (#30)
1925
- Check required plugins are enabled (#32)
2026
- Create manually CB file when it is null (#25)
2127
- Other fixes and improvements:
22-
* Add GitHub action support (#22)
28+
- Add GitHub action support (#22)
2329

2430
Thanks to Jordan, Ramon Ovelar, Adrian Perez and all the contributors who have created issues, fixes and improvements.
2531

26-
Changes in version 0.1.3 (2020121100) - Hurray project week!
27-
---------------------------------------------------
32+
## Changes in version 0.1.3 (2020121100) - Hurray project week
33+
2834
- Let admins copy files to content bank too (#11)
2935
- Migrate depending on a subset of content-types (#19)
3036
- Allow async module deletes (#14)
3137
- Other fixes and improvements:
32-
* Set grade type to None when maxgrade is 0 (#7)
33-
* Rawscore and maxscore can not be null (#8)
38+
- Set grade type to None when maxgrade is 0 (#7)
39+
- Rawscore and maxscore can not be null (#8)
3440

3541
Thanks to Eric Merrill, GaRaOne and Alexander Bias and all the contributors who have created issues, fixes and improvements.
3642

37-
Changes in version 0.1.2 (2020062400) - Welcome Beta
38-
---------------------------------------------------
43+
## Changes in version 0.1.2 (2020062400) - Welcome Beta
44+
3945
- Some migration errors fixes:
40-
* Use "enable skipping" from the competency API to avoid migration failed error (#1)
41-
* Set contextid properly in event trigger (#3)
42-
* Replace wrong table name and hardcoded prefix
46+
- Use "enable skipping" from the competency API to avoid migration failed error (#1)
47+
- Set contextid properly in event trigger (#3)
48+
- Replace wrong table name and hardcoded prefix

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
# Migrate mod_hvp to mod_h5pactivity #
1+
# Migrate mod_hvp to mod_h5pactivity
22

33
[![Moodle Plugin CI](https://github.com/moodlehq/moodle-tool_migratehvp2h5p/actions/workflows/ci.yml/badge.svg)](https://github.com/moodlehq/moodle-tool_migratehvp2h5p/actions/workflows/ci.yml)
44

5-
65
Moodle plugin allowing to migrate activities created with the mod_hvp plugin created by Joubel to the new mod_h5pactivity created by Moodle HQ since Moodle 3.9.
76

87
Some limitations to consider before using this plugin:
98

109
* Currently it's still not possible to save the current status with the mod_h5pactivity. The mod_hvp supports it (although it's disabled by default) so, before migrating the activities, consider students might loose these unfinished attempts.
1110
* The new mod_h5pactivity hasn't any global settings to define the default behaviour so general settings defined in mod_hvp, such as the default display options or whether to use or not the hub, are not migrated.
1211

13-
# How to use this tool #
12+
## How to use this tool
1413

1514
There are two ways to execute the activity migration:
1615

@@ -23,7 +22,7 @@ By default, the CLI method will only migrate up to 100 hvp activities per execut
2322

2423
The tool will only migrate each hvp once. In case you need to re-migrate an hvp, just remove or rename the migrated h5p activity, this way the tool won't detect the hvp as migrated.
2524

26-
# Tool dependencies #
25+
## Tool dependencies
2726

2827
This tools requires both core H5P and the third party plugin (mod_hvp) installed in the system. The minimum requirements are:
2928

@@ -36,7 +35,7 @@ Apart from that, for adding contents to the content bank too (so it's not strict
3635
* H5P content type of the content bank enabled
3736
* Content bank repository enabled
3837

39-
## License ##
38+
### License
4039

4140
This program is free software: you can redistribute it and/or modify it under
4241
the terms of the GNU General Public License as published by the Free Software

classes/api.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@
5353
*/
5454
class api {
5555

56-
/** @var value to indicate the original hvp activity must be deleted after migration */
56+
/** @var int Value to indicate the original hvp activity must be deleted after migration */
5757
public const DELETEORIGINAL = 0;
5858

59-
/** @var value to indicate to keep the original hvp activity after migration */
59+
/** @var int Value to indicate to keep the original hvp activity after migration */
6060
public const KEEPORIGINAL = 1;
6161

62-
/** @var value to indicate to hide the original hvp activity after migration */
62+
/** @var int Value to indicate to hide the original hvp activity after migration */
6363
public const HIDEORIGINAL = 2;
6464

65-
/** @var value to indicate the original hvp activity must not be copied to content bank. */
65+
/** @var int Value to indicate the original hvp activity must not be copied to content bank. */
6666
public const COPY2CBNO = 0;
6767

68-
/** @var value to indicate the original hvp activity must be copied to content bank and then linked to the new activity. */
68+
/** @var int Value to indicate the original hvp activity must be copied to content bank and then linked to the new activity. */
6969
public const COPY2CBYESWITHLINK = 1;
7070

71-
/** @var value to indicate the original hvp activity must be copied to content bank too. */
71+
/** @var int Value to indicate the original hvp activity must be copied to content bank too. */
7272
public const COPY2CBYESWITHOUTLINK = 2;
7373

7474
/**
@@ -353,7 +353,7 @@ private static function create_mod_h5pactivity(stdClass $hvp, stdClass $hvpgrade
353353
$h5pactivity->gradeitem = self::duplicate_grade_item($hvpgradeitem, $h5pactivity);
354354

355355
// Update couse_module information.
356-
$h5pcm = self::add_course_module_to_section($hvpcm, $h5pactivity->cm->id);
356+
self::add_course_module_to_section($hvpcm, $h5pactivity->cm->id);
357357

358358
self::copy_tags($hvpcm, $h5pactivity);
359359
self::copy_competencies($hvpcm, $h5pactivity);
@@ -663,18 +663,18 @@ private static function duplicate_course_module(stdClass $cm, int $moduleid): st
663663
*
664664
* @param stdClass $hvpcm
665665
* @param int $h5pcmid
666-
* @return stdClass The course module object for the h5pactivity.
666+
* @return stdClass|null The course module object for the h5pactivity.
667667
*/
668-
private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcmid): stdClass {
668+
private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcmid): ?stdClass {
669669
global $DB;
670670

671671
$h5pcm = get_coursemodule_from_id('', $h5pcmid, $hvpcm->course);
672672
if (!$h5pcm) {
673-
return false;
673+
return null;
674674
}
675675
$section = $DB->get_record('course_sections', ['id' => $h5pcm->section]);
676676
if (!$section) {
677-
return false;
677+
return null;
678678
}
679679

680680
$h5pcm->section = course_add_cm_to_section($h5pcm->course, $h5pcm->id, $section->section, $hvpcm->id);

classes/event/hvp_migrated.php

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

2525
namespace tool_migratehvp2h5p\event;
2626

27+
use stdClass;
2728
use core\event\base;
2829

2930
/**
@@ -67,7 +68,7 @@ public static function get_name() {
6768
* Create event from record.
6869
*
6970
* @param stdClass $record
70-
* @return acceptance_created
71+
* @return hvp_migrated
7172
*/
7273
public static function create_from_record($record) {
7374
$event = static::create([
@@ -119,7 +120,7 @@ protected function validate_data() {
119120
/**
120121
* No mapping required for this event because this event is not backed up.
121122
*
122-
* @return bool
123+
* @return array
123124
*/
124125
public static function get_other_mapping() {
125126
$othermapped = [

classes/output/hvpactivities_table.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ protected function define_table_columns() {
8888

8989
$this->define_columns(array_keys($columnheaders));
9090
$this->define_headers(array_values($columnheaders));
91-
$this->column_class('id', 'd-none d-sm-table-cell');
92-
$this->column_class('contenttype', 'd-none d-sm-table-cell');
93-
$this->column_class('graded', 'd-none d-md-table-cell');
94-
$this->column_class('attempted', 'd-none d-md-table-cell');
95-
$this->column_class('savedstate', 'd-none d-md-table-cell');
91+
$this->column_class(array_search('id', $columnheaders), 'd-none d-sm-table-cell');
92+
$this->column_class(array_search('contenttype', $columnheaders), 'd-none d-sm-table-cell');
93+
$this->column_class(array_search('graded', $columnheaders), 'd-none d-md-table-cell');
94+
$this->column_class(array_search('attempted', $columnheaders), 'd-none d-md-table-cell');
95+
$this->column_class(array_search('savedstate', $columnheaders), 'd-none d-md-table-cell');
9696
}
9797

9898
/**
@@ -114,7 +114,7 @@ protected function define_table_configs() {
114114
* @param stdClass $data The row data.
115115
* @return string
116116
* @throws \moodle_exception
117-
* @throws coding_exception
117+
* @throws \coding_exception
118118
*/
119119
public function col_select(stdClass $data):string {
120120
global $OUTPUT;
@@ -139,7 +139,7 @@ public function col_select(stdClass $data):string {
139139
* @param stdClass $data The row data.
140140
* @return string
141141
* @throws \moodle_exception
142-
* @throws coding_exception
142+
* @throws \coding_exception
143143
*/
144144
public function col_graded(stdClass $data): string {
145145
global $DB;
@@ -158,7 +158,7 @@ public function col_graded(stdClass $data): string {
158158
* @param stdClass $data The row data.
159159
* @return string
160160
* @throws \moodle_exception
161-
* @throws coding_exception
161+
* @throws \coding_exception
162162
*/
163163
public function col_attempted(stdClass $data): string {
164164
global $DB;
@@ -177,7 +177,7 @@ public function col_attempted(stdClass $data): string {
177177
* @param stdClass $data The row data.
178178
* @return string
179179
* @throws \moodle_exception
180-
* @throws coding_exception
180+
* @throws \coding_exception
181181
*/
182182
public function col_name(stdClass $data): string {
183183
$url = new moodle_url('/mod/hvp/view.php', ['id' => $data->instanceid]);

classes/output/listnotmigrated.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
*/
4141
class listnotmigrated implements renderable, templatable {
4242

43-
/** @var data_requests_table $table The data requests table. */
43+
/** @var \tool_migratehvp2h5p\output\hvpactivities_table $table The data requests table. */
4444
protected $table;
4545

4646
/**
4747
* Contructor.
4848
*
49-
* @param hvpactivities_table $table The data requests table.
49+
* @param \tool_migratehvp2h5p\output\hvpactivities_table $table The data requests table.
5050
*/
5151
public function __construct(\tool_migratehvp2h5p\output\hvpactivities_table $table) {
5252
$this->table = $table;

tests/author_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function fake_hvp(stdClass $course): stdClass {
5151
if (empty($this->modid)) {
5252
$mod = $DB->get_record('modules', [ 'name' => 'hvp' ], '*', IGNORE_MISSING);
5353
if (empty($mod)) {
54-
$this->fail("The 'mod_hvp' plugin must be installed for these tests to succeed.");
54+
throw new \moodle_exception("The 'mod_hvp' plugin must be installed for these tests to succeed.");
5555
}
5656
$this->modid = $mod->id;
5757
}

0 commit comments

Comments
 (0)