Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport/adf 1685/store tests items uris #2496

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: throw an exception if item calss does not exists
  • Loading branch information
shpran committed Aug 15, 2024
commit 817967ca57f8e02e11965fd395bc0696231f12a1
16 changes: 13 additions & 3 deletions actions/class.RestQtiTests.php
Original file line number Diff line number Diff line change
@@ -136,9 +136,19 @@ public function import()
}
}

protected function getItemClassUri(): ?string
/**
* @throws common_exception_RestApi
*/
protected function getItemClassUri(): string
{
return $this->getPostParameter(self::ITEM_CLASS_URI);
$itemClassUri = $this->getPostParameter(self::ITEM_CLASS_URI, TaoOntology::CLASS_URI_ITEM);
$itemClass = $this->getClass($itemClassUri);

if (!$itemClass->exists()) {
throw new common_exception_RestApi('Class does not exist. Please use valid ' . self::ITEM_CLASS_URI);
}

return $itemClassUri;
}

/**
@@ -153,7 +163,7 @@ protected function isOverwriteTest(): bool
}

if (!in_array($isOverwriteTest, ['true', 'false'])) {
throw new \common_exception_RestApi(
throw new common_exception_RestApi(
'isOverwriteTest parameter should be boolean (true or false).'
);
}
2 changes: 1 addition & 1 deletion models/classes/tasks/ImportQtiTest.php
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public function __invoke($params)
$params[self::PARAM_ITEM_MUST_EXIST] ?? false,
$params[self::PARAM_ITEM_MUST_BE_OVERWRITTEN] ?? false,
$params[self::PARAM_OVERWRITE_TEST] ?? false,
$params[self::PARAM_ITEM_CLASS_URI] ?? false,
$params[self::PARAM_ITEM_CLASS_URI] ?? null,
$params[self::PARAM_OVERWRITE_TEST_URI] ?? null,
$params[self::PARAM_PACKAGE_LABEL] ?? null,
);