Skip to content

Commit

Permalink
Merge branch 'release-48.14.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 25, 2024
2 parents 257efc4 + 0b4ca1e commit 9068f4e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions models/classes/class.QtiTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ protected function importTest(

// If any, assessmentSectionRefs will be resolved and included as part of the main test definition.
$testDefinition->includeAssessmentSectionRefs(true);
$testLabel = $packageLabel ?? $this->getTestLabel($reportCtx->testMetadata);
$testLabel = $packageLabel ?? $this->getTestLabel($reportCtx->testMetadata, $testDefinition);

if ($overwriteTestUri || $overwriteTest) {
$itemsClassLabel = $testLabel;
Expand Down Expand Up @@ -1571,12 +1571,21 @@ private function createTestIdentifier(core_kernel_classes_Resource $test): strin
return str_replace('_', '-', Format::sanitizeIdentifier($identifier));
}

private function getTestLabel(array $testMetadata): string
private function getTestLabel(array $testMetadata, XmlDocument $testDefinition): string
{
$labelMetadata = array_filter($testMetadata, function ($metadata) {
return in_array(RDFS_LABEL, $metadata->getPath());
});

if (empty($labelMetadata)) {
if ($testDefinition->getDocumentComponent() === null) {
throw new Exception('No metadata label found for test and no title in the test definition.');
}

common_Logger::w('No metadata label found for test. Using the title from the test definition.');
return $testDefinition->getDocumentComponent()->getTitle();
}

if (count($labelMetadata) > 1) {
common_Logger::w('Multiple labels found for test. Using the first one.');
}
Expand Down

0 comments on commit 9068f4e

Please sign in to comment.