From 7079a4f112f25180e95d62013675651829bd8f8c Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 15 Nov 2023 10:43:00 +0100 Subject: [PATCH] SEBSERV-487 defined some features --- .../ch/ethz/seb/sebserver/gbl/FeatureService.java | 8 +++++++- .../ethz/seb/sebserver/gbl/FeatureServiceImpl.java | 12 ++++++------ .../seb/sebserver/gui/content/exam/ExamForm.java | 10 ++++++---- .../seb/sebserver/webservice/WebserviceInfo.java | 5 ++++- src/main/resources/config/application-dev.properties | 2 +- src/main/resources/config/application.properties | 7 ++++++- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java index 0152e9ef..1f804c51 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureService.java @@ -14,6 +14,12 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType; 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."; boolean isEnabled(LmsType LmsType); @@ -22,6 +28,6 @@ public interface FeatureService { boolean isEnabled(CollectingStrategy collectingRoomStrategy); - boolean isScreenProcteringEnabled(); + boolean isEnabled(String featureSuffix); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java index 15e46045..96f41e9d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/FeatureServiceImpl.java @@ -55,16 +55,16 @@ public class FeatureServiceImpl implements FeatureService { Boolean.TRUE); } - private String toConfigName(final String key) { - return key.replaceAll("_", "-"); - } - @Override - public boolean isScreenProcteringEnabled() { + public boolean isEnabled(final String featureSuffix) { return this.environment.getProperty(toConfigName( - FEATURE_SETTINGS_PREFIX + "seb.screenProctoring"), + FEATURE_SETTINGS_PREFIX + featureSuffix + ".enabled"), Boolean.class, Boolean.FALSE); } + private String toConfigName(final String key) { + return key.replaceAll("_", "-"); + } + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java index fb1c8cb8..178c08b4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/exam/ExamForm.java @@ -412,14 +412,15 @@ public class ExamForm implements TemplateComposer { this.processTemplateSelection(formHandle.getForm(), formContext); } - final boolean proctoringEnabled = importFromQuizData ? false : this.restService + final boolean proctoringEnabled = !importFromQuizData && this.restService .getBuilder(GetExamProctoringSettings.class) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .call() .map(ProctoringServiceSettings::getEnableProctoring) .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) .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .call() @@ -430,6 +431,7 @@ public class ExamForm implements TemplateComposer { .clearEntityKeys() .removeAttribute(AttributeKeys.IMPORT_FROM_QUIZ_DATA)); + // propagate content actions to action-pane actionBuilder @@ -514,7 +516,7 @@ public class ExamForm implements TemplateComposer { .withExec( this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable)) .noEventPropagation() - .publishIf(() -> this.featureService.isScreenProcteringEnabled() && screenProctoringEnabled && readonly) + .publishIf(() -> spsFeatureEnabled && screenProctoringEnabled && readonly) .newAction(ActionDefinition.SCREEN_PROCTORING_OFF) .withEntityKey(entityKey) @@ -522,7 +524,7 @@ public class ExamForm implements TemplateComposer { this.screenProctoringSettingsPopup.settingsFunction(this.pageService, modifyGrant && editable)) .noEventPropagation() .publishIf( - () -> this.featureService.isScreenProcteringEnabled() && !screenProctoringEnabled && readonly) + () -> spsFeatureEnabled && !screenProctoringEnabled && readonly) ; diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java index 26976b85..65cdc4e2 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/WebserviceInfo.java @@ -150,10 +150,13 @@ public class WebserviceInfo { 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( "sebserver.feature.seb.screenProctoring.bundled", Constants.FALSE_STRING)); - if (spsBundled) { + if (spsEnabled && spsBundled) { this.screenProctoringServiceBundle = new ScreenProctoringServiceBundle( environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.url"), environment.getProperty("sebserver.feature.seb.screenProctoring.bundled.clientId"), diff --git a/src/main/resources/config/application-dev.properties b/src/main/resources/config/application-dev.properties index f2c01c1d..3862d91e 100644 --- a/src/main/resources/config/application-dev.properties +++ b/src/main/resources/config/application-dev.properties @@ -30,4 +30,4 @@ sebserver.http.client.connection-request-timeout=10000 sebserver.http.client.read-timeout=60000 # features -sebserver.feature.seb.screenProctoring=true \ No newline at end of file +sebserver.feature.seb.screenProctoring.enabled=true \ No newline at end of file diff --git a/src/main/resources/config/application.properties b/src/main/resources/config/application.properties index dcd3c8ea..8dff4181 100644 --- a/src/main/resources/config/application.properties +++ b/src/main/resources/config/application.properties @@ -64,7 +64,12 @@ sebserver.ssl.redirect.enabled=false sebserver.ssl.redirect.html.port=8080 # 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.url=sps-service:8090 sebserver.feature.seb.screenProctoring.bundled.clientId=sebserverClient