diff --git a/composer.json b/composer.json index 13861cb12..0f21b8359 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/models/classes/xmlEditor/XmlEditor.php b/models/classes/xmlEditor/XmlEditor.php index 69862ecce..9a4009a7b 100644 --- a/models/classes/xmlEditor/XmlEditor.php +++ b/models/classes/xmlEditor/XmlEditor.php @@ -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; @@ -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) @@ -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); + } } diff --git a/test/unit/models/classes/xml/XmlEditorTest.php b/test/unit/models/classes/xml/XmlEditorTest.php index e50757395..f9c634c4f 100644 --- a/test/unit/models/classes/xml/XmlEditorTest.php +++ b/test/unit/models/classes/xml/XmlEditorTest.php @@ -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; @@ -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(); @@ -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 ]); } @@ -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 + ] + ] ]; } } diff --git a/views/js/controller/creator/helpers/featureVisibility.js b/views/js/controller/creator/helpers/featureVisibility.js index e660a7a5c..b645684b2 100644 --- a/views/js/controller/creator/helpers/featureVisibility.js +++ b/views/js/controller/creator/helpers/featureVisibility.js @@ -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; + } } /** @@ -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; } @@ -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; + } } /** @@ -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; } @@ -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; + } } /** @@ -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; } diff --git a/views/js/controller/creator/helpers/scoring.js b/views/js/controller/creator/helpers/scoring.js index cb43e709d..42fd5ad45 100644 --- a/views/js/controller/creator/helpers/scoring.js +++ b/views/js/controller/creator/helpers/scoring.js @@ -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'; /** @@ -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, diff --git a/views/js/controller/creator/templates/itemref-props.tpl b/views/js/controller/creator/templates/itemref-props.tpl index add1fec42..14cd15517 100644 --- a/views/js/controller/creator/templates/itemref-props.tpl +++ b/views/js/controller/creator/templates/itemref-props.tpl @@ -2,38 +2,42 @@