Skip to content

Commit

Permalink
feat: Add DeliveryItemTypeRepository service
Browse files Browse the repository at this point in the history
  • Loading branch information
yaraslau-kavaliou committed Aug 30, 2023
1 parent 57e9815 commit 7b38453
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
3 changes: 3 additions & 0 deletions config/default/DeliveryItemTypeRepository.conf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return new oat\taoQtiTest\models\DeliveryItemTypeRepository([]);
2 changes: 2 additions & 0 deletions model/Container/TestQtiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use oat\generis\model\data\Ontology;
use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\generis\model\DependencyInjection\ServiceOptions;
use oat\oatbox\event\EventManager;
use oat\oatbox\log\LoggerService;
use oat\taoQtiItem\model\qti\Service;
Expand All @@ -42,6 +43,7 @@
use oat\taoQtiTest\model\Service\SkipService;
use oat\taoQtiTest\model\Service\StoreTraceVariablesService;
use oat\taoQtiTest\model\Service\TimeoutService;
use oat\taoQtiTest\models\DeliveryItemTypeRepository;
use oat\taoQtiTest\models\runner\QtiRunnerService;
use oat\taoQtiTest\models\TestModelService;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
Expand Down
63 changes: 63 additions & 0 deletions models/classes/DeliveryItemTypeRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2023 (original work) Open Assessment Technologies SA ;
*
*/

namespace oat\taoQtiTest\models;

use oat\oatbox\service\ConfigurableService;

class DeliveryItemTypeRepository extends ConfigurableService
{
public const SERVICE_ID = 'taoQtiTest/DeliveryItemTypeRepository';

private const OPTION_DEFAULT_ITEM_TYPE = 'defaultItemType';

/**
* Sets the default item type the viewer should manage
*/
public function setDefaultItemType(string $type)
{
$this->setOption(self::OPTION_DEFAULT_ITEM_TYPE, $type);
}

/**
* Gets the default item type the viewer should manage
* @return string|bool
*/
public function getDefaultItemType()
{
if ($this->hasOption(self::OPTION_DEFAULT_ITEM_TYPE)) {
return $this->getOption(self::OPTION_DEFAULT_ITEM_TYPE);
}

return false;
}

/**
* Gets the type of item the viewer should manage
* @todo determine the item type from the $resultIdentifier
* @param string $resultIdentifier
* @return string
*/
public function getDeliveryItemType($resultIdentifier)
{
return $this->getDefaultItemType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use oat\taoQtiTest\models\classes\render\CustomInteraction\CustomInteractionPostProcessorAllocator;
use oat\taoQtiTest\models\classes\render\CustomInteraction\PostProcessor\TextReaderPostProcessor;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

class CustomInteractionPostProcessingServiceProvider implements ContainerServiceProviderInterface
Expand All @@ -49,5 +48,6 @@ public function __invoke(ContainerConfigurator $configurator): void
->args([
[TextReaderPostProcessor::INTERACTION_IDENTIFIER => service(TextReaderPostProcessor::class)]
]);

}
}

0 comments on commit 7b38453

Please sign in to comment.