diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e62b4..517dd66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Create an official Quiz Archiver documentation website: [https://quizarchiver.gandrass.de/](https://quizarchiver.gandrass.de/) - Automate building and deployment of documentation website - Cleanup and restructure existing documentation within README +- Add demo quiz archive worker information to admin settings page - Fix PHP warning on autoinstall admin page diff --git a/lang/de/quiz_archiver.php b/lang/de/quiz_archiver.php index d461a03..0fe9e70 100644 --- a/lang/de/quiz_archiver.php +++ b/lang/de/quiz_archiver.php @@ -224,7 +224,7 @@ $string['setting_webservice_userid'] = 'Webservice Nutzer-ID'; $string['setting_webservice_userid_desc'] = 'User-ID des Moodle Nutzers, der vom Archive Worker Service genutzt wird, um auf Testdaten zuzugreifen. Er muss alle Berechtigungen besitzen, die in der Dokumentation aufgelistet sind, um korrekt zu funktionieren. Aus Sicherheitsgründen sollte dies ein dedizierter Nutzer ohne globale Administrationsrechte sein.'; $string['setting_worker_url'] = 'Archive Worker URL'; -$string['setting_worker_url_desc'] = 'URL des Archive Worker Services, der für die Ausführung von Archivierungsaufträgen genutzt wird.
Beispiel: http://127.0.0.1:8080 oder http://moodle-quiz-archive-worker:8080'; +$string['setting_worker_url_desc'] = 'URL des Archive Worker Services, der für die Ausführung von Archivierungsaufträgen genutzt wird. Wenn Sie den Quiz Archiver lediglich ausprobieren wollen, können Sie vorerst auch den kostenfreien öffentlichen Archive Worker Service nutzen.
Beispiel: http://127.0.0.1:8080 oder http://moodle-quiz-archive-worker:8080'; // Errors. $string['error_worker_connection_failed'] = 'Verbindung zum Archive Worker fehlgeschlagen.'; diff --git a/lang/en/quiz_archiver.php b/lang/en/quiz_archiver.php index 2cf7d4e..c708e9b 100644 --- a/lang/en/quiz_archiver.php +++ b/lang/en/quiz_archiver.php @@ -224,7 +224,7 @@ $string['setting_webservice_userid'] = 'Web service user-ID'; $string['setting_webservice_userid_desc'] = 'User-ID of the Moodle user that is used by the archive worker service to access quiz data. It must have all capabilities that are listed in the documentation to work properly. For security reasons, this should be a dedicated user account without full administrative privileges.'; $string['setting_worker_url'] = 'Archive worker URL'; -$string['setting_worker_url_desc'] = 'URL of the archive worker service to call for quiz archive task execution.
Example: http://127.0.0.1:8080 or http://moodle-quiz-archive-worker:8080'; +$string['setting_worker_url_desc'] = 'URL of the archive worker service to call for quiz archive task execution. If you only want to try the Quiz Archiver, you can use the free public demo quiz archive worker service, eliminating the need to set up your own worker service right away.
Example: http://127.0.0.1:8080 or http://moodle-quiz-archive-worker:8080'; // Errors. $string['error_worker_connection_failed'] = 'Establishing a connection to the archive worker failed.'; diff --git a/tests/external/get_backup_status_test.php b/tests/external/get_backup_status_test.php index 65fb9c5..0a81203 100644 --- a/tests/external/get_backup_status_test.php +++ b/tests/external/get_backup_status_test.php @@ -113,8 +113,8 @@ public function test_assure_return_parameter_spec(): void { * @covers \quiz_archiver\external\get_backup_status::execute * @covers \quiz_archiver\external\get_backup_status::validate_parameters * - * @param string $jobid Job ID - * @param string $backupid Backup ID + * @param string|null $jobid Job ID to check + * @param string|null $backupid Backup ID to check * @param bool $shouldfail Whether a failure is expected * @return void * @throws \coding_exception @@ -123,17 +123,37 @@ public function test_assure_return_parameter_spec(): void { * @throws \required_capability_exception */ public function test_parameter_validation( - string $jobid, - string $backupid, - bool $shouldfail + ?string $jobid, + ?string $backupid, + bool $shouldfail ): void { + // Gain webservice permission. + $this->setAdminUser(); + + // Create mock quiz. $this->resetAfterTest(); + $mocks = $this->getDataGenerator()->create_mock_quiz(); + $job = ArchiveJob::create( + '20000000-1234-5678-abcd-ef4242424242', + $mocks->course->id, + $mocks->quiz->cmid, + $mocks->quiz->id, + $mocks->user->id, + null, + 'TEST-WS-TOKEN', + [], + [] + ); + $_GET['wstoken'] = 'TEST-WS-TOKEN'; if ($shouldfail) { $this->expectException(\invalid_parameter_exception::class); } - get_backup_status::execute($jobid, $backupid); + get_backup_status::execute( + $jobid === null ? $job->get_jobid() : $jobid, + $backupid === null ? 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15' : $backupid + ); } /** @@ -144,29 +164,22 @@ public function test_parameter_validation( * @throws \moodle_exception */ public static function parameter_data_provider(): array { - // Create job. - $self = new self(); - $mocks = $self->getDataGenerator()->create_mock_quiz(); - $job = ArchiveJob::create( - '20000000-1234-5678-abcd-ef4242424242', - $mocks->course->id, - $mocks->quiz->cmid, - $mocks->quiz->id, - $mocks->user->id, - null, - 'TEST-WS-TOKEN', - [], - [] - ); - $base = [ - 'jobid' => $job->get_jobid(), - 'backupid' => 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15', - ]; - return [ - 'Valid' => array_merge($base, ['shouldfail' => false]), - 'Invalid jobid' => array_merge($base, ['jobid' => 'Foo', 'shouldfail' => true]), - 'Invalid backupid' => array_merge($base, ['backupid' => 'Bar', 'shouldfail' => true]), + 'Valid' => array_merge([ + 'jobid' => null, + 'backupid' => null, + 'shouldfail' => false, + ]), + 'Invalid jobid' => array_merge([ + 'jobid' => 'Foo', + 'backupid' => null, + 'shouldfail' => true, + ]), + 'Invalid backupid' => array_merge([ + 'jobid' => null, + 'backupid' => 'Bar', + 'shouldfail' => true, + ]), ]; } diff --git a/tests/external/process_uploaded_artifact_test.php b/tests/external/process_uploaded_artifact_test.php index 09f348b..fa79de3 100644 --- a/tests/external/process_uploaded_artifact_test.php +++ b/tests/external/process_uploaded_artifact_test.php @@ -196,15 +196,15 @@ public function test_wstoken_write_access_check(): void { * @covers \quiz_archiver\external\process_uploaded_artifact::execute * @covers \quiz_archiver\external\process_uploaded_artifact::validate_parameters * - * @param string $jobid Job ID - * @param string $artifactcomponent Component name - * @param int $artifactcontextid Context ID - * @param int $artifactuserid User ID - * @param string $artifactfilearea File area name - * @param string $artifactfilename File name - * @param string $artifactfilepath File path - * @param int $artifactitemid Item ID - * @param string $artifactsha256sum SHA256 checksum + * @param string|null $jobid Job ID + * @param string|null $artifactcomponent Component name + * @param int|null $artifactcontextid Context ID + * @param int|null $artifactuserid User ID + * @param string|null $artifactfilearea File area name + * @param string|null $artifactfilename File name + * @param string|null $artifactfilepath File path + * @param int|null $artifactitemid Item ID + * @param string|null $artifactsha256sum SHA256 checksum * @param bool $shouldfail Whether a failure is expected * @return void * @throws \coding_exception @@ -213,33 +213,36 @@ public function test_wstoken_write_access_check(): void { * @throws \required_capability_exception */ public function test_parameter_validation( - string $jobid, - string $artifactcomponent, - int $artifactcontextid, - int $artifactuserid, - string $artifactfilearea, - string $artifactfilename, - string $artifactfilepath, - int $artifactitemid, - string $artifactsha256sum, - bool $shouldfail + ?string $jobid, + ?string $artifactcomponent, + ?int $artifactcontextid, + ?int $artifactuserid, + ?string $artifactfilearea, + ?string $artifactfilename, + ?string $artifactfilepath, + ?int $artifactitemid, + ?string $artifactsha256sum, + bool $shouldfail ): void { + // Create mock quiz. $this->resetAfterTest(); + $mocks = $this->getDataGenerator()->create_mock_quiz(); + $base = $this->generate_valid_request('xxx', $mocks->quiz->cmid, $mocks->user->id); if ($shouldfail) { $this->expectException(\invalid_parameter_exception::class); } process_uploaded_artifact::execute( - $jobid, - $artifactcomponent, - $artifactcontextid, - $artifactuserid, - $artifactfilearea, - $artifactfilename, - $artifactfilepath, - $artifactitemid, - $artifactsha256sum + $jobid === null ? $base['jobid'] : $jobid, + $artifactcomponent === null ? $base['artifact_component'] : $artifactcomponent, + $artifactcontextid === null ? $base['artifact_contextid'] : $artifactcontextid, + $artifactuserid === null ? $base['artifact_userid'] : $artifactuserid, + $artifactfilearea === null ? $base['artifact_filearea'] : $artifactfilearea, + $artifactfilename === null ? $base['artifact_filename'] : $artifactfilename, + $artifactfilepath === null ? $base['artifact_filepath'] : $artifactfilepath, + $artifactitemid === null ? $base['artifact_itemid'] : $artifactitemid, + $artifactsha256sum === null ? $base['artifact_sha256sum'] : $artifactsha256sum ); } @@ -249,9 +252,20 @@ public function test_parameter_validation( * @return array[] Test data */ public static function parameter_data_provider(): array { - $self = new self(); - $mocks = $self->getDataGenerator()->create_mock_quiz(); - $base = $self->generate_valid_request('xxx', $mocks->quiz->cmid, $mocks->user->id); + // Create base data (no modification). + $base = [ + "jobid" => null, + "artifact_component" => null, + "artifact_contextid" => null, + "artifact_userid" => null, + "artifact_filearea" => null, + "artifact_filename" => null, + "artifact_filepath" => null, + "artifact_itemid" => null, + "artifact_sha256sum" => null, + ]; + + // Define test datasets. return [ 'Valid' => array_merge($base, [ 'shouldfail' => false,