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 c5a036b
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
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([]);
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();
}
}

0 comments on commit c5a036b

Please sign in to comment.