Skip to content

Commit

Permalink
Merge pull request #477 from oat-sa/feat/HKD-6/integration
Browse files Browse the repository at this point in the history
Feat/hkd 6/integration
  • Loading branch information
shpran authored Nov 11, 2024
2 parents 6e92601 + b87ac68 commit 32e99ff
Show file tree
Hide file tree
Showing 27 changed files with 1,310 additions and 15 deletions.
23 changes: 23 additions & 0 deletions actions/class.Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
use oat\tao\model\controller\SignedFormInstance;
use oat\tao\model\resources\Service\ClassDeleter;
use oat\tao\model\routing\AnnotationReader\security;
use oat\taoTests\models\Form\Modifier\FormModifierProxy;
use oat\taoTests\models\Translation\Form\Modifier\TranslationFormModifierProxy;
use tao_helpers_form_FormContainer as FormContainer;
use oat\generis\model\resource\Service\ResourceDeleter;
use oat\tao\model\resources\Contract\ClassDeleterInterface;
Expand Down Expand Up @@ -114,6 +116,10 @@ public function editTest()
$this->getDependsOnPropertyValidator(),
],
],
FormContainer::FORM_MODIFIERS => [
FormModifierProxy::class,
TranslationFormModifierProxy::class,
],
]
);
$myForm = $formContainer->getForm();
Expand Down Expand Up @@ -235,6 +241,23 @@ public function authoring()
if (!empty($authoringUrl)) {
$userId = common_session_SessionManager::getSession()->getUser()->getIdentifier();
LockManager::getImplementation()->setLock($test, $userId);

// Add support for the translation and the side-by-side authoring tool
if ($this->getRequestParameter('translation') !== null) {
$authoringUrl = sprintf(
'%s&translation=%s',
$authoringUrl,
$this->getRequestParameter('translation')
);
}
if ($this->getRequestParameter('originResourceUri') !== null) {
$authoringUrl = sprintf(
'%s&originResourceUri=%s',
$authoringUrl,
$this->getRequestParameter('originResourceUri')
);
}

return $this->forwardUrl($authoringUrl);
}
throw new common_exception_NoImplementation();
Expand Down
3 changes: 3 additions & 0 deletions actions/structures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<action id="test-new" name="New test" url="/taoTests/Tests/addInstance" context="resource" group="tree" binding="instanciate">
<icon id="icon-test"/>
</action>
<action id="test-translate" name="Translate" url="/tao/Translation/translate" context="instance" group="tree" binding="translateTest">
<icon id="icon-replace"/>
</action>
</actions>
</section>
</sections>
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
},
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.24",
"oat-sa/tao-core": ">=53.0.0",
"oat-sa/generis": ">=15.39.0",
"oat-sa/tao-core": ">=54.23.0",
"oat-sa/extension-tao-backoffice": ">=6.0.0",
"oat-sa/extension-tao-item": ">=12.0.0"
"oat-sa/extension-tao-item": ">=12.4.0"
},
"autoload": {
"psr-4": {
Expand Down
20 changes: 17 additions & 3 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\user\TaoRoles;
use oat\taoTests\models\Copier\CopierServiceProvider;
use oat\taoTests\models\Form\ServiceProvider\FormServiceProvider;
use oat\taoTests\models\Translation\ServiceProvider\TranslationServiceProvider;
use oat\taoTests\models\user\TaoTestsRoles;
use oat\taoTests\scripts\update\Updater;
use oat\taoTests\scripts\install\SetupProvider;
use oat\taoTests\scripts\install\RegisterFrontendPaths;
use oat\taoTests\scripts\install\RegisterTestPluginService;
use oat\taoTests\scripts\install\RegisterTestProviderService;
use oat\taoTests\scripts\install\RegisterTestPreviewerRegistryService;
use oat\taoTests\scripts\install\RegisterTestProviderService;
use oat\taoTests\scripts\install\SetupEventListeners;
use oat\taoTests\scripts\install\SetupProvider;
use oat\taoTests\scripts\update\Updater;

$extpath = __DIR__ . DIRECTORY_SEPARATOR;

Expand All @@ -62,6 +65,7 @@
RegisterFrontendPaths::class,
RegisterTestPreviewerRegistryService::class,
SetupProvider::class,
SetupEventListeners::class,
],
],
'update' => Updater::class,
Expand Down Expand Up @@ -96,6 +100,14 @@
AccessRule::GRANT,
TaoTestsRoles::RESTRICTED_TEST_AUTHOR,
['ext' => 'taoTests', 'mod' => 'Tests']
],
[
AccessRule::GRANT,
TaoTestsRoles::TEST_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
]
],
'optimizableClasses' => [
Expand All @@ -122,5 +134,7 @@
],
'containerServiceProviders' => [
CopierServiceProvider::class,
TranslationServiceProvider::class,
FormServiceProvider::class,
],
];
85 changes: 85 additions & 0 deletions migrations/Version202409060743452141_taoTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

