From 9b8840c779bfcb7e5c7036d80abd9ae7b674a213 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 3 Dec 2020 10:38:02 +0100 Subject: [PATCH 1/2] added LmsType enabling --- .../sebserver/gui/content/LmsSetupForm.java | 14 ++++++++++++- .../gui/service/ResourceService.java | 20 +++++++++++++++---- .../config/application-dev-gui.properties | 5 ++++- .../config/application-gui.properties | 2 ++ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java index c22a3604..153d167b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/LmsSetupForm.java @@ -198,7 +198,7 @@ public class LmsSetupForm implements TemplateComposer { .addField(FormBuilder.singleSelection( Domain.LMS_SETUP.ATTR_LMS_TYPE, FORM_TYPE_TEXT_KEY, - (lmsType != null) ? lmsType.name() : LmsType.MOCKUP.name(), + getLmsTypeDefaultSelection(lmsType), this.resourceService::lmsTypeResources) .readonlyIf(isNotNew) .mandatory(!readonly)) @@ -350,6 +350,18 @@ public class LmsSetupForm implements TemplateComposer { .publishIf(() -> !readonly); } + private String getLmsTypeDefaultSelection(final LmsType lmsType) { + if (lmsType != null) { + return lmsType.name(); + } + + try { + return this.resourceService.lmsTypeResources().get(0)._1; + } catch (final Exception e) { + return null; + } + } + /** Save and test connection before activation */ public static PageAction activate( final PageAction action, diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java index c68b38b7..4e5d5882 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java @@ -125,18 +125,30 @@ public class ResourceService { private final I18nSupport i18nSupport; private final RestService restService; private final CurrentUser currentUser; - private final boolean mock_lms_enabled; + private final EnumSet enabledLmsTypes; protected ResourceService( final I18nSupport i18nSupport, final RestService restService, final CurrentUser currentUser, - @Value("${sebserver.gui.webservice.mock-lms-enabled:true}") final boolean mock_lms_enabled) { + @Value("${sebserver.gui.webservice.mock-lms-enabled:true}") final boolean mock_lms_enabled, + @Value("${sebserver.gui.webservice.edx-lms-enabled:true}") final boolean edx_lms_enabled, + @Value("${sebserver.gui.webservice.moodle-lms-enabled:true}") final boolean moodle_lms_enabled) { this.i18nSupport = i18nSupport; this.restService = restService; this.currentUser = currentUser; - this.mock_lms_enabled = mock_lms_enabled; + + this.enabledLmsTypes = EnumSet.noneOf(LmsType.class); + if (mock_lms_enabled) { + this.enabledLmsTypes.add(LmsType.MOCKUP); + } + if (edx_lms_enabled) { + this.enabledLmsTypes.add(LmsType.OPEN_EDX); + } + if (moodle_lms_enabled) { + this.enabledLmsTypes.add(LmsType.MOODLE); + } } public I18nSupport getI18nSupport() { @@ -166,7 +178,7 @@ public class ResourceService { public List> lmsTypeResources() { return Arrays.stream(LmsType.values()) - .filter(lmsType -> lmsType != LmsType.MOCKUP || this.mock_lms_enabled) + .filter(this.enabledLmsTypes::contains) .map(lmsType -> new Tuple<>( lmsType.name(), this.i18nSupport.getText(LMSSETUP_TYPE_PREFIX + lmsType.name(), lmsType.name()))) diff --git a/src/main/resources/config/application-dev-gui.properties b/src/main/resources/config/application-dev-gui.properties index 5a44192a..d62aead1 100644 --- a/src/main/resources/config/application-dev-gui.properties +++ b/src/main/resources/config/application-dev-gui.properties @@ -8,7 +8,10 @@ sebserver.gui.webservice.port=8080 sebserver.gui.webservice.apipath=/admin-api/v1 # defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page sebserver.gui.webservice.poll-interval=1000 -sebserver.gui.webservice.mock-lms-enabled=true + +sebserver.gui.webservice.mock-lms-enabled=false +sebserver.gui.webservice.edx-lms-enabled=true +sebserver.gui.webservice.moodle-lms-enabled=false sebserver.gui.theme=css/sebserver.css diff --git a/src/main/resources/config/application-gui.properties b/src/main/resources/config/application-gui.properties index aca55cea..7a268dae 100644 --- a/src/main/resources/config/application-gui.properties +++ b/src/main/resources/config/application-gui.properties @@ -21,6 +21,8 @@ sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint} # defines the polling interval that is used to poll the webservice for client connection data on a monitored exam page sebserver.gui.webservice.poll-interval=1000 sebserver.gui.webservice.mock-lms-enabled=true +sebserver.gui.webservice.edx-lms-enabled=true +sebserver.gui.webservice.moodle-lms-enabled=true sebserver.gui.seb.client.config.download.filename=SEBServerSettings.seb sebserver.gui.seb.exam.config.download.filename=SEBExamSettings.seb From 4ac8f15dcaecf4a0ba50bef473f1041a9e03f264 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 7 Dec 2020 09:19:47 +0100 Subject: [PATCH 2/2] prepare for version 1.0.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4c45f724..4b04d424 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,7 @@ jar - 1.0.2-SNAPSHOT + 1.0.2 ${sebserver-version} UTF-8 UTF-8