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/aut-3623/hide-features-in-solar-design #2475

Merged
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"oat-sa/oatbox-extension-installer": "~1.1||dev-master",
"qtism/qtism": ">=0.28.3",
"oat-sa/generis" : ">=15.22",
"oat-sa/tao-core": ">=54.14.0",
"oat-sa/tao-core": "dev-feat/AUT-3625/content-creation-mode-switch",
"oat-sa/extension-tao-item" : ">=12.1.0",
"oat-sa/extension-tao-itemqti" : ">=30.10.0",
"oat-sa/extension-tao-test" : ">=16.0.0",
Expand Down
17 changes: 17 additions & 0 deletions models/classes/xmlEditor/XmlEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@
namespace oat\taoQtiTest\models\xmlEditor;

use core_kernel_classes_Resource;
use oat\generis\model\GenerisRdf;
use oat\oatbox\service\ConfigurableService;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\tao\model\user\implementation\UserSettingsService;
use oat\tao\model\user\UserSettingsInterface;
use qtism\data\storage\xml\XmlDocument;
use taoQtiTest_models_classes_QtiTestService;

Expand Down Expand Up @@ -59,6 +63,14 @@ public function saveStringTest(core_kernel_classes_Resource $test, string $testS
*/
public function isLocked(): bool
{
$userSettings = $this->getUserSettingsService()->getCurrentUserSettings();
if (
$this->getFeatureFlagChecker()->isEnabled(FeatureFlagCheckerInterface::FEATURE_FLAG_SOLAR_DESIGN_ENABLED)
&& $userSettings->getSetting(UserSettingsInterface::INTERFACE_MODE) == GenerisRdf::PROPERTY_USER_INTERFACE_MODE_SIMPLE
) {
return true;
}

if (
$this->getFeatureFlagChecker()->isEnabled(self::FEATURE_FLAG_XML_EDITOR_ENABLED)
|| $this->getFeatureFlagChecker()->isEnabled(self::LEGACY_FEATURE_FLAG_XML_EDITOR_ENABLED)
Expand All @@ -78,4 +90,9 @@ private function getFeatureFlagChecker(): FeatureFlagChecker
{
return $this->getServiceManager()->getContainer()->get(FeatureFlagChecker::class);
}

public function getUserSettingsService(): UserSettingsService
{
return $this->getServiceManager()->getContainer()->get(UserSettingsService::class);
}
}
110 changes: 89 additions & 21 deletions test/unit/models/classes/xml/XmlEditorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
use common_ext_Extension;
use common_ext_ExtensionsManager;
use core_kernel_classes_Resource;
use oat\generis\model\GenerisRdf;
use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\tao\model\featureFlag\FeatureFlagCheckerInterface;
use oat\tao\model\user\implementation\UserSettings;
use oat\tao\model\user\implementation\UserSettingsService;
use oat\tao\model\user\UserSettingsInterface;
use oat\taoQtiTest\models\xmlEditor\XmlEditor;
use oat\taoQtiTest\models\xmlEditor\XmlEditorInterface;
use PHPUnit\Framework\MockObject\MockObject;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\storage\xml\XmlStorageException;
Expand Down Expand Up @@ -52,6 +58,9 @@ class XmlEditorTest extends TestCase
/** @var FeatureFlagChecker|MockObject */
private $featureFlagCheckerMock;

/** @var UserSettingsService|MockObject */
private $userSettingsService;

public function setUp(): void
{
$doc = new XmlDocument();
Expand All @@ -65,10 +74,12 @@ public function setUp(): void
->with($this->testResourceMock)
->willReturn($this->xmlDoc);
$this->featureFlagCheckerMock = $this->createMock(FeatureFlagChecker::class);
$this->userSettingsService = $this->createMock(UserSettingsService::class);

$this->serviceLocatorMock = $this->getServiceLocatorMock([
taoQtiTest_models_classes_QtiTestService::class => $this->qtiTestServiceMock,
FeatureFlagChecker::class => $this->featureFlagCheckerMock,
UserSettingsService::class => $this->userSettingsService
]);
}

Expand Down Expand Up @@ -175,46 +186,103 @@ public function testSaveStringTest()
/**
* @dataProvider getFeatureIsLockedData
*/
public function testIsLocked($configFlag, $newFeatureFlag, $legacyFeatureFlag, $expectedLock)
public function testIsLocked(array $options)
{
$service = new XmlEditor([XmlEditor::OPTION_XML_EDITOR_LOCK => $configFlag]);
$userSettings = $this->createMock(UserSettings::class);
$userSettings->method('getSetting')
->with(UserSettingsInterface::INTERFACE_MODE)
->willReturn($options['interfaceMode']);

$this->userSettingsService
->method('getCurrentUserSettings')
->willReturn($userSettings);

$service = new XmlEditor([XmlEditorInterface::OPTION_XML_EDITOR_LOCK => $options['configFlag']]);
$service->setServiceLocator($this->serviceLocatorMock);

$this->featureFlagCheckerMock
->method('isEnabled')
->withConsecutive(['FEATURE_FLAG_XML_EDITOR_ENABLED'], ['XML_EDITOR_ENABLED'])
->willReturnOnConsecutiveCalls($newFeatureFlag, $legacyFeatureFlag);
->withConsecutive([FeatureFlagCheckerInterface::FEATURE_FLAG_SOLAR_DESIGN_ENABLED], ['FEATURE_FLAG_XML_EDITOR_ENABLED'], ['XML_EDITOR_ENABLED'])
->willReturnOnConsecutiveCalls($options['solarDesignEnabled'], $options['xmlEditorEnabled'], $options['legacyXmlEditorEnabled']);

$this->assertEquals($expectedLock, $service->isLocked());
$this->assertEquals($options['expectedLock'], $service->isLocked());
}

public function getFeatureIsLockedData(): array
{
return [
'unlocked by config' => [
false,
false,
false,
false
'options' => [
'configFlag' => false,
'xmlEditorEnabled' => false,
'legacyXmlEditorEnabled' => false,
'solarDesignEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
],
'unlocked by new feature flag' => [
true,
true,
false,
false
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => false,
'solarDesignEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
],
'unlocked by legacy feature flag' => [
true,
false,
true,
false
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => false,
'legacyXmlEditorEnabled' => true,
'solarDesignEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
],
'locked' => [
true,
false,
false,
true
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => false,
'legacyXmlEditorEnabled' => false,
'solarDesignEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => true
]
],
'enabled but locked but simple interface' => [
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => true,
'solarDesignEnabled' => true,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_SIMPLE,
'expectedLock' => true
]
],

'enabled with advanced interface mode' => [
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => true,
'solarDesignEnabled' => true,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
],

'unlocked because ignoring simple mode when solar disabled' => [
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => true,
'solarDesignEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_SIMPLE,
'expectedLock' => false
]
]
];
}
}
54 changes: 54 additions & 0 deletions views/js/controller/creator/helpers/featureVisibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ define(['services/features'], function (features) {
if (features.isVisible('taoQtiTest/creator/test/property/timeLimits')) {
model.showTimeLimits = true;
}
if (features.isVisible('taoQtiTest/creator/test/property/identifier')) {
model.showIdentifier = true;
}
if (features.isVisible('taoQtiTest/creator/test/property/lateSubmission')) {
model.lateSubmission = true;
}
if (features.isVisible('taoQtiTest/creator/test/property/outcomeDeclarations')) {
model.showOutcomeDeclarations = true;
}
}

/**
Expand All @@ -39,6 +48,18 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}timeLimits`)) {
model.showTimeLimits = true;
}
if (features.isVisible(`${propertyNamespace}identifier`)) {
model.showIdentifier = true;
}
if (features.isVisible(`${propertyNamespace}lateSubmission`)) {
model.lateSubmission = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl`)) {
model.showItemSessionControl = true;
}
if (features.isVisible(`${propertyNamespace}navigationWarnings`)) {
model.showNavigationWarnings = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/showFeedback`)) {
model.itemSessionShowFeedback = true;
}
Expand All @@ -48,6 +69,12 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}itemSessionControl/allowSkipping`)) {
model.itemSessionAllowSkipping = true;
}
if (features.isVisible(`${propertyNamespace}weights`)) {
model.showWeights = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/validateResponses`)) {
model.showWeights = true;
}
}

/**
Expand All @@ -59,6 +86,21 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}timeLimits`)) {
model.showTimeLimits = true;
}
if (features.isVisible(`${propertyNamespace}identifier`)) {
model.showIdentifier = true;
}
if (features.isVisible(`${propertyNamespace}visible`)) {
model.showVisible = true;
}
if (features.isVisible(`${propertyNamespace}keepTogether`)) {
model.showKeepTogether = true;
}
if (features.isVisible(`${propertyNamespace}property/lateSubmission`)) {
model.lateSubmission = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/validateResponses`)) {
model.validateResponsesVisible = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/showFeedback`)) {
model.itemSessionShowFeedback = true;
}
Expand All @@ -68,6 +110,9 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}itemSessionControl/allowSkipping`)) {
model.itemSessionAllowSkipping = true;
}
if (features.isVisible(`${propertyNamespace}rubricBlocks/class`)) {
model.rubricBlocksClass = true;
}
}

/**
Expand All @@ -79,6 +124,15 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}timeLimits`)) {
model.showTimeLimits = true;
}
if (features.isVisible(`${propertyNamespace}identifier`)) {
model.showIdentifier = true;
}
if (features.isVisible(`${propertyNamespace}reference`)) {
model.showReference = true;
}
if (features.isVisible(`${propertyNamespace}lateSubmission`)) {
model.lateSubmission = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/showFeedback`)) {
model.itemSessionShowFeedback = true;
}
Expand Down
9 changes: 7 additions & 2 deletions views/js/controller/creator/helpers/scoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ define([
'core/format',
'taoQtiTest/controller/creator/helpers/baseType',
'taoQtiTest/controller/creator/helpers/outcome',
'taoQtiTest/controller/creator/helpers/processingRule'
], function (_, __, format, baseTypeHelper, outcomeHelper, processingRuleHelper) {
'taoQtiTest/controller/creator/helpers/processingRule',
'services/features'
], function (_, __, format, baseTypeHelper, outcomeHelper, processingRuleHelper, features) {
'use strict';

/**
Expand Down Expand Up @@ -890,6 +891,10 @@ define([
*/
function detectScoring(modelOverseer) {
var model = modelOverseer.getModel();
let modes = processingModes;
if(!features.isVisible('taoQtiTest/creator/test/property/scoring/custom')) {
delete modes.custom;
}
return {
modes: processingModes,
scoreIdentifier: defaultScoreIdentifier,
Expand Down
Loading