From 85bc7e0706d9e8ae13f108e59abca2cdd51ae205 Mon Sep 17 00:00:00 2001 From: Karol Stelmaczonek Date: Wed, 4 Dec 2024 14:41:13 +0100 Subject: [PATCH] fix: handle import of props without metadata (cherry picked from commit 098410115805c2d66f2cb60e3d6812311c9001e2) --- models/classes/class.QtiTestService.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/models/classes/class.QtiTestService.php b/models/classes/class.QtiTestService.php index f51e98017..542d36701 100644 --- a/models/classes/class.QtiTestService.php +++ b/models/classes/class.QtiTestService.php @@ -1545,8 +1545,19 @@ private function getMappedProperties( if ($importMetadata === true) { $metaMetadataValues = $this->getMetaMetadataExtractor()->extract($domManifest); $reportCtx->metaMetadata = $metaMetadataValues; - return $this->getMetaMetadataImporter() + + $mappedMetadataValues = $this->getMetaMetadataImporter() ->mapMetaMetadataToProperties($metaMetadataValues, $targetItemClass, $testClass); + + if (empty($mappedMetadataValues)) { + $metadataValues = $this->getMetadataImporter()->extract($domManifest); + $mappedMetadataValues = $this->getMetaMetadataImporter()->mapMetadataToProperties( + $metadataValues, + $targetItemClass, + $testClass + ); + } + return $mappedMetadataValues; } return [];