Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding resizer backup and restore step #499

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backup/moodle2/backup_hvp_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ static public function encode_content_links($content) {
$search = "/(".$base."\/mod\/hvp\/embed.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@HVPEMBEDBYID*$2@$', $content);

// Link to hvp resizer script
$search = "/(".$base."\/mod\/hvp\/library\/js\/h5p-resizer.js)/";
$content = preg_replace($search,'$@HVPRESIZER@$', $content);

return $content;
}
}
19 changes: 19 additions & 0 deletions backup/moodle2/restore_decode_rule_h5p_url.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
class restore_decode_rule_h5p_url extends restore_decode_rule {

/**
* This class exists so that restore can run over URLs to H5P Scripts which
* do not have an id referencing the course / course module - their soley static
* scripts used across the activity - e.g. h5p-resizer.js - this is included when
* embedding a h5p activity, but not specific to an activity - the url still needs
* to be replaced with one relevant to the new restore site.
*
* @param $linkname
* @param $urltemplate
* @param $mappings
* @return array
*/
protected function validate_params($linkname, $urltemplate, $mappings) {
return [];
}
}
3 changes: 3 additions & 0 deletions backup/moodle2/restore_hvp_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/mod/hvp/backup/moodle2/restore_hvp_stepslib.php'); // Because it exists (must).
require_once($CFG->dirroot . '/mod/hvp/backup/moodle2/restore_decode_rule_h5p_url.class.php');

/**
* Hvp restore task that provides all the settings and steps to perform one complete restore of the activity.
Expand Down Expand Up @@ -75,6 +77,7 @@ static public function define_decode_rules() {
$rules[] = new restore_decode_rule('HVPVIEWBYID', '/mod/hvp/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('HVPINDEX', '/mod/hvp/index.php?id=$1', 'course');
$rules[] = new restore_decode_rule('HVPEMBEDBYID', '/mod/hvp/embed.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule_h5p_url('HVPRESIZER', '/mod/hvp/library/js/h5p-resizer.js', []);

return $rules;
}
Expand Down