namespace oat\taoTests\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\oatbox\event\EventManager;
use oat\oatbox\reporting\Report;
use oat\tao\model\accessControl\func\AccessRule;
use oat\tao\model\accessControl\func\AclProxy;
use oat\tao\model\menu\SectionVisibilityFilter;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\tao\scripts\update\OntologyUpdater;
use oat\taoTests\models\event\TestCreatedEvent;
use oat\taoTests\models\Translation\Listener\TestCreatedEventListener;
use oat\taoTests\models\user\TaoTestsRoles;

final class Version202409060743452141_taoTests extends AbstractMigration
{
public function getDescription(): string
{
return 'Add new Test Translator Role, sync models and add new listener';
}

public function up(Schema $schema): void
{
OntologyUpdater::syncModels();

AclProxy::applyRule($this->getRule());

$this->addReport(Report::createSuccess('Applied rules for role ' . TaoTestsRoles::TEST_TRANSLATOR));

/** @var SectionVisibilityFilter $sectionVisibilityFilter */
$sectionVisibilityFilter = $this->getServiceManager()->get(SectionVisibilityFilter::SERVICE_ID);

$sectionVisibilityFilter->showSectionByFeatureFlag(
$sectionVisibilityFilter->createSectionPath(
[
'manage_tests',
'test-translate'
]
),
'FEATURE_FLAG_TRANSLATION_ENABLED'
);
$this->getServiceManager()->register(SectionVisibilityFilter::SERVICE_ID, $sectionVisibilityFilter);

$this->addReport(
Report::createSuccess('Hide test section for feature flag FEATURE_FLAG_TRANSLATION_ENABLED')
);

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->attach(
TestCreatedEvent::class,
[TestCreatedEventListener::class, 'populateTranslationProperties']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}

public function down(Schema $schema): void
{
AclProxy::revokeRule($this->getRule());

/** @var EventManager $eventManager */
$eventManager = $this->getServiceManager()->get(EventManager::SERVICE_ID);
$eventManager->detach(
TestCreatedEvent::class,
[TestCreatedEventListener::class, 'populateTranslationProperties']
);
$this->getServiceManager()->register(EventManager::SERVICE_ID, $eventManager);
}

private function getRule(): AccessRule
{
return new AccessRule(
AccessRule::GRANT,
TaoTestsRoles::TEST_TRANSLATOR,
[
'ext' => 'tao',
'mod' => 'Translation'
]
);
}
}
30 changes: 30 additions & 0 deletions migrations/Version202411111300542363_taoTests.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace oat\taoTests\migrations;

use Doctrine\DBAL\Schema\Schema;
use oat\tao\scripts\tools\migrations\AbstractMigration;
use oat\tao\scripts\update\OntologyUpdater;

/**
* phpcs:disable Squiz.Classes.ValidClassName
*/
final class Version202411111300542363_taoTests extends AbstractMigration
{
public function getDescription(): string
{
return 'Sync models';
}

public function up(Schema $schema): void
{
OntologyUpdater::syncModels();
}

public function down(Schema $schema): void
{
OntologyUpdater::syncModels();
}
}
6 changes: 6 additions & 0 deletions models/classes/Copier/CopierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ public function __invoke(ContainerConfigurator $configurator): void
[
tagged_iterator('tao.copier.permissions'),
]
)
->call(
'withEventManager',
[
service(EventManager::class),
]
);

$services
Expand Down
29 changes: 29 additions & 0 deletions models/classes/Form/Modifier/FormModifierProxy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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\taoTests\models\Form\Modifier;

use oat\tao\model\form\Modifier\AbstractFormModifier;

final class FormModifierProxy extends AbstractFormModifier
{
}
51 changes: 51 additions & 0 deletions models/classes/Form/ServiceProvider/FormServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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\taoTests\models\Form\ServiceProvider;

use oat\generis\model\DependencyInjection\ContainerServiceProviderInterface;
use oat\tao\model\form\Modifier\UniqueIdFormModifier;
use oat\taoTests\models\Form\Modifier\FormModifierProxy;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

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

class FormServiceProvider implements ContainerServiceProviderInterface
{
public function __invoke(ContainerConfigurator $configurator): void
{
$services = $configurator->services();

$services
->set(FormModifierProxy::class, FormModifierProxy::class)
->public();

$services
->get(FormModifierProxy::class)
->call(
'addModifier',
[
service(UniqueIdFormModifier::class),
]
);
}
}
32 changes: 32 additions & 0 deletions models/classes/TaoTestOntology.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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.
*
* phpcs:disable Generic.Files.LineLength
*/

declare(strict_types=1);

namespace oat\taoTests\models;

interface TaoTestOntology
{
public const PROPERTY_TRANSLATION_COMPLETION = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TranslationCompletion';
public const PROPERTY_VALUE_TRANSLATION_COMPLETION_MISSING_TRANSLATIONS = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TranslationCompletionStatusMissingTranslations';
public const PROPERTY_VALUE_TRANSLATION_COMPLETION_TRANSLATED = 'http://www.tao.lu/Ontologies/TAOTest.rdf#TranslationCompletionStatusTranslated';
}
Loading

0 comments on commit 32e99ff

Please sign in to comment.