From 4ebd81086ef845571e400211d89f2b946f995cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Mon, 11 Nov 2024 16:48:19 +0100 Subject: [PATCH 1/5] fix: remove GenericLomOntologyClassificationExtractor --- .../RemoveLegacyGenericLomExtractor.php | 45 +++++++++++++++++++ .../Version202411111526061101_taoQtiItem.php | 32 +++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 install/scripts/RemoveLegacyGenericLomExtractor.php create mode 100644 migrations/Version202411111526061101_taoQtiItem.php diff --git a/install/scripts/RemoveLegacyGenericLomExtractor.php b/install/scripts/RemoveLegacyGenericLomExtractor.php new file mode 100644 index 0000000000..0d1c730346 --- /dev/null +++ b/install/scripts/RemoveLegacyGenericLomExtractor.php @@ -0,0 +1,45 @@ +getServiceManager()->getContainer()->get(MetadataService::SERVICE_ID); + $exportOption = $metadataService->getOption(MetadataService::EXPORTER_KEY); + $extractors = $exportOption->getOption('extractors'); + + $extractors = array_filter($extractors, function ($extractor) { + return $extractor !== 'oat\taoQtiItem\model\qti\metadata\ontology\GenericLomOntologyClassificationExtractor'; + }); + + $exportOption->setOption('extractors', ... $extractors); + $metadataService->setOption(MetadataService::EXPORTER_KEY, $exportOption); + $this->getServiceManager()->register(MetadataService::SERVICE_ID, $metadataService); + } +} diff --git a/migrations/Version202411111526061101_taoQtiItem.php b/migrations/Version202411111526061101_taoQtiItem.php new file mode 100644 index 0000000000..0ace15765a --- /dev/null +++ b/migrations/Version202411111526061101_taoQtiItem.php @@ -0,0 +1,32 @@ +runAction(new RemoveLegacyGenericLomExtractor()); + } + + public function down(Schema $schema): void + { + $this->throwIrreversibleMigrationException(); + } +} From 2338597cfb61f625e415e5c4daf71e38161f0957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Tue, 12 Nov 2024 10:30:10 +0100 Subject: [PATCH 2/5] fix: extractor as array --- install/scripts/RemoveLegacyGenericLomExtractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/scripts/RemoveLegacyGenericLomExtractor.php b/install/scripts/RemoveLegacyGenericLomExtractor.php index 0d1c730346..960a05030a 100644 --- a/install/scripts/RemoveLegacyGenericLomExtractor.php +++ b/install/scripts/RemoveLegacyGenericLomExtractor.php @@ -38,7 +38,7 @@ public function __invoke($params) return $extractor !== 'oat\taoQtiItem\model\qti\metadata\ontology\GenericLomOntologyClassificationExtractor'; }); - $exportOption->setOption('extractors', ... $extractors); + $exportOption->setOption('extractors', [... $extractors]); $metadataService->setOption(MetadataService::EXPORTER_KEY, $exportOption); $this->getServiceManager()->register(MetadataService::SERVICE_ID, $metadataService); } From d28f0fc8679c927335740812f5171cb0e0c7d7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Tue, 12 Nov 2024 10:32:26 +0100 Subject: [PATCH 3/5] fix: add RemoveLegacyGenericLomExtractor to setup --- manifest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifest.php b/manifest.php index 30c1154d4d..320aeeff1d 100755 --- a/manifest.php +++ b/manifest.php @@ -25,6 +25,7 @@ use oat\taoQtiItem\controller\QtiPreview; use oat\taoQtiItem\install\scripts\addValidationSettings; use oat\taoQtiItem\install\scripts\ExtendConfigurationRegistry; +use oat\taoQtiItem\install\scripts\RemoveLegacyGenericLomExtractor; use oat\taoQtiItem\install\scripts\SetDragAndDropConfig; use oat\taoQtiItem\install\scripts\setXMLParserConfig; use oat\taoQtiItem\model\qti\CustomInteractionAsset\ServiceProvider\{ @@ -93,7 +94,8 @@ RegisterNpmPaths::class, ExtendConfigurationRegistry::class, SetupQtiMetadataImportExportService::class, - AddLabelInjectorForExport::class + AddLabelInjectorForExport::class, + RemoveLegacyGenericLomExtractor::class, ] ], 'local' => [ From f9a2e290f6ca8e3eb04daa264e1ebdc513380944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Wed, 13 Nov 2024 14:04:03 +0100 Subject: [PATCH 4/5] fix: remove metadata injector --- model/qti/ImportService.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/model/qti/ImportService.php b/model/qti/ImportService.php index b9cef682e2..f110bec892 100755 --- a/model/qti/ImportService.php +++ b/model/qti/ImportService.php @@ -486,8 +486,6 @@ public function importQtiItem( //load the information about resources in the manifest try { $resourceIdentifier = $qtiItemResource->getIdentifier(); - - $this->getMetadataImporter()->setMetadataValues($metadataValues); $guardian = false; if ($enableMetadataGuardians === true) { @@ -544,11 +542,8 @@ public function importQtiItem( } $targetClass = $this->getMetadataImporter()->classLookUp($resourceIdentifier, $createdClasses); - $tmpQtiFile = $tmpFolder . helpers_File::urlToPath($qtiItemResource->getFile()); - common_Logger::i('file :: ' . $qtiItemResource->getFile()); - $qtiModel = $this->createQtiItemModel($tmpQtiFile); if ( @@ -635,8 +630,6 @@ public function importQtiItem( $qtiModel = $this->createQtiItemModel($itemAssetManager->getItemContent(), false); $qtiService->saveDataItemToRdfItem($qtiModel, $rdfItem); - $this->getMetadataImporter()->inject($resourceIdentifier, $rdfItem); - if ($importMetadataEnabled && isset($metadataValues[$resourceIdentifier])) { $this->getMappedMetadataInjector()->inject( $metaMedataValues, From 101b7ae97e2bf90bd765f820683c87898a64e6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Marsza=C5=82?= Date: Wed, 13 Nov 2024 14:44:57 +0100 Subject: [PATCH 5/5] fix: ignore phpcs for line lenght --- install/scripts/RemoveLegacyGenericLomExtractor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/scripts/RemoveLegacyGenericLomExtractor.php b/install/scripts/RemoveLegacyGenericLomExtractor.php index 960a05030a..6c9386b877 100644 --- a/install/scripts/RemoveLegacyGenericLomExtractor.php +++ b/install/scripts/RemoveLegacyGenericLomExtractor.php @@ -27,7 +27,6 @@ class RemoveLegacyGenericLomExtractor extends InstallAction { - public function __invoke($params) { $metadataService = $this->getServiceManager()->getContainer()->get(MetadataService::SERVICE_ID); @@ -35,6 +34,7 @@ public function __invoke($params) $extractors = $exportOption->getOption('extractors'); $extractors = array_filter($extractors, function ($extractor) { + //phpcs:ignore return $extractor !== 'oat\taoQtiItem\model\qti\metadata\ontology\GenericLomOntologyClassificationExtractor'; });