Skip to content

Commit

Permalink
Merge branch 'release-12.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jan 28, 2025
2 parents 642e952 + 274b5b7 commit 39f011e
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions actions/class.ItemExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
* (under the project TAO-TRANSFER);
* 2009-2012 (update and modification) Public Research Centre Henri Tudor
* (under the project TAO-SUSTAIN & TAO-DEV);
* 2012-2018 (update and modification) Open Assessment Technologies SA;
* 2012-2025 (update and modification) Open Assessment Technologies SA;
*/

use oat\tao\model\featureFlag\FeatureFlagChecker;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use tao_models_classes_export_ExportHandler as ExportHandlerInterface;

/**
* This controller provide the actions to export items
*
Expand All @@ -34,6 +39,10 @@
*/
class taoItems_actions_ItemExport extends tao_actions_Export
{
//TODO: This was created only to temporary handle QTI3 Export feature. Will be removed.
private const QTI3_HANDLER = 'oat\taoQtiItem\model\Export\Qti3Package\Handler';
private const FEATURE_FLAG_QTI3_EXPORT = 'FEATURE_FLAG_QTI3_EXPORT';

/**
* overwrite the parent index to add the requiresRight for Items only
*
Expand All @@ -56,7 +65,9 @@ protected function getAvailableExportHandlers(): array
$impl = taoItems_models_classes_ItemsService::singleton()->getItemModelImplementation($model);
if (in_array('tao_models_classes_export_ExportProvider', class_implements($impl), true)) {
foreach ($impl->getExportHandlers() as $handler) {
array_unshift($returnValue, $handler);
if ($this->isHandlerEnabled($handler)) {
array_unshift($returnValue, $handler);
}
}
}
}
Expand All @@ -65,7 +76,7 @@ protected function getAvailableExportHandlers(): array
if (!count($instances)) {
$returnValue = array_filter(
$returnValue,
static function (tao_models_classes_export_ExportHandler $handler) {
static function (ExportHandlerInterface $handler) {
return $handler instanceof tao_models_classes_export_RdfExporter;
}
);
Expand All @@ -88,7 +99,7 @@ public function getClassInstances(): array

protected function getFormFactory(
array $handlers,
tao_models_classes_export_ExportHandler $exporter,
ExportHandlerInterface $exporter,
core_kernel_classes_Resource $selectedResource,
array $formData
): tao_actions_form_Export {
Expand Down Expand Up @@ -120,4 +131,21 @@ protected function getResourcesToExport()

return $resources;
}

/**
* TODO: This was created only to temporary handle QTI3 Export feature. Will be removed.
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function isHandlerEnabled(ExportHandlerInterface $handler): bool
{
if (
$handler instanceof self::QTI3_HANDLER
&& !$this->getPsrContainer()->get(FeatureFlagChecker::class)->isEnabled(self::FEATURE_FLAG_QTI3_EXPORT)
) {
return false;
}

return true;
}
}

0 comments on commit 39f011e

Please sign in to comment.