Skip to content

Commit

Permalink
quiz-data - Code check
Browse files Browse the repository at this point in the history
  • Loading branch information
EJMFarrow committed Dec 9, 2024
1 parent df2a822 commit fc351ea
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion classes/create_repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,4 @@ public function call_repo_creation(string $rootdirectory, string $moodleinstance
$rootdirectory . '" -i "' . $moodleinstance .
'" -l "module" -n ' . $instanceid . ' -t ' . $token . $ignorecat);
}
}
}
2 changes: 1 addition & 1 deletion classes/export_repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class export_repo {
* Set in config. Adds commit hash to manifest.
* @var bool
*/
public bool $usegit;
public bool $usegit;

/**
* Constructor
Expand Down
6 changes: 6 additions & 0 deletions classes/export_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ public function export_to_repo_main_process(object $moodlequestionlist): void {
}
}

/**
* Export quiz structure
* @param mixed $clihelper
* @param mixed $scriptdirectory
* @return void
*/
public function export_quiz_structure($clihelper, $scriptdirectory) {
$arguments = $clihelper->get_arguments();
$moodleinstance = $arguments['moodleinstance'];
Expand Down
9 changes: 8 additions & 1 deletion classes/import_quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ public function process(): void {
$this->import_quiz_data();
}

/**
* Import quiz including structure.
* Creates quiz, imports questions, updates structure.
* @param mixed $clihelper
* @param mixed $scriptdirectory
* @return void
*/
public function import_all($clihelper, $scriptdirectory): void {
if ($this->quizmanifestcontents) {
echo "\nA question manifest already exists for this quiz in this Moodle instance.\n";
Expand Down Expand Up @@ -315,7 +322,7 @@ public function import_all($clihelper, $scriptdirectory): void {
echo $output;
}

/**
/**
* Separate out exec call for mocking.
*
* @param string $rootdirectory
Expand Down
2 changes: 1 addition & 1 deletion cli/importwholecoursetomoodle.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
'default' => null,
'variable' => 'modulename',
'valuerequired' => true,
'hidden' => true
'hidden' => true,
],
[
'longopt' => 'coursecategory',
Expand Down
2 changes: 1 addition & 1 deletion tests/create_repo_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function setUp(): void {
'execute',
])->setConstructorArgs(['xxxx'])->getMock();;
$this->createrepo = $this->getMockBuilder(\qbank_gitsync\create_repo::class)->onlyMethods([
'get_curl_request', 'call_repo_creation', 'call_export_quiz'
'get_curl_request', 'call_repo_creation', 'call_export_quiz',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();
$this->createrepo->curlrequest = $this->curl;
$this->createrepo->listcurlrequest = $this->listcurl;
Expand Down
8 changes: 4 additions & 4 deletions tests/export_repo_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setUp(): void {
'execute',
])->setConstructorArgs(['xxxx'])->getMock();
$this->exportrepo = $this->getMockBuilder(\qbank_gitsync\export_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo'
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();
$this->exportrepo->curlrequest = $this->curl;
$this->exportrepo->listcurlrequest = $this->listcurl;
Expand Down Expand Up @@ -445,7 +445,7 @@ public function test_full_course_not_in_manifest(): void {
"quizzes": [{"instanceid":"1", "name":"Quiz 1"}, {"instanceid":"2", "name":"Quiz 2"}]}')
);
$this->exportrepo = $this->getMockBuilder(\qbank_gitsync\export_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo'
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();

$this->exportrepo->curlrequest = $this->curl;
Expand Down Expand Up @@ -488,7 +488,7 @@ public function test_full_course_in_manifest_no_directories(): void {
"quizzes": [{"instanceid":"1", "name":"Quiz 1"}, {"instanceid":"2", "name":"Quiz 2"}]}')
);
$this->exportrepo = $this->getMockBuilder(\qbank_gitsync\export_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo'
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();

$this->exportrepo->curlrequest = $this->curl;
Expand Down Expand Up @@ -535,7 +535,7 @@ public function test_full_course_in_manifest_existing_directories(): void {
"quizzes": [{"instanceid":"1", "name":"Quiz 1"}]}')
);
$this->exportrepo = $this->getMockBuilder(\qbank_gitsync\export_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo'
'get_curl_request', 'call_exit', 'call_repo_creation', 'call_export_quiz', 'call_export_repo',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();

$this->exportrepo->curlrequest = $this->curl;
Expand Down
8 changes: 4 additions & 4 deletions tests/import_repo_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public function test_full_course(): void {
]}')
);
$this->importrepo = $this->getMockBuilder(\qbank_gitsync\import_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data'
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();

$this->importrepo->update_quizzes($this->clihelper, $this->rootpath . '/testrepoparent');
Expand Down Expand Up @@ -1488,7 +1488,7 @@ public function test_full_course_quiz_create_fail(): void {
"questions": [], "quizzes": [{"instanceid":"1", "name":"Quiz Wrong"}]}')
);
$this->importrepo = $this->getMockBuilder(\qbank_gitsync\import_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data'
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();

$this->importrepo->update_quizzes($this->clihelper, $this->rootpath . '/testrepoparent');
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public function test_full_course_quiz_already_imported(): void {
"questions": [], "quizzes": [{"instanceid":"1", "name":"Quiz 1"}]}')
);
$this->importrepo = $this->getMockBuilder(\qbank_gitsync\import_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data'
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();
copy($this->rootpath . '/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json',
$this->rootpath . '/testrepo_quiz_quiz-1/fakeimport_module_course-1_quiz-1_question_manifest.json');
Expand Down Expand Up @@ -1557,7 +1557,7 @@ public function test_full_course_quiz_in_moodle(): void {
{"instanceid":"2", "name":"Quiz 2"}]}')
);
$this->importrepo = $this->getMockBuilder(\qbank_gitsync\import_repo::class)->onlyMethods([
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data'
'get_curl_request', 'call_exit', 'call_import_repo', 'call_import_quiz_data',
])->setConstructorArgs([$this->clihelper, $this->moodleinstances])->getMock();
copy($this->rootpath . '/testrepo_quiz_quiz-1/fakeexportquiz_module_course-1_quiz-1_question_manifest.json',
$this->rootpath . '/testrepo_quiz_quiz-1/fakeimport_module_course-1_quiz-1_question_manifest.json');
Expand Down

0 comments on commit fc351ea

Please sign in to comment.