From c4905d62bafed8971eecef8b2d956b5c0a07d9c9 Mon Sep 17 00:00:00 2001 From: Edmund Farrow Date: Tue, 10 Dec 2024 14:28:41 +0000 Subject: [PATCH] quiz-data - Fix tests --- classes/export_repo.php | 2 +- doc/exportrepofrommoodle.md | 1 + .../testrepo/fakeexport_system_question_manifest.json | 3 ++- .../fakeexportquiz_course_course-1_question_manifest.json | 3 ++- .../testrepo/fakeignore_system_question_manifest.json | 3 ++- .../testrepo/fakeimport_system_question_manifest.json | 3 ++- .../fakeimportquiz_course_course-1_question_manifest.json | 3 ++- ...akeexportquiz_module_course-1_quiz-1_question_manifest.json | 3 ++- ...akeimportquiz_module_course-1_quiz-1_question_manifest.json | 3 ++- tests/create_repo_test.php | 1 + tests/export_repo_test.php | 1 + tests/export_trait_test.php | 1 + tests/tidy_trait_test.php | 1 + 13 files changed, 20 insertions(+), 8 deletions(-) diff --git a/classes/export_repo.php b/classes/export_repo.php index 8404ebd..96c2129 100644 --- a/classes/export_repo.php +++ b/classes/export_repo.php @@ -122,6 +122,7 @@ public function __construct(cli_helper $clihelper, array $moodleinstances) { // (Moodle code rules don't allow 'extract()'). $arguments = $clihelper->get_arguments(); $moodleinstance = $arguments['moodleinstance']; + $this->moodleurl = $moodleinstances[$moodleinstance]; $this->usegit = $arguments['usegit']; $defaultwarning = false; $this->manifestpath = ($arguments['rootdirectory']) ? $arguments['rootdirectory'] . '/' . $arguments['manifestpath'] : @@ -165,7 +166,6 @@ public function __construct(cli_helper $clihelper, array $moodleinstances) { $this->tempfilepath = str_replace(cli_helper::MANIFEST_FILE, '_export' . cli_helper::TEMP_MANIFEST_FILE, $this->manifestpath); - $this->moodleurl = $moodleinstances[$moodleinstance]; $wsurl = $this->moodleurl . '/webservice/rest/server.php'; $this->curlrequest = $this->get_curl_request($wsurl); diff --git a/doc/exportrepofrommoodle.md b/doc/exportrepofrommoodle.md index 8336194..6b61279 100644 --- a/doc/exportrepofrommoodle.md +++ b/doc/exportrepofrommoodle.md @@ -12,6 +12,7 @@ |-|-|-| |i|moodleinstance|Key of Moodle instance in $moodleinstances to use. Should match end of instance URL.| |r|rootdirectory|Directory on user's computer containing repos.| +|f|nonquizmanifestpath|Filepath of non-quiz manifest file relative to root directory.| |f|manifestpath|Filepath of manifest file relative to root directory.| |s|subcategory|Relative subcategory of repo to actually export.| |q|questioncategoryid|Numerical id of subcategory to actually export. diff --git a/testrepoparent/testrepo/fakeexport_system_question_manifest.json b/testrepoparent/testrepo/fakeexport_system_question_manifest.json index 5f58526..f777673 100644 --- a/testrepoparent/testrepo/fakeexport_system_question_manifest.json +++ b/testrepoparent/testrepo/fakeexport_system_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "", "defaultsubdirectory": "top\/cat-2", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo/fakeexportquiz_course_course-1_question_manifest.json b/testrepoparent/testrepo/fakeexportquiz_course_course-1_question_manifest.json index c40bcb1..f593bce 100644 --- a/testrepoparent/testrepo/fakeexportquiz_course_course-1_question_manifest.json +++ b/testrepoparent/testrepo/fakeexportquiz_course_course-1_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "", "defaultsubdirectory": "top\/cat-2", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo/fakeignore_system_question_manifest.json b/testrepoparent/testrepo/fakeignore_system_question_manifest.json index 72056c8..b4cc7b8 100644 --- a/testrepoparent/testrepo/fakeignore_system_question_manifest.json +++ b/testrepoparent/testrepo/fakeignore_system_question_manifest.json @@ -7,7 +7,8 @@ "instanceid": "", "defaultsubdirectory": "top\/cat-2", "defaultsubcategoryid": 5, - "defaultignorecat": "/subcat 2_1/" + "defaultignorecat": "/subcat 2_1/", + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo/fakeimport_system_question_manifest.json b/testrepoparent/testrepo/fakeimport_system_question_manifest.json index 5f58526..f777673 100644 --- a/testrepoparent/testrepo/fakeimport_system_question_manifest.json +++ b/testrepoparent/testrepo/fakeimport_system_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "", "defaultsubdirectory": "top\/cat-2", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo/fakeimportquiz_course_course-1_question_manifest.json b/testrepoparent/testrepo/fakeimportquiz_course_course-1_question_manifest.json index 6129dba..0e6288c 100644 --- a/testrepoparent/testrepo/fakeimportquiz_course_course-1_question_manifest.json +++ b/testrepoparent/testrepo/fakeimportquiz_course_course-1_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "5", "defaultsubdirectory": "top\/cat-2", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json b/testrepoparent/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json index 6e99a0b..62bcf17 100644 --- a/testrepoparent/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json +++ b/testrepoparent/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "", "defaultsubdirectory": "top", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/testrepoparent/testrepo_quiz_quiz-1/fakeimportquiz_module_course-1_quiz-1_question_manifest.json b/testrepoparent/testrepo_quiz_quiz-1/fakeimportquiz_module_course-1_quiz-1_question_manifest.json index 56a51ce..4dd58bc 100644 --- a/testrepoparent/testrepo_quiz_quiz-1/fakeimportquiz_module_course-1_quiz-1_question_manifest.json +++ b/testrepoparent/testrepo_quiz_quiz-1/fakeimportquiz_module_course-1_quiz-1_question_manifest.json @@ -6,7 +6,8 @@ "coursecategory": "", "instanceid": "1", "defaultsubdirectory": "top", - "defaultsubcategoryid": 5 + "defaultsubcategoryid": 5, + "moodleurl": "fakeurl.com" }, "questions": [ { diff --git a/tests/create_repo_test.php b/tests/create_repo_test.php index 3e91c2a..1dad6df 100644 --- a/tests/create_repo_test.php +++ b/tests/create_repo_test.php @@ -67,6 +67,7 @@ public function setUp(): void { 'rootdirectory' => $this->rootpath, 'directory' => '', 'subcategory' => null, + 'nonquizmanifestpath' => null, 'contextlevel' => 'system', 'coursename' => 'Course 1', 'modulename' => 'Test 1', diff --git a/tests/export_repo_test.php b/tests/export_repo_test.php index 0e1763a..bb374b9 100644 --- a/tests/export_repo_test.php +++ b/tests/export_repo_test.php @@ -90,6 +90,7 @@ public function setUp(): void { $this->options = [ 'moodleinstance' => self::MOODLE, 'rootdirectory' => $this->rootpath, + 'nonquizmanifestpath' => null, 'subcategory' => null, 'qcategoryid' => null, 'manifestpath' => '/' . self::MOODLE . '_system' . cli_helper::MANIFEST_FILE, diff --git a/tests/export_trait_test.php b/tests/export_trait_test.php index 387528d..98087e3 100644 --- a/tests/export_trait_test.php +++ b/tests/export_trait_test.php @@ -66,6 +66,7 @@ public function setUp(): void { $this->options = [ 'moodleinstance' => self::MOODLE, 'rootdirectory' => $this->rootpath, + 'nonquizmanifestpath' => null, 'subcategory' => null, 'qcategoryid' => null, 'manifestpath' => '/' . self::MOODLE . '_system' . cli_helper::MANIFEST_FILE, diff --git a/tests/tidy_trait_test.php b/tests/tidy_trait_test.php index 48edd61..963823c 100644 --- a/tests/tidy_trait_test.php +++ b/tests/tidy_trait_test.php @@ -67,6 +67,7 @@ public function setUp(): void { 'moodleinstance' => self::MOODLE, 'rootdirectory' => $this->rootpath, 'subcategory' => 'top', + 'nonquizmanifestpath' => null, 'qcategoryid' => null, 'manifestpath' => '/' . self::MOODLE . '_system' . cli_helper::MANIFEST_FILE, 'token' => 'XXXXXX',