From bea3f558552f66242c038bfc50d63e260add9f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Thu, 18 Apr 2024 09:53:56 +0200 Subject: [PATCH] feat: Remove MetaMetadataValidator. Move business logic into matcher --- models/classes/class.QtiTestService.php | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/models/classes/class.QtiTestService.php b/models/classes/class.QtiTestService.php index 2c78dee38..69835b492 100644 --- a/models/classes/class.QtiTestService.php +++ b/models/classes/class.QtiTestService.php @@ -32,11 +32,9 @@ use oat\taoQtiItem\model\qti\metadata\imsManifest\MetaMetadataExtractor; use oat\taoQtiItem\model\qti\metadata\importer\MetaMetadataImportMapper; use oat\taoQtiItem\model\qti\metadata\importer\PropertyDoesNotExistException; -use oat\taoQtiItem\model\qti\metadata\imsManifest\MetaMetadataValidator; use oat\taoQtiItem\model\qti\metadata\MetadataGuardianResource; use oat\taoQtiItem\model\qti\metadata\MetadataService; use oat\taoQtiItem\model\qti\metadata\ontology\MappedMetadataInjector; -use oat\taoQtiItem\model\qti\metaMetadata\imsManifest\MetaMetadataException; use oat\taoQtiItem\model\qti\Resource; use oat\taoQtiItem\model\qti\Service; use oat\taoQtiTest\models\cat\AdaptiveSectionInjectionException; @@ -46,7 +44,6 @@ use oat\taoQtiTest\models\render\QtiPackageImportPreprocessing; use oat\taoQtiTest\models\test\AssessmentTestXmlFactory; use oat\taoTests\models\event\TestUpdatedEvent; -use PHP_CodeSniffer\Reporter; use Psr\Container\ContainerInterface; use qtism\common\utils\Format; use qtism\data\AssessmentItemRef; @@ -57,6 +54,7 @@ use qtism\data\storage\xml\XmlDocument; use qtism\data\storage\xml\XmlStorageException; use taoTests_models_classes_TestsService as TestService; +use oat\oatbox\reporting\Report; /** * the QTI TestModel service. @@ -615,7 +613,6 @@ protected function importTest( $testDefinition = new XmlDocument(); try { - $this->getMetaMetadataValidator()->validateClass($testClass, $metaMetadataValues); $testDefinition->load($expectedTestFile, true); // If any, assessmentSectionRefs will be resolved and included as part of the main test definition. @@ -851,12 +848,8 @@ protected function importTest( $report->add(common_report_Report::createFailure($msg)); } catch (PropertyDoesNotExistException $e) { - $report->add( - new common_report_Report( - common_report_Report::TYPE_ERROR, - __("Property '%s' does not exist.", $e->getProperty()) - ) - ); + $reportCtx->itemClass = $targetItemClass; + $report->add(Report::createError($e->getMessage())); } catch (CatEngineNotFoundException $e) { $report->add( @@ -875,11 +868,6 @@ protected function importTest( // phpcs:enable Generic.Files.LineLength ) ); - } catch (MetaMetadataException $e) { - $report = Reporter::createError( - sprintf('Import failed at validating metametadata with message: "%s"', $e->getMessage()) - ); - common_Logger::e($e->getMessage()); } } @@ -1529,9 +1517,4 @@ private function getMetaMetadataImporter(): MetaMetadataImportMapper { return $this->getServiceManager()->getContainer()->get(MetaMetadataImportMapper::class); } - - protected function getMetaMetadataValidator(): MetaMetadataValidator - { - return $this->getServiceManager()->getContainer()->get(MetaMetadataValidator::class); - } }