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/hkd 6/integration #477

Open
wants to merge 50 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
fc74469
feat: introduce new translator role
gabrielfs7 Sep 4, 2024
fcfe23e
chore: add metadata to tests
shpran Sep 5, 2024
9af0ea8
chore: move props to tao-core
shpran Sep 5, 2024
556812e
chore: set domains for new props
shpran Sep 5, 2024
2c62e4d
chore: add new field with completion status
shpran Sep 9, 2024
652dd41
feat: hide translations buttons based on role
gabrielfs7 Sep 9, 2024
ce7539b
chore: use form modifiers for edit instance form, fix rdf schema
shpran Sep 9, 2024
5535b42
chore: bring specific data for tests
gabrielfs7 Sep 10, 2024
d62dc3e
chore: add constant with new prop, add new modifier
shpran Sep 10, 2024
20211cc
chore: use constants instead of string
gabrielfs7 Sep 10, 2024
ce43571
chore: use proxies instead of manager
shpran Sep 10, 2024
e8fa8c3
chore: fix cs
shpran Sep 10, 2024
ba0e5e6
chore: add composer dependencies
gabrielfs7 Sep 11, 2024
893d475
Merge branch 'feat/ADF-1779/add-translator-role' of https://github.co…
gabrielfs7 Sep 11, 2024
ba32536
chore: add unit tests for modifier
shpran Sep 11, 2024
8ab2a47
chore: add event listener to set translation type
shpran Sep 11, 2024
5dabc45
chore: register listener
shpran Sep 11, 2024
221ccb1
chore: add property alias
shpran Sep 11, 2024
587a2b2
chore: add missing dependency for clone
gabrielfs7 Sep 12, 2024
39d6414
chore: add post translation for tests
gabrielfs7 Sep 12, 2024
db8c6c1
chore: only do translation over tao-core extension
gabrielfs7 Sep 12, 2024
2144427
chore: missing return type
gabrielfs7 Sep 12, 2024
48a1239
chore: use direct event class, add unit test
shpran Sep 12, 2024
77fdd90
chore: fix cs
shpran Sep 13, 2024
bdf7325
chore: default values during test creation
shpran Sep 13, 2024
7c021f5
Merge pull request #476 from oat-sa/feat/ADF-1779/add-translator-role
gabrielfs7 Sep 13, 2024
f8bab4a
chore: add new constants, convert literal to string
shpran Sep 13, 2024
a4bf4d5
chore: remove translation completion for original tests
shpran Sep 13, 2024
00c8cc4
chore: update dependencies
gabrielfs7 Sep 16, 2024
44545ab
chore: use standard feature flag name
gabrielfs7 Sep 16, 2024
8e0736b
chore: use proper endpoint
gabrielfs7 Sep 16, 2024
a925101
chore: add new metadata to link original resource
gabrielfs7 Sep 18, 2024
fbb2af4
chore: provide new form modifier, remove type from item properties
shpran Sep 18, 2024
bdb5c25
Merge pull request #478 from oat-sa/feature/ADF-1787/translatable-test
gabrielfs7 Sep 19, 2024
e179096
chore: fix unit tests
shpran Sep 19, 2024
09236f5
chore: attach service and fix ontolgy method
gabrielfs7 Sep 19, 2024
72f0a8a
chore: add missing model
gabrielfs7 Sep 20, 2024
f19f24f
chore: use translation language retriever instead of user language se…
shpran Sep 30, 2024
3b808a6
refactor: change the icon for the translate action
jsconan Oct 14, 2024
578e07f
feat: add the action for managing the test translations
jsconan Oct 14, 2024
c2f4adf
Merge pull request #480 from oat-sa/feature/ADF-1788/translation-list-ui
jsconan Oct 14, 2024
3848192
feat: forward the translation parameters
jsconan Oct 14, 2024
c4458ad
Merge pull request #481 from oat-sa/feature/ADF-1789/forward-translat…
jsconan Oct 16, 2024
1cd3991
Merge branch 'develop' into feat/HKD-6/integration
jsconan Oct 30, 2024
ce0bb0b
chore: bundle the assets
jsconan Oct 31, 2024
86a3ae1
fix: bypass metadata import issue
gabrielfs7 Nov 4, 2024
89fe434
feat: better handling of unique IDs
shpran Nov 4, 2024
ab08f01
chore: use new service to clone
gabrielfs7 Nov 5, 2024
8be1e7f
Merge pull request #484 from oat-sa/feat/adf-1802/unique-identifier
gabrielfs7 Nov 5, 2024
914db4f
chore: fix unit tests
shpran Nov 7, 2024
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
15 changes: 15 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,15 @@ 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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"require": {
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"oat-sa/generis": ">=15.24",
"oat-sa/tao-core": ">=53.0.0",
"oat-sa/tao-core": "dev-feat/HKD-6/integration as 99",
"oat-sa/extension-tao-backoffice": ">=6.0.0",
"oat-sa/extension-tao-item": ">=12.0.0"
"oat-sa/extension-tao-item": "dev-feat/HKD-6/integration as 99"
},
"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'
]
);
}
}
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';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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\Translation\Form\Modifier;

use core_kernel_classes_Literal;
use core_kernel_classes_Resource;
use oat\generis\model\data\Ontology;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\tao\model\form\Modifier\AbstractFormModifier;
use oat\tao\model\TaoOntology;
use oat\taoTests\models\TaoTestOntology;
use tao_helpers_form_Form as Form;
use tao_helpers_Uri;

class TranslationFormModifier extends AbstractFormModifier
{
private FeatureFlagCheckerInterface $featureFlagChecker;
private Ontology $ontology;

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

public function modify(Form $form, array $options = []): void
{
if (!$this->featureFlagChecker->isEnabled('FEATURE_FLAG_TRANSLATION_ENABLED')) {
$form->removeElement(tao_helpers_Uri::encode(TaoTestOntology::PROPERTY_TRANSLATION_COMPLETION));

return;
}

$instance = $this->ontology->getResource($form->getValue('uri'));

$translationType = $instance->getOnePropertyValue(
$this->ontology->getProperty(TaoOntology::PROPERTY_TRANSLATION_TYPE)
);
$translationTypeUri = $translationType instanceof core_kernel_classes_Literal
? (string) $translationType
: ($translationType instanceof core_kernel_classes_Resource ? $translationType->getUri() : null);

if (
empty($translationType)
|| $translationTypeUri === TaoOntology::PROPERTY_VALUE_TRANSLATION_TYPE_ORIGINAL
) {
$form->removeElement(tao_helpers_Uri::encode(TaoTestOntology::PROPERTY_TRANSLATION_COMPLETION));
}
}
}
Loading
Loading