Skip to content

Commit

Permalink
New release 0.1.7
Browse files Browse the repository at this point in the history
Also:
- Improve markdown
- Fix coding style
  • Loading branch information
sarjona committed Jan 20, 2025
1 parent 2fc8146 commit 88db9f8
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 47 deletions.
40 changes: 23 additions & 17 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
# VERSIONS HISTORY #
# VERSIONS HISTORY

## Changes in version 0.1.7 (20250120) - I'm still alive

- Add Moodle 4.4 and 4.5 support
- Replace deprecated calls
- Improve markdown and fix coding style

## Changes in version 0.1.6 (20240111) - RIP master

Changes in version 0.1.6 (20240111) - RIP master
---------------------------------------------------
- Move from master to main (#51)
- Bump GHA environments

Changes in version 0.1.5 (20221129) - I'm now stable!
---------------------------------------------------
## Changes in version 0.1.5 (20221129) - I'm now stable

- Include author, if possible, when migrating to content bank (#46)
- Fix SQL limit with Oracle (#34)

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

Changes in version 0.1.4 (20210204) - Let's make it better!
---------------------------------------------------
## Changes in version 0.1.4 (20210204) - Let's make it better

- Copy completion information related to grades too (#27)
- Check if contentbank repository is enabled or not (#30)
- Check required plugins are enabled (#32)
- Create manually CB file when it is null (#25)
- Other fixes and improvements:
* Add GitHub action support (#22)
- Add GitHub action support (#22)

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

Changes in version 0.1.3 (2020121100) - Hurray project week!
---------------------------------------------------
## Changes in version 0.1.3 (2020121100) - Hurray project week

- Let admins copy files to content bank too (#11)
- Migrate depending on a subset of content-types (#19)
- Allow async module deletes (#14)
- Other fixes and improvements:
* Set grade type to None when maxgrade is 0 (#7)
* Rawscore and maxscore can not be null (#8)
- Set grade type to None when maxgrade is 0 (#7)
- Rawscore and maxscore can not be null (#8)

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

Changes in version 0.1.2 (2020062400) - Welcome Beta
---------------------------------------------------
## Changes in version 0.1.2 (2020062400) - Welcome Beta

- Some migration errors fixes:
* Use "enable skipping" from the competency API to avoid migration failed error (#1)
* Set contextid properly in event trigger (#3)
* Replace wrong table name and hardcoded prefix
- Use "enable skipping" from the competency API to avoid migration failed error (#1)
- Set contextid properly in event trigger (#3)
- Replace wrong table name and hardcoded prefix
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Migrate mod_hvp to mod_h5pactivity #
# Migrate mod_hvp to mod_h5pactivity

[![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)


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.

Some limitations to consider before using this plugin:

* 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.
* 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.

# How to use this tool #
## How to use this tool

There are two ways to execute the activity migration:

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

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.

# Tool dependencies #
## Tool dependencies

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

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

## License ##
### License

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down
22 changes: 11 additions & 11 deletions classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@
*/
class api {

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

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

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

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

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

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

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

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

self::copy_tags($hvpcm, $h5pactivity);
self::copy_competencies($hvpcm, $h5pactivity);
Expand Down Expand Up @@ -663,18 +663,18 @@ private static function duplicate_course_module(stdClass $cm, int $moduleid): st
*
* @param stdClass $hvpcm
* @param int $h5pcmid
* @return stdClass The course module object for the h5pactivity.
* @return stdClass|null The course module object for the h5pactivity.
*/
private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcmid): stdClass {
private static function add_course_module_to_section(stdClass $hvpcm, int $h5pcmid): ?stdClass {
global $DB;

$h5pcm = get_coursemodule_from_id('', $h5pcmid, $hvpcm->course);
if (!$h5pcm) {
return false;
return null;
}
$section = $DB->get_record('course_sections', ['id' => $h5pcm->section]);
if (!$section) {
return false;
return null;
}

$h5pcm->section = course_add_cm_to_section($h5pcm->course, $h5pcm->id, $section->section, $hvpcm->id);
Expand Down
5 changes: 3 additions & 2 deletions classes/event/hvp_migrated.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace tool_migratehvp2h5p\event;

use stdClass;
use core\event\base;

/**
Expand Down Expand Up @@ -67,7 +68,7 @@ public static function get_name() {
* Create event from record.
*
* @param stdClass $record
* @return acceptance_created
* @return hvp_migrated
*/
public static function create_from_record($record) {
$event = static::create([
Expand Down Expand Up @@ -119,7 +120,7 @@ protected function validate_data() {
/**
* No mapping required for this event because this event is not backed up.
*
* @return bool
* @return array
*/
public static function get_other_mapping() {
$othermapped = [
Expand Down
18 changes: 9 additions & 9 deletions classes/output/hvpactivities_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ protected function define_table_columns() {

$this->define_columns(array_keys($columnheaders));
$this->define_headers(array_values($columnheaders));
$this->column_class('id', 'd-none d-sm-table-cell');
$this->column_class('contenttype', 'd-none d-sm-table-cell');
$this->column_class('graded', 'd-none d-md-table-cell');
$this->column_class('attempted', 'd-none d-md-table-cell');
$this->column_class('savedstate', 'd-none d-md-table-cell');
$this->column_class(array_search('id', $columnheaders), 'd-none d-sm-table-cell');
$this->column_class(array_search('contenttype', $columnheaders), 'd-none d-sm-table-cell');
$this->column_class(array_search('graded', $columnheaders), 'd-none d-md-table-cell');
$this->column_class(array_search('attempted', $columnheaders), 'd-none d-md-table-cell');
$this->column_class(array_search('savedstate', $columnheaders), 'd-none d-md-table-cell');
}

/**
Expand All @@ -114,7 +114,7 @@ protected function define_table_configs() {
* @param stdClass $data The row data.
* @return string
* @throws \moodle_exception
* @throws coding_exception
* @throws \coding_exception
*/
public function col_select(stdClass $data):string {
global $OUTPUT;
Expand All @@ -139,7 +139,7 @@ public function col_select(stdClass $data):string {
* @param stdClass $data The row data.
* @return string
* @throws \moodle_exception
* @throws coding_exception
* @throws \coding_exception
*/
public function col_graded(stdClass $data): string {
global $DB;
Expand All @@ -158,7 +158,7 @@ public function col_graded(stdClass $data): string {
* @param stdClass $data The row data.
* @return string
* @throws \moodle_exception
* @throws coding_exception
* @throws \coding_exception
*/
public function col_attempted(stdClass $data): string {
global $DB;
Expand All @@ -177,7 +177,7 @@ public function col_attempted(stdClass $data): string {
* @param stdClass $data The row data.
* @return string
* @throws \moodle_exception
* @throws coding_exception
* @throws \coding_exception
*/
public function col_name(stdClass $data): string {
$url = new moodle_url('/mod/hvp/view.php', ['id' => $data->instanceid]);
Expand Down
4 changes: 2 additions & 2 deletions classes/output/listnotmigrated.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
*/
class listnotmigrated implements renderable, templatable {

/** @var data_requests_table $table The data requests table. */
/** @var \tool_migratehvp2h5p\output\hvpactivities_table $table The data requests table. */
protected $table;

/**
* Contructor.
*
* @param hvpactivities_table $table The data requests table.
* @param \tool_migratehvp2h5p\output\hvpactivities_table $table The data requests table.
*/
public function __construct(\tool_migratehvp2h5p\output\hvpactivities_table $table) {
$this->table = $table;
Expand Down
2 changes: 1 addition & 1 deletion tests/author_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private function fake_hvp(stdClass $course): stdClass {
if (empty($this->modid)) {
$mod = $DB->get_record('modules', [ 'name' => 'hvp' ], '*', IGNORE_MISSING);
if (empty($mod)) {
$this->fail("The 'mod_hvp' plugin must be installed for these tests to succeed.");
throw new \moodle_exception("The 'mod_hvp' plugin must be installed for these tests to succeed.");
}
$this->modid = $mod->id;
}
Expand Down

0 comments on commit 88db9f8

Please sign in to comment.