Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add delivery item service #2398

Merged
merged 3 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions config/default/DeliveryItemTypeService.conf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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;
*/

return new oat\taoQtiTest\models\DeliveryItemTypeService();
47 changes: 47 additions & 0 deletions migrations/Version202309080855452260_taoQtiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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;
*/

declare(strict_types=1);

namespace oat\taoQtiTest\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\taoQtiTest\models\DeliveryItemTypeService;

final class Version202309080855452260_taoQtiTest extends AbstractMigration
{
public function getDescription(): string
{
return 'Register DeliveryItemTypeService';
}

public function up(Schema $schema): void
{
$deliveryItemTypeService = new DeliveryItemTypeService();

$this->getServiceLocator()->register(DeliveryItemTypeService::SERVICE_ID, $deliveryItemTypeService);
}

public function down(Schema $schema): void
{
$this->throwIrreversibleMigrationException();
}
}
63 changes: 63 additions & 0 deletions models/classes/DeliveryItemTypeService.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 DeliveryItemTypeService extends ConfigurableService
{
public const SERVICE_ID = 'taoQtiTest/DeliveryItemTypeService';

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();
}
}
Loading