Skip to content

Commit

Permalink
Merge branch 'release-48.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 26, 2024
2 parents 9068f4e + 3938224 commit ecacad2
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"qtism/qtism": ">=0.28.3",
"oat-sa/generis": ">=15.39.0",
"oat-sa/tao-core": ">=54.23.0",
"oat-sa/tao-core": ">=54.25.0",
"oat-sa/extension-tao-item": ">=12.4.0",
"oat-sa/extension-tao-itemqti": ">=30.22.0",
"oat-sa/extension-tao-itemqti": ">=30.23.0",
"oat-sa/extension-tao-test": ">=16.3.0",
"oat-sa/extension-tao-delivery": ">=15.0.0",
"oat-sa/extension-tao-outcome": ">=13.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoQtiTest\models\Translation\Service;

use oat\generis\model\data\Ontology;
use oat\tao\model\Translation\Entity\ResourceTranslatableStatus;
use taoQtiTest_models_classes_QtiTestService;

class ResourceTranslatableStatusHandler
{
private taoQtiTest_models_classes_QtiTestService $testQtiService;
private Ontology $ontology;

public function __construct(taoQtiTest_models_classes_QtiTestService $testQtiService, Ontology $ontology)
{
$this->testQtiService = $testQtiService;
$this->ontology = $ontology;
}

public function __invoke(ResourceTranslatableStatus $status): void
{
$originalTest = $this->ontology->getResource($status->getUri());

$status->setEmpty(empty($this->testQtiService->getItems($originalTest)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
use oat\oatbox\log\LoggerService;
use oat\tao\model\TaoOntology;
use oat\tao\model\Translation\Repository\ResourceTranslationRepository;
use oat\tao\model\Translation\Service\ResourceTranslatableStatusRetriever;
use oat\tao\model\Translation\Service\TranslationCreationService;
use oat\tao\model\Translation\Service\TranslationSyncService as TaoTranslationSyncService;
use oat\tao\model\Translation\Service\TranslationUniqueIdSetter;
use oat\taoQtiTest\models\Qti\Identifier\Service\QtiIdentifierSetter;
use oat\taoQtiTest\models\Translation\Service\ResourceTranslatableStatusHandler;
use oat\taoQtiTest\models\Translation\Service\TestTranslator;
use oat\taoQtiTest\models\Translation\Service\TranslationPostCreationService;
use oat\taoQtiTest\models\Translation\Service\TranslationSyncService;
Expand All @@ -54,6 +56,13 @@ public function __invoke(ContainerConfigurator $configurator): void
service(LoggerService::SERVICE_ID),
]);

$services
->set(ResourceTranslatableStatusHandler::class, ResourceTranslatableStatusHandler::class)
->args([
service(taoQtiTest_models_classes_QtiTestService::class),
service(Ontology::SERVICE_ID),
]);

$services
->set(TranslationSyncService::class, TranslationSyncService::class)
->args([
Expand Down Expand Up @@ -104,5 +113,15 @@ public function __invoke(ContainerConfigurator $configurator): void
service(TranslationUniqueIdSetter::class),
]
);

$services
->get(ResourceTranslatableStatusRetriever::class)
->call(
'addCallable',
[
TaoOntology::CLASS_URI_TEST,
service(ResourceTranslatableStatusHandler::class)
]
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?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) 2024 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);

namespace oat\taoQtiTest\test\unit\models\classes\Translation\Service;

use core_kernel_classes_Resource;
use oat\generis\model\data\Ontology;
use oat\tao\model\TaoOntology;
use oat\tao\model\Translation\Entity\ResourceTranslatableStatus;
use oat\taoQtiTest\models\Translation\Service\ResourceTranslatableStatusHandler;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use taoQtiTest_models_classes_QtiTestService;

class ResourceTranslatableStatusHandlerTest extends TestCase
{
/** @var core_kernel_classes_Resource|MockObject */
private $test;

/** @var taoQtiTest_models_classes_QtiTestService|MockObject */
private $testQtiService;

/** @var Ontology|MockObject */
private $ontology;

private ResourceTranslatableStatusHandler $sut;
private ResourceTranslatableStatus $status;

protected function setUp(): void
{
$this->test = $this->createMock(core_kernel_classes_Resource::class);
$this->testQtiService = $this->createMock(taoQtiTest_models_classes_QtiTestService::class);
$this->ontology = $this->createMock(Ontology::class);
$this->status = new ResourceTranslatableStatus(
'testUri',
TaoOntology::CLASS_URI_TEST,
'languageUri',
true,
true
);

$this->sut = new ResourceTranslatableStatusHandler($this->testQtiService, $this->ontology);
}

public function testMustMarkAsEmptyIfTestHasNoItems(): void
{
$this->ontology
->expects($this->once())
->method('getResource')
->with('testUri')
->willReturn($this->test);

$this->testQtiService
->expects($this->once())
->method('getItems')
->with($this->test)
->willReturn([]);

$this->sut->__invoke($this->status);

$this->assertTrue($this->status->isEmpty());
}

public function testMustMarkAsNotEmptyIfTestHasNoItems(): void
{
$this->ontology
->expects($this->once())
->method('getResource')
->with('testUri')
->willReturn($this->test);

$this->testQtiService
->expects($this->once())
->method('getItems')
->with($this->test)
->willReturn([
$this->createMock(core_kernel_classes_Resource::class)
]);

$this->sut->__invoke($this->status);

$this->assertFalse($this->status->isEmpty());
}
}

0 comments on commit ecacad2

Please sign in to comment.