Skip to content

Commit

Permalink
Merge branch 'release-48.14.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 22, 2024
2 parents e67e033 + 432c326 commit 257efc4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 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 ?? $testDefinition->getDocumentComponent()->getTitle();
$testLabel = $packageLabel ?? $this->getTestLabel($reportCtx->testMetadata);

if ($overwriteTestUri || $overwriteTest) {
$itemsClassLabel = $testLabel;
Expand Down Expand Up @@ -807,9 +807,8 @@ protected function importTest(
$this->importTestAuxiliaryFiles($testContent, $qtiTestResource, $folder, $report);

// 3. Give meaningful names to resources.
$definitionTitle = $testDefinition->getDocumentComponent()->getTitle();
$testResource->setLabel($packageLabel ?? $definitionTitle);
$targetItemClass->setLabel($packageLabel ?? $definitionTitle);
$testResource->setLabel($packageLabel ?? $testLabel);
$targetItemClass->setLabel($packageLabel ?? $testLabel);

// 4. Import metadata for the resource (use same mechanics as item resources).
// Metadata will be set as property values.
Expand Down Expand Up @@ -1571,4 +1570,17 @@ private function createTestIdentifier(core_kernel_classes_Resource $test): strin

return str_replace('_', '-', Format::sanitizeIdentifier($identifier));
}

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

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

return reset($labelMetadata)->getValue();
}
}

0 comments on commit 257efc4

Please sign in to comment.