Skip to content

Commit

Permalink
chore: update swagger, add exception log
Browse files Browse the repository at this point in the history
  • Loading branch information
shpran committed Aug 8, 2024
1 parent d50a809 commit f6c647f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,27 @@
"type": "string",
"required": false
},
{
"name": "overwriteTest",
"in": "formData",
"description": "Deprecated: use `overwriteTestUri` parameter with the URI of the test to be replaced. Flag that indicates if already existed tests and all related items are removed in a case they have the same title and class as uploaded tests. Can be used to replace existing test and avoid creating a new one with the same title and class. 'true' value counts as true, 'false' as false",
"type": "string",
"required": false
},
{
"name": "overwriteTestUri",
"in": "formData",
"description": "Test URI, that can be used to replace existing test and avoid creating a new one with the same title and class",
"type": "string",
"required": false
},
{
"name": "packageLabel",
"in": "formData",
"description": "Label for items folder and test label, which will be used instead of QTI test title",
"type": "string",
"required": false
},
{
"name": "enableMetadataGuardians",
"in": "formData",
Expand Down Expand Up @@ -350,13 +364,27 @@
"type": "string",
"required": false
},
{
"name": "overwriteTest",
"in": "formData",
"description": "Deprecated: use `overwriteTestUri` parameter with the URI of the test to be replaced. Flag that indicates if already existed tests and all related items are removed in a case they have the same title and class as uploaded tests. Can be used to replace existing test and avoid creating a new one with the same title and class. 'true' value counts as true, 'false' as false",
"type": "string",
"required": false
},
{
"name": "overwriteTestUri",
"in": "formData",
"description": "Test URI, that can be used to replace existing test and avoid creating a new one with the same title and class",
"type": "string",
"required": false
},
{

This comment has been minimized.

Copy link
@gabrielfs7

gabrielfs7 Aug 8, 2024

Contributor
  • @shpran this is repeated, can we remove the duplication, please?

This comment has been minimized.

Copy link
@gabrielfs7

gabrielfs7 Aug 8, 2024

Contributor

Forget, I see it is a new endpoint. Closing it

"name": "packageLabel",
"in": "formData",
"description": "Label for items folder and test label, which will be used instead of QTI test title",
"type": "string",
"required": false
},
{
"name": "enableMetadataGuardians",
"in": "formData",
Expand Down
22 changes: 22 additions & 0 deletions models/classes/class.CrudQtiTestsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
*/

use oat\oatbox\log\LoggerAwareTrait;
use oat\tao\model\TaoOntology;

/**
Expand All @@ -32,6 +33,8 @@
*/
class taoQtiTest_models_classes_CrudQtiTestsService extends tao_models_classes_CrudService
{
use LoggerAwareTrait;

/** (non-PHPdoc)
* @see tao_models_classes_CrudSservice::getClassService()
*/
Expand Down Expand Up @@ -106,7 +109,26 @@ public function importQtiTest(

return $report;
} catch (common_exception_UserReadableException $e) {
$this->logException($e);

return new common_report_Report(common_report_Report::TYPE_ERROR, __($e->getUserMessage()));
} catch (Throwable $exception) {
$this->logException($exception);

return new common_report_Report(common_report_Report::TYPE_ERROR, __('QTI test import failed'));
}
}

private function logException(Throwable $exception): void

This comment has been minimized.

Copy link
@gabrielfs7

gabrielfs7 Aug 8, 2024

Contributor

Would it be asking too much if we could put the form data that we received? label, test URI, etc. Sorry for pushing a lot on this, but this would save us so much time on debugging translation issues on PROD.

Thanks again!

{
$this->logError(
sprintf(
'QTI test import failed: %s. File: %s, Line: %s. Stack trace: %s',
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$exception->getTraceAsString()
)
);
}
}

0 comments on commit f6c647f

Please sign in to comment.