Skip to content

Commit

Permalink
Merge branch 'release-54.33.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Mar 6, 2025
2 parents e799029 + d0a519d commit 833c9d3
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 62 deletions.
2 changes: 1 addition & 1 deletion locales/ku-IQ/lang.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<rdf:value><![CDATA[ku-IQ]]></rdf:value>
<tao:LanguageUsages xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsageGUI"/>
<tao:LanguageUsages xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsageData"/>
<tao:LanguageOrientation xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#OrientationLeftToRight"/>
<tao:LanguageOrientation xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#OrientationRightToLeft"/>
</rdf:Description>
</rdf:RDF>
2 changes: 1 addition & 1 deletion locales/ug-CN/lang.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<rdf:value><![CDATA[ug-CN]]></rdf:value>
<tao:LanguageUsages xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsageGUI"/>
<tao:LanguageUsages xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#LanguageUsageData"/>
<tao:LanguageOrientation xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#OrientationLeftToRight"/>
<tao:LanguageOrientation xmlns:tao="http://www.tao.lu/Ontologies/TAO.rdf#" rdf:resource="http://www.tao.lu/Ontologies/TAO.rdf#OrientationRightToLeft"/>
</rdf:Description>
</rdf:RDF>
16 changes: 7 additions & 9 deletions models/classes/Translation/Service/TranslationUniqueIdSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.
* Copyright (c) 2024-2025 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);
Expand Down Expand Up @@ -59,24 +59,22 @@ public function addQtiIdentifierSetter(AbstractQtiIdentifierSetter $qtiIdentifie

public function __invoke(core_kernel_classes_Resource $resource): void
{
if (
!$this->featureFlagChecker->isEnabled('FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER')
|| !$this->featureFlagChecker->isEnabled('FEATURE_FLAG_TRANSLATION_ENABLED')
) {
if (!$this->featureFlagChecker->isEnabled('FEATURE_FLAG_TRANSLATION_ENABLED')) {
return;
}

$originalResource = $this->getOriginalResource($resource);
$uniqueIdentifier = $this->getUniqueId($originalResource);

$resource->editPropertyValues(
$this->getProperty(TaoOntology::PROPERTY_UNIQUE_IDENTIFIER),
$uniqueIdentifier
);
$this->getQtiIdentifierSetter($resource)->set([
AbstractQtiIdentifierSetter::OPTION_RESOURCE => $resource,
AbstractQtiIdentifierSetter::OPTION_IDENTIFIER => $uniqueIdentifier,
]);

$resource->editPropertyValues(
$this->getProperty(TaoOntology::PROPERTY_UNIQUE_IDENTIFIER),
$uniqueIdentifier
);
}

private function getOriginalResource(core_kernel_classes_Resource $resource): core_kernel_classes_Resource
Expand Down
18 changes: 17 additions & 1 deletion models/classes/class.LanguageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use oat\generis\model\kernel\persistence\file\FileIterator;
use oat\tao\model\ClientLibConfigRegistry;
use oat\tao\model\ClientLibRegistry;
use oat\tao\model\TaoOntology;

/**
* Short description of class tao_models_classes_LanguageService
Expand Down Expand Up @@ -399,7 +400,22 @@ public function isRtlLanguage(string $languageCode): bool
{
$config = $this->getClientLibConfigRegistry()->get('util/locale') ?? [];

return in_array($languageCode, $config['rtl'] ?? [], true);
if (in_array($languageCode, $config['rtl'] ?? [], true)) {
return true;
}

$language = $this->getModel()
->getResource(sprintf('http://www.tao.lu/Ontologies/TAO.rdf#Lang%s', $languageCode));

$orientationProperty = $this->getModel()
->getProperty(tao_models_classes_LanguageService::PROPERTY_LANGUAGE_ORIENTATION);
$orientationValue = $language->getOnePropertyValue($orientationProperty);

if ($orientationValue) {
return $orientationValue->getUri() === tao_models_classes_LanguageService::INSTANCE_ORIENTATION_RTL;
}

return false;
}

private function getClientLibConfigRegistry(): ClientLibConfigRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* 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.
* Copyright (c) 2024-2025 (original work) Open Assessment Technologies SA.
*/

declare(strict_types=1);
Expand Down Expand Up @@ -62,12 +62,12 @@ protected function setUp(): void
$this->sut->addQtiIdentifierSetter($this->qtiIdentifierSetter, 'resourceType');
}

public function testUniqueIdFeatureDisabled(): void
public function testTranslationFeatureDisabled(): void
{
$this->featureFlagChecker
->expects($this->once())
->method('isEnabled')
->with('FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER')
->with('FEATURE_FLAG_TRANSLATION_ENABLED')
->willReturn(false);

$this->resource
Expand All @@ -81,38 +81,13 @@ public function testUniqueIdFeatureDisabled(): void
$this->sut->__invoke($this->resource);
}

public function testTranslationFeatureDisabled(): void
{
$this->featureFlagChecker
->expects($this->exactly(2))
->method('isEnabled')
->withConsecutive(
['FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER'],
['FEATURE_FLAG_TRANSLATION_ENABLED']
)
->willReturnOnConsecutiveCalls(true, false);

$this->resource
->expects($this->never())
->method($this->anything());

$this->qtiIdentifierSetter
->expects($this->never())
->method('set');

$this->sut->__invoke($this->resource);
}

public function testNoOriginalResourceUri(): void
{
$this->featureFlagChecker
->expects($this->exactly(2))
->expects($this->once())
->method('isEnabled')
->withConsecutive(
['FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER'],
['FEATURE_FLAG_TRANSLATION_ENABLED']
)
->willReturnOnConsecutiveCalls(true, true);
->with('FEATURE_FLAG_TRANSLATION_ENABLED')
->willReturn(true);

$originalResourceUriProperty = $this->createPropertyMock();

Expand Down Expand Up @@ -142,13 +117,10 @@ public function testNoOriginalResourceUri(): void
public function testNoUniqueId(): void
{
$this->featureFlagChecker
->expects($this->exactly(2))
->expects($this->once())
->method('isEnabled')
->withConsecutive(
['FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER'],
['FEATURE_FLAG_TRANSLATION_ENABLED']
)
->willReturnOnConsecutiveCalls(true, true);
->with('FEATURE_FLAG_TRANSLATION_ENABLED')
->willReturn(true);

$originalResourceUriProperty = $this->createPropertyMock();
$uniqueIdProperty = $this->createPropertyMock();
Expand Down Expand Up @@ -199,13 +171,10 @@ public function testNoUniqueId(): void
public function testNoQtiIdentifierSetterForSpecifiedType(): void
{
$this->featureFlagChecker
->expects($this->exactly(2))
->expects($this->once())
->method('isEnabled')
->withConsecutive(
['FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER'],
['FEATURE_FLAG_TRANSLATION_ENABLED']
)
->willReturnOnConsecutiveCalls(true, true);
->with('FEATURE_FLAG_TRANSLATION_ENABLED')
->willReturn(true);

$originalResourceUriProperty = $this->createPropertyMock();
$uniqueIdProperty = $this->createPropertyMock();
Expand Down Expand Up @@ -246,7 +215,7 @@ public function testNoQtiIdentifierSetterForSpecifiedType(): void
->willReturn($identifier);

$this->resource
->expects($this->once())
->expects($this->never())
->method('editPropertyValues')
->with($uniqueIdProperty, 'identifier');

Expand All @@ -268,13 +237,10 @@ public function testNoQtiIdentifierSetterForSpecifiedType(): void
public function testSuccess(): void
{
$this->featureFlagChecker
->expects($this->exactly(2))
->expects($this->once())
->method('isEnabled')
->withConsecutive(
['FEATURE_FLAG_UNIQUE_NUMERIC_QTI_IDENTIFIER'],
['FEATURE_FLAG_TRANSLATION_ENABLED']
)
->willReturnOnConsecutiveCalls(true, true);
->with('FEATURE_FLAG_TRANSLATION_ENABLED')
->willReturn(true);

$originalResourceUriProperty = $this->createPropertyMock();
$uniqueIdProperty = $this->createPropertyMock();
Expand Down

0 comments on commit 833c9d3

Please sign in to comment.