Skip to content

Commit

Permalink
feat: Remove MetaMetadataValidator. Move business logic into matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomiejmarszal committed Apr 18, 2024
1 parent 2ac9845 commit bea3f55
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions models/classes/class.QtiTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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(
Expand All @@ -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());
}
}

Expand Down Expand Up @@ -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);
}
}

0 comments on commit bea3f55

Please sign in to comment.