SEBSERV-487 defined some features

This commit is contained in:
anhefti 2023-11-15 10:43:00 +01:00
parent a08a72a2a6
commit 7079a4f112
6 changed files with 30 additions and 14 deletions

View file

@ -14,6 +14,12 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
public interface FeatureService { public interface FeatureService {
String SCREEN_PROCTORING_FEATURE_NAME = "seb.screenProctoring";
String INSTITUTION_FEATURE_NAME = "admin.institution";
String REMOTE_PROCTORING_FEATURE_NAME = "seb.remoteProctoring";
String TEST_LMS_FEATURE_NAME = "lms.testLMS";
String EXAM_NO_LMS_FEATURE_NAME = "exam.noLMS";
String FEATURE_SETTINGS_PREFIX = "sebserver.feature."; String FEATURE_SETTINGS_PREFIX = "sebserver.feature.";
boolean isEnabled(LmsType LmsType); boolean isEnabled(LmsType LmsType);
@ -22,6 +28,6 @@ public interface FeatureService {
boolean isEnabled(CollectingStrategy collectingRoomStrategy); boolean isEnabled(CollectingStrategy collectingRoomStrategy);
boolean isScreenProcteringEnabled(); boolean isEnabled(String featureSuffix);
} }

View file

@ -55,16 +55,16 @@ public class FeatureServiceImpl implements FeatureService {
Boolean.TRUE); Boolean.TRUE);
} }
private String toConfigName(final String key) {
return key.replaceAll("_", "-");
}
@Override @Override
public boolean isScreenProcteringEnabled() { public boolean isEnabled(final String featureSuffix) {
return this.environment.getProperty(toConfigName( return this.environment.getProperty(toConfigName(
FEATURE_SETTINGS_PREFIX + "seb.screenProctoring"), FEATURE_SETTINGS_PREFIX + featureSuffix + ".enabled"),
Boolean.class, Boolean.class,
Boolean.FALSE); Boolean.FALSE);
} }
private String toConfigName(final String key) {
return key.replaceAll("_", "-");
}
} }

View file

@ -412,14 +412,15 @@ public class ExamForm implements TemplateComposer {
this.processTemplateSelection(formHandle.getForm(), formContext); this.processTemplateSelection(formHandle.getForm(), formContext);
} }
final boolean proctoringEnabled = importFromQuizData ? false : this.restService final boolean proctoringEnabled = !importFromQuizData && this.restService
.getBuilder(GetExamProctoringSettings.class) .getBuilder(GetExamProctoringSettings.class)
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.call() .call()
.map(ProctoringServiceSettings::getEnableProctoring) .map(ProctoringServiceSettings::getEnableProctoring)
.getOr(false); .getOr(false);
final boolean screenProctoringEnabled = importFromQuizData ? false : this.restService final boolean spsFeatureEnabled = this.featureService.isEnabled(FeatureService.SCREEN_PROCTORING_FEATURE_NAME);
final boolean screenProctoringEnabled = spsFeatureEnabled && !importFromQuizData && this.restService
.getBuilder(GetScreenProctoringSettings.class) .getBuilder(GetScreenProctoringSettings.class)
.withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId)
.call() .call()
@ -430,6 +431,7 @@ public class ExamForm implements TemplateComposer {
.clearEntityKeys() .clearEntityKeys()
.removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA)); .removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA));
// propagate content actions to action-pane // propagate content actions to action-pane
actionBuilder actionBuilder
@ -514,7 +516,7 @@ public class ExamForm implements TemplateComposer {
.withExec( .withExec(
this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable)) this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable))
.noEventPropagation() .noEventPropagation()
.publishIf(() -> this.featureService.isScreenProcteringEnabled() && screenProctoringEnabled && readonly) .publishIf(() -> spsFeatureEnabled && screenProctoringEnabled && readonly)
.newAction(ActionDefinition.SCREEN_PROCTORING_OFF) .newAction(ActionDefinition.SCREEN_PROCTORING_OFF)
.withEntityKey(entityKey) .withEntityKey(entityKey)
@ -522,7 +524,7 @@ public class ExamForm implements TemplateComposer {
this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable)) this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable))
.noEventPropagation() .noEventPropagation()
.publishIf( .publishIf(
() -> this.featureService.isScreenProcteringEnabled() && !screenProctoringEnabled && readonly) () -> spsFeatureEnabled && !screenProctoringEnabled && readonly)
; ;

View file

@ -150,10 +150,13 @@ public class WebserviceInfo {
this.lmsExternalAddressAlias = Collections.emptyMap(); this.lmsExternalAddressAlias = Collections.emptyMap();
} }
final boolean spsEnabled = BooleanUtils.toBoolean(environment.getProperty(
"sebserver.feature.seb.screenProctoring.enabled",
Constants.FALSE_STRING));
final boolean spsBundled = BooleanUtils.toBoolean(environment.getProperty( final boolean spsBundled = BooleanUtils.toBoolean(environment.getProperty(
"sebserver.feature.seb.screenProctoring.bundled", "sebserver.feature.seb.screenProctoring.bundled",
Constants.FALSE_STRING)); Constants.FALSE_STRING));
if (spsBundled) { if (spsEnabled && spsBundled) {
this.screenProctoringServiceBundle = new ScreenProctoringServiceBundle( this.screenProctoringServiceBundle = new ScreenProctoringServiceBundle(
environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.url"), environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.url"),
environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.clientId"), environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.clientId"),

View file

@ -30,4 +30,4 @@ sebserver.http.client.connection-request-timeout=10000
sebserver.http.client.read-timeout=60000 sebserver.http.client.read-timeout=60000
# features # features
sebserver.feature.seb.screenProctoring=true sebserver.feature.seb.screenProctoring.enabled=true

View file

@ -64,7 +64,12 @@ sebserver.ssl.redirect.enabled=false
sebserver.ssl.redirect.html.port=8080 sebserver.ssl.redirect.html.port=8080
# features # features
sebserver.feature.seb.screenProctoring=false sebserver.feature.admin.institution.enabled=true
sebserver.feature.seb.remoteProctoring.enabled=true
sebserver.feature.lms.testLMS.enabled=true
sebserver.feature.exam.noLMS.enabled=true
sebserver.feature.seb.screenProctoring.enabled=false
sebserver.feature.seb.screenProctoring.bundled=true sebserver.feature.seb.screenProctoring.bundled=true
sebserver.feature.seb.screenProctoring.bundled.url=sps-service:8090 sebserver.feature.seb.screenProctoring.bundled.url=sps-service:8090
sebserver.feature.seb.screenProctoring.bundled.clientId=sebserverClient sebserver.feature.seb.screenProctoring.bundled.clientId=sebserverClient