Skip to content

Commit

Permalink
Merge branch 'release-48.17.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 18, 2024
2 parents 6d779d5 + 9532431 commit 8dabd67
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 131 deletions.
35 changes: 0 additions & 35 deletions models/classes/Qti/Converter/TestConverter.php

This file was deleted.

10 changes: 1 addition & 9 deletions models/classes/Qti/ServiceProvider/QtiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@

use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\oatbox\log\LoggerService;
use oat\taoQtiItem\model\qti\converter\CaseConversionService;
use oat\taoQtiTest\models\Qti\Converter\TestConverter;
use oat\taoQtiTest\models\Qti\Identifier\Service\QtiIdentifierSetter;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use taoQtiTest_models_classes_QtiTestService;

use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

class QtiServiceProvider implements ContainerServiceProviderInterface
Expand All @@ -43,12 +42,5 @@ public function __invoke(ContainerConfigurator $configurator): void
service(taoQtiTest_models_classes_QtiTestService::class),
service(LoggerService::SERVICE_ID),
]);

$services
->set(TestConverter::class)
->args([
service(CaseConversionService::class),
])
->public();
}
}
59 changes: 23 additions & 36 deletions models/classes/class.QtiTestService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand All @@ -21,31 +22,27 @@
use oat\oatbox\filesystem\Directory;
use oat\oatbox\filesystem\File;
use oat\oatbox\filesystem\FileSystemService;
use oat\oatbox\reporting\Report;
use oat\tao\model\IdentifierGenerator\Generator\IdentifierGeneratorInterface;
use oat\tao\model\IdentifierGenerator\Generator\IdentifierGeneratorProxy;
use oat\tao\model\resources\ResourceAccessDeniedException;
use oat\tao\model\resources\SecureResourceServiceInterface;
use oat\tao\model\TaoOntology;
use oat\taoItems\model\Command\DeleteItemCommand;
use oat\taoQtiItem\model\qti\converter\ManifestConverter;
use oat\taoQtiItem\model\qti\ImportService;
use oat\taoQtiItem\model\qti\metadata\importer\MetadataImporter;
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\MetaMetadataExtractor;
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\PackageParser;
use oat\taoQtiItem\model\qti\Resource;
use oat\taoQtiItem\model\qti\Service;
use oat\taoQtiTest\models\cat\AdaptiveSectionInjectionException;
use oat\taoQtiTest\models\cat\CatEngineNotFoundException;
use oat\taoQtiTest\models\cat\CatService;
use oat\taoQtiTest\models\classes\event\TestImportedEvent;
use oat\taoQtiTest\models\metadata\MetadataTestContextAware;
use oat\taoQtiTest\models\Qti\Converter\TestConverter;
use oat\taoQtiTest\models\render\QtiPackageImportPreprocessing;
use oat\taoQtiTest\models\test\AssessmentTestXmlFactory;
use oat\taoTests\models\event\TestUpdatedEvent;
Expand All @@ -58,8 +55,9 @@
use qtism\data\storage\xml\marshalling\UnmarshallingException;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\storage\xml\XmlStorageException;
use taoQtiTest_models_classes_import_TestImportForm as TestImportForm;
use taoTests_models_classes_TestsService as TestService;
use oat\oatbox\reporting\Report;
use taoQtiTest_models_classes_import_TestImportForm as TestImportForm;

/**
* the QTI TestModel service.
Expand Down Expand Up @@ -203,7 +201,7 @@ protected function setDefaultModel($test): void
* Save the json formated test into the test resource.
*
* @param core_kernel_classes_Resource $test
* @param string $json
* @param string $json
*
* @return bool true if saved
*
Expand All @@ -214,7 +212,7 @@ public function saveJsonTest(core_kernel_classes_Resource $test, $json): bool
{
$saved = false;

if (!empty($json)) {
if (! empty($json)) {
$this->verifyItemPermissions($test, $json);

$doc = $this->getDoc($test);
Expand Down Expand Up @@ -268,7 +266,7 @@ public function setItems(core_kernel_classes_Resource $test, array $items)
return false;
}

/**
/**
* Save the QTI test : set the items sequence and some options.
*
* @param core_kernel_classes_Resource $test A Resource describing a QTI Assessment Test.
Expand All @@ -282,7 +280,7 @@ public function save(core_kernel_classes_Resource $test, array $items)
try {
$doc = $this->getDoc($test);
$this->setItemsToDoc($doc, $items);
$saved = $this->saveDoc($test, $doc);
$saved = $this->saveDoc($test, $doc);
} catch (StorageException $e) {
throw new taoQtiTest_models_classes_QtiTestServiceException(
"An error occured while dealing with the QTI-XML test: " . $e->getMessage(),
Expand All @@ -308,7 +306,7 @@ public function getIdentifierFor(XmlDocument $doc, $qtiType)
do {
$identifier = $this->generateIdentifier($doc, $qtiType, $index);
$index++;
} while (!$this->isIdentifierUnique($components, $identifier));
} while (! $this->isIdentifierUnique($components, $identifier));

return $identifier;
}
Expand Down Expand Up @@ -365,7 +363,7 @@ public function importMultipleTests(
?string $packageLabel = null
) {
$testClass = $targetClass;
$report = new Report(Report::TYPE_INFO);
$report = new common_report_Report(common_report_Report::TYPE_INFO);
$validPackage = false;
$validManifest = false;
$testsFound = false;
Expand All @@ -383,25 +381,24 @@ public function importMultipleTests(
// phpcs:enable Generic.Files.LineLength

try {
$qtiPackageParser = new PackageParser($file);
$qtiPackageParser = new taoQtiTest_models_classes_PackageParser($file);
$qtiPackageParser->validate();
$validPackage = true;
} catch (Exception $e) {
$report->add(Report::createError($invalidArchiveMsg));
$report->add(common_report_Report::createFailure($invalidArchiveMsg));
}

// Validate the manifest (well formed XML, valid against the schema).
if ($validPackage === true) {
$folder = $qtiPackageParser->extract();

if (is_dir($folder) === false) {
$report->add(Report::createError($invalidArchiveMsg));
$report->add(common_report_Report::createFailure($invalidArchiveMsg));
} else {
$file = $folder . 'imsmanifest.xml';
$qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($file);
$qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
$this->propagate($qtiManifestParser);
$this->getManifestConverter()->convert($file, $qtiManifestParser);
// We validate manifest file against QTI 3.0
$qtiManifestParser->validate();

if ($qtiManifestParser->isValid() === true) {
$validManifest = true;

Expand All @@ -414,10 +411,10 @@ public function importMultipleTests(

if ($testsFound !== true) {
$report->add(
Report::createError(
// phpcs:disable Generic.Files.LineLength
common_report_Report::createFailure(
// phpcs:disable Generic.Files.LineLength
__("Package is valid but no tests were found. Make sure that it contains valid QTI tests.")
// phpcs:enable Generic.Files.LineLength
// phpcs:enable Generic.Files.LineLength
)
);
} else {
Expand Down Expand Up @@ -580,11 +577,12 @@ protected function importTest(

// Create the report that will hold information about the import
// of $qtiTestResource in TAO.
$report = new Report(Report::TYPE_INFO);
$report = new common_report_Report(common_report_Report::TYPE_INFO);

// Load and validate the manifest
$qtiManifestParser = new taoQtiTest_models_classes_ManifestParser($folder . 'imsmanifest.xml');
$this->propagate($qtiManifestParser);
$qtiManifestParser->validate();

$domManifest = new DOMDocument('1.0', 'UTF-8');
$domManifest->load($folder . 'imsmanifest.xml');
Expand Down Expand Up @@ -622,8 +620,6 @@ protected function importTest(
)
);
} else {
//Convert to QTI 2.2
$this->getTestConverter()->convert($expectedTestFile);
// -- Load the test in a QTISM flavour.
$testDefinition = new XmlDocument();

Expand Down Expand Up @@ -1083,6 +1079,7 @@ public function getTestFile(core_kernel_classes_Resource $test)
*/
public function getDoc(core_kernel_classes_Resource $test)
{

$doc = new XmlDocument('2.1');
$doc->loadFromString($this->getQtiTestFile($test)->read());
return $doc;
Expand Down Expand Up @@ -1436,7 +1433,7 @@ public function getQtiTestTemplateFileAsString()
*/
protected function getMetadataImporter()
{
if (!$this->metadataImporter) {
if (! $this->metadataImporter) {
$this->metadataImporter = $this->getServiceLocator()->get(MetadataService::SERVICE_ID)->getImporter();
}
return $this->metadataImporter;
Expand Down Expand Up @@ -1604,14 +1601,4 @@ private function getTestLabel(array $testMetadata, XmlDocument $testDefinition):

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

private function getManifestConverter(): ManifestConverter
{
return $this->getPsrContainer()->get(ManifestConverter::class);
}

private function getTestConverter(): TestConverter
{
return $this->getPsrContainer()->get(TestConverter::class);
}
}
51 changes: 0 additions & 51 deletions models/classes/render/QTI3PackagePreprocessing.php

This file was deleted.

0 comments on commit 8dabd67

Please sign in to comment.