Merge branch 'MDL-84264-main' of https://github.com/pmaneggia/moodle

This commit is contained in:
Sara Arjona 2025-01-29 16:52:52 +01:00
commit ff0e03ff56
No known key found for this signature in database
3 changed files with 8 additions and 2 deletions

View File

@ -157,6 +157,7 @@ class backup_course_task extends backup_task {
// Link to the course main page (it also covers "&topic=xx" and "&week=xx"
// because they don't become transformed (section number) in backup/restore.
$content = self::encode_links_helper($content, 'COURSEVIEWBYID', '/course/view.php?id=');
$content = self::encode_links_helper($content, 'COURSESECTIONBYID', '/course/section.php?id=');
// A few other key course links.
$content = self::encode_links_helper($content, 'GRADEINDEXBYID', '/grade/index.php?id=');

View File

@ -160,6 +160,7 @@ class restore_course_task extends restore_task {
// Link to the course main page (it also covers "&topic=xx" and "&week=xx"
// because they don't become transformed (section number) in backup/restore.
$rules[] = new restore_decode_rule('COURSEVIEWBYID', '/course/view.php?id=$1', 'course');
$rules[] = new restore_decode_rule('COURSESECTIONBYID', '/course/section.php?id=$1', 'course_section');
// A few other key course links.
$rules[] = new restore_decode_rule('GRADEINDEXBYID', '/grade/index.php?id=$1', 'course');

View File

@ -52,6 +52,7 @@ final class backup_encode_content_test extends \basic_testcase {
$encoded = backup_course_task::encode_content_links(
$httproot . '/course/view.php?id=123, ' .
$httpsroot . '/course/view.php?id=123, ' .
$httpsroot . '/course/section.php?id=123, ' .
$httpsroot . '/grade/index.php?id=123, ' .
$httpsroot . '/grade/report/index.php?id=123, ' .
$httpsroot . '/badges/index.php?type=2&id=123, ' .
@ -59,7 +60,8 @@ final class backup_encode_content_test extends \basic_testcase {
$httpsroot . '/pluginfile.php/123 and ' .
urlencode($httpsroot . '/pluginfile.php/123') . '.'
);
$this->assertEquals('$@COURSEVIEWBYID*123@$, $@COURSEVIEWBYID*123@$, $@GRADEINDEXBYID*123@$, ' .
$this->assertEquals('$@COURSEVIEWBYID*123@$, $@COURSEVIEWBYID*123@$, ' .
'$@COURSESECTIONBYID*123@$, $@GRADEINDEXBYID*123@$, ' .
'$@GRADEREPORTINDEXBYID*123@$, $@BADGESVIEWBYID*123@$, $@USERINDEXVIEWBYID*123@$, ' .
'$@PLUGINFILEBYCONTEXT*123@$ and $@PLUGINFILEBYCONTEXTURLENCODED*123@$.', $encoded);
@ -68,6 +70,7 @@ final class backup_encode_content_test extends \basic_testcase {
$encoded = backup_course_task::encode_content_links(
$httproot . '/course/view.php?id=123, ' .
$httpsroot . '/course/view.php?id=123, ' .
$httproot . '/course/section.php?id=123, ' .
$httproot . '/grade/index.php?id=123, ' .
$httproot . '/grade/report/index.php?id=123, ' .
$httproot . '/badges/index.php?type=2&id=123, ' .
@ -75,7 +78,8 @@ final class backup_encode_content_test extends \basic_testcase {
$httproot . '/pluginfile.php/123 and ' .
urlencode($httproot . '/pluginfile.php/123') . '.'
);
$this->assertEquals('$@COURSEVIEWBYID*123@$, $@COURSEVIEWBYID*123@$, $@GRADEINDEXBYID*123@$, ' .
$this->assertEquals('$@COURSEVIEWBYID*123@$, $@COURSEVIEWBYID*123@$, ' .
'$@COURSESECTIONBYID*123@$, $@GRADEINDEXBYID*123@$, ' .
'$@GRADEREPORTINDEXBYID*123@$, $@BADGESVIEWBYID*123@$, $@USERINDEXVIEWBYID*123@$, ' .
'$@PLUGINFILEBYCONTEXT*123@$ and $@PLUGINFILEBYCONTEXTURLENCODED*123@$.', $encoded);
$CFG->wwwroot = $oldroot;