Skip to content

Commit

Permalink
Merge pull request #2482 from oat-sa/integration/RFE-1247-M3/solar-de…
Browse files Browse the repository at this point in the history
…sign-feature-hiding

Integration/rfe 1247 m3/solar design feature hiding
  • Loading branch information
Nevermind23 authored Jun 24, 2024
2 parents 89cf600 + 346bfa2 commit 3b5d5cb
Show file tree
Hide file tree
Showing 16 changed files with 457 additions and 289 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
"oat-sa/lib-test-cat": "2.3.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/generis": ">=15.36.4",
"oat-sa/tao-core": ">=54.14.7",
"oat-sa/extension-tao-item" : ">=12.1.0",
"oat-sa/extension-tao-itemqti" : ">=30.10.0",
"oat-sa/extension-tao-itemqti" : ">=30.12.0",
"oat-sa/extension-tao-test" : ">=16.0.0",
"oat-sa/extension-tao-delivery" : ">=15.0.0",
"oat-sa/extension-tao-outcome" : ">=13.0.0",
Expand Down
24 changes: 22 additions & 2 deletions models/classes/xmlEditor/XmlEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
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 oat\tao\model\user\UserSettingsServiceInterface;
use qtism\data\storage\xml\XmlDocument;
use taoQtiTest_models_classes_QtiTestService;

Expand Down Expand Up @@ -59,6 +64,16 @@ public function saveStringTest(core_kernel_classes_Resource $test, string $testS
*/
public function isLocked(): bool
{
$userSettings = $this->getUserSettingsService()->getCurrentUserSettings();

if (
$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 @@ -71,11 +86,16 @@ public function isLocked(): bool

private function getTestService(): taoQtiTest_models_classes_QtiTestService
{
return $this->getServiceLocator()->get(taoQtiTest_models_classes_QtiTestService::class);
return $this->getServiceManager()->getContainer()->get(taoQtiTest_models_classes_QtiTestService::class);
}

private function getFeatureFlagChecker(): FeatureFlagChecker
private function getFeatureFlagChecker(): FeatureFlagCheckerInterface
{
return $this->getServiceManager()->getContainer()->get(FeatureFlagChecker::class);
}

public function getUserSettingsService(): UserSettingsServiceInterface
{
return $this->getServiceManager()->getContainer()->get(UserSettingsService::class);
}
}
90 changes: 70 additions & 20 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,85 @@ public function testSaveStringTest()
/**
* @dataProvider getFeatureIsLockedData
*/
public function testIsLocked($configFlag, $newFeatureFlag, $legacyFeatureFlag, $expectedLock)
public function testIsLocked(array $options): void
{
$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);
->willReturnOnConsecutiveCalls($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,
'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,
'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,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
],
'locked' => [
true,
false,
false,
true
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => false,
'legacyXmlEditorEnabled' => false,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => true
]
],
'enabled but locked but simple interface' => [
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => true,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_SIMPLE,
'expectedLock' => true
]
],
'enabled with advanced interface mode' => [
'options' => [
'configFlag' => true,
'xmlEditorEnabled' => true,
'legacyXmlEditorEnabled' => true,
'interfaceMode' => GenerisRdf::PROPERTY_USER_INTERFACE_MODE_ADVANCED,
'expectedLock' => false
]
]
];
}
}
60 changes: 59 additions & 1 deletion views/js/controller/creator/helpers/featureVisibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ define(['services/features'], function (features) {
* @param {Object} model
*/
function addTestVisibilityProps(model) {
if (features.isVisible('taoQtiTest/creator/test/property/timeLimits')) {
const propertyNamespace = 'taoQtiTest/creator/test/property/';
if (features.isVisible(`${propertyNamespace}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 +49,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}submissionMode`)) {
model.submissionModeVisible = 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 @@ -59,6 +84,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}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 +108,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 +122,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 All @@ -88,6 +140,12 @@ define(['services/features'], function (features) {
if (features.isVisible(`${propertyNamespace}itemSessionControl/allowSkipping`)) {
model.itemSessionAllowSkipping = true;
}
if (features.isVisible(`${propertyNamespace}itemSessionControl/validateResponses`)) {
model.validateResponsesVisible = true;
}
if (features.isVisible(`${propertyNamespace}weights`)) {
model.weightsVisible = 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

0 comments on commit 3b5d5cb

Please sign in to comment.