diff --git a/src/main/java/org/olat/course/_spring/courseContext.xml b/src/main/java/org/olat/course/_spring/courseContext.xml index f5788faac81d2c36fa21e28efcaeaf7ff7b393c3..dbfa5f111c4d70e34157d9ef63ccc29454773651 100644 --- a/src/main/java/org/olat/course/_spring/courseContext.xml +++ b/src/main/java/org/olat/course/_spring/courseContext.xml @@ -76,7 +76,8 @@ </list> </property> </bean> - <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> + + <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> <property name="order" value="8210" /> <property name="actionController"> <bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype"> @@ -94,5 +95,24 @@ </list> </property> </bean> + + <bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints"> + <property name="order" value="7210" /> + <property name="actionController"> + <bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype"> + <property name="className" value="org.olat.course.nodes.livestream.ui.LiveStreamAdminController"/> + </bean> + </property> + <property name="navigationKey" value="livestream" /> + <property name="parentTreeNodeIdentifier" value="modulesParent" /> + <property name="i18nActionKey" value="admin.menu.title"/> + <property name="i18nDescriptionKey" value="admin.menu.title.alt"/> + <property name="translationPackage" value="org.olat.course.nodes.livestream.ui"/> + <property name="extensionPoints"> + <list> + <value>org.olat.admin.SystemAdminMainController</value> + </list> + </property> + </bean> </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/course/nodes/LiveStreamCourseNode.java b/src/main/java/org/olat/course/nodes/LiveStreamCourseNode.java index bb478e1d798abd9fa0425d6213f7fcab16e0bcb9..9c8f3f4295bd29ce8d08a1e0afcba84f74459c8d 100644 --- a/src/main/java/org/olat/course/nodes/LiveStreamCourseNode.java +++ b/src/main/java/org/olat/course/nodes/LiveStreamCourseNode.java @@ -129,7 +129,7 @@ public class LiveStreamCourseNode extends AbstractAccessableCourseNode { LiveStreamModule liveStreamModule = CoreSpringFactory.getImpl(LiveStreamModule.class); config.setIntValue(CONFIG_BUFFER_BEFORE_MIN, liveStreamModule.getBufferBeforeMin()); config.setIntValue(CONFIG_BUFFER_AFTER_MIN, liveStreamModule.getBufferAfterMin()); - config.setBooleanEntry(CONFIG_COACH_CAN_EDIT, false); + config.setBooleanEntry(CONFIG_COACH_CAN_EDIT, liveStreamModule.isEditCoach()); } config.setConfigurationVersion(CURRENT_VERSION); } diff --git a/src/main/java/org/olat/course/nodes/livestream/LiveStreamModule.java b/src/main/java/org/olat/course/nodes/livestream/LiveStreamModule.java index ef497400a582365c0a79228a69b2f562e1786996..7dd830efb80b4447a6b4e604173338a93c5af1ca 100644 --- a/src/main/java/org/olat/course/nodes/livestream/LiveStreamModule.java +++ b/src/main/java/org/olat/course/nodes/livestream/LiveStreamModule.java @@ -39,6 +39,7 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf public static final String LIVE_STREAM_ENABLED = "live.stream.enabled"; public static final String LIVE_STREAM_BUFFER_BEFORE_MIN = "live.stream.buffer.before.min"; public static final String LIVE_STREAM_BUFFER_AFTER_MIN = "live.stream.buffer.after.min"; + public static final String LIVE_STREAM_EDIT_COACH = "live.stream.edit.coach"; @Value("${live.stream.enabled:false}") private boolean enabled; @@ -46,7 +47,9 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf private int bufferBeforeMin; @Value("${live.stream.buffer.after.min:5}") private int bufferAfterMin; - + @Value("${live.stream.edit.coach:false}") + private boolean editCoach; + @Autowired public LiveStreamModule(CoordinatorManager coordinatorManager) { super(coordinatorManager); @@ -68,6 +71,11 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf if(StringHelper.containsNonWhitespace(bufferAfterMinObj)) { bufferAfterMin = Integer.parseInt(bufferAfterMinObj); } + + String editCoachObj = getStringPropertyValue(LIVE_STREAM_EDIT_COACH, true); + if(StringHelper.containsNonWhitespace(editCoachObj)) { + editCoach = "true".equals(editCoachObj); + } } @Override @@ -103,4 +111,13 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf setStringProperty(LIVE_STREAM_BUFFER_BEFORE_MIN, Integer.toString(bufferAfterMin), true); } + public boolean isEditCoach() { + return editCoach; + } + + public void setEditCoach(boolean editCoach) { + this.editCoach = editCoach; + setStringProperty(LIVE_STREAM_EDIT_COACH, Boolean.toString(editCoach), true); + } + } diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamAdminController.java b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamAdminController.java new file mode 100644 index 0000000000000000000000000000000000000000..3acd268aa8b6be8fbb4c9c64e9cbd6fef800956f --- /dev/null +++ b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamAdminController.java @@ -0,0 +1,128 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.course.nodes.livestream.ui; + +import static org.olat.core.gui.translator.TranslatorHelper.translateAll; +import static org.olat.course.nodes.livestream.ui.LiveStreamUIFactory.validateInteger; + +import org.olat.core.gui.UserRequest; +import org.olat.core.gui.components.form.flexible.FormItemContainer; +import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement; +import org.olat.core.gui.components.form.flexible.elements.TextElement; +import org.olat.core.gui.components.form.flexible.impl.FormBasicController; +import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer; +import org.olat.core.gui.control.Controller; +import org.olat.core.gui.control.WindowControl; +import org.olat.course.nodes.livestream.LiveStreamModule; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * + * Initial date: 5 Jun 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +public class LiveStreamAdminController extends FormBasicController { + + private static final String[] ENABLED_KEYS = new String[]{"on"}; + + private MultipleSelectionElement enabledEl; + private TextElement bufferBeforeMinEl; + private TextElement bufferAfterMinEl; + private MultipleSelectionElement coachCanEditEl; + + @Autowired + private LiveStreamModule liveStreamModule; + + public LiveStreamAdminController(UserRequest ureq, WindowControl wControl) { + super(ureq, wControl, LAYOUT_BAREBONE); + + initForm(ureq); + } + + @Override + protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { + FormLayoutContainer generalCont = FormLayoutContainer.createDefaultFormLayout("general", getTranslator()); + generalCont.setFormTitle(translate("admin.general.title")); + generalCont.setRootForm(mainForm); + formLayout.add("genearl", generalCont); + + enabledEl = uifactory.addCheckboxesHorizontal("admin.module.enabled", generalCont, ENABLED_KEYS, + translateAll(getTranslator(), ENABLED_KEYS)); + enabledEl.select(ENABLED_KEYS[0], liveStreamModule.isEnabled()); + + FormLayoutContainer defaultValuesCont = FormLayoutContainer.createDefaultFormLayout("default_values", getTranslator()); + defaultValuesCont.setFormTitle(translate("admin.default.values.title")); + defaultValuesCont.setFormDescription(translate("admin.default.values.desc")); + defaultValuesCont.setRootForm(mainForm); + formLayout.add("defaultValues", defaultValuesCont); + + int bufferBeforeMin = liveStreamModule.getBufferBeforeMin(); + bufferBeforeMinEl = uifactory.addTextElement("admin.buffer.before.min", 4, String.valueOf(bufferBeforeMin), + defaultValuesCont); + bufferBeforeMinEl.setMandatory(true); + + int bufferAfterMin = liveStreamModule.getBufferAfterMin(); + bufferAfterMinEl = uifactory.addTextElement("admin.buffer.after.min", 4, String.valueOf(bufferAfterMin), + defaultValuesCont); + bufferAfterMinEl.setMandatory(true); + + coachCanEditEl = uifactory.addCheckboxesHorizontal("admin.coach.edit", defaultValuesCont, ENABLED_KEYS, + translateAll(getTranslator(), ENABLED_KEYS)); + boolean coachCanEdit = liveStreamModule.isEditCoach(); + coachCanEditEl.select(ENABLED_KEYS[0], coachCanEdit); + + FormLayoutContainer buttonsCont = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator()); + buttonsCont.setRootForm(mainForm); + formLayout.add("buttons", buttonsCont); + uifactory.addFormSubmitButton("save", buttonsCont); + } + + @Override + protected boolean validateFormLogic(UserRequest ureq) { + boolean allOk = super.validateFormLogic(ureq); + + allOk &= validateInteger(bufferBeforeMinEl, true); + allOk &= validateInteger(bufferAfterMinEl, true); + + return allOk; + } + + @Override + protected void formOK(UserRequest ureq) { + boolean enabled = enabledEl.isAtLeastSelected(1); + liveStreamModule.setEnabled(enabled); + + int bufferBeforeMin = Integer.parseInt(bufferBeforeMinEl.getValue()); + liveStreamModule.setBufferBeforeMin(bufferBeforeMin); + + int bufferAfterMin = Integer.parseInt(bufferAfterMinEl.getValue()); + liveStreamModule.setBufferAfterMin(bufferAfterMin); + + boolean coachCanEdit = coachCanEditEl.isAtLeastSelected(1); + liveStreamModule.setEditCoach(coachCanEdit); + } + + @Override + protected void doDispose() { + // + } + +} diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamConfigController.java b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamConfigController.java index 6c4206b960cdb0d46aaf792871bf5ee5e20405f7..0c417d030d96809987b9a8ef8d2d0e758cc69015 100644 --- a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamConfigController.java +++ b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamConfigController.java @@ -20,6 +20,7 @@ package org.olat.course.nodes.livestream.ui; import static org.olat.core.gui.translator.TranslatorHelper.translateAll; +import static org.olat.course.nodes.livestream.ui.LiveStreamUIFactory.validateInteger; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItemContainer; @@ -29,7 +30,6 @@ import org.olat.core.gui.components.form.flexible.impl.FormBasicController; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; -import org.olat.core.util.StringHelper; import org.olat.course.nodes.LiveStreamCourseNode; import org.olat.modules.ModuleConfiguration; @@ -85,26 +85,6 @@ public class LiveStreamConfigController extends FormBasicController { return allOk; } - - private boolean validateInteger(TextElement el, boolean mandatory) { - boolean allOk = true; - el.clearError(); - if(el.isEnabled() && el.isVisible()) { - String val = el.getValue(); - if (StringHelper.containsNonWhitespace(val)) { - try { - Integer.parseInt(val); - } catch (NumberFormatException e) { - el.setErrorKey("form.error.wrong.int", null); - allOk = false; - } - } else if (mandatory) { - el.setErrorKey("form.mandatory.hover", null); - allOk = false; - } - } - return allOk; - } @Override protected void formOK(UserRequest ureq) { diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamUIFactory.java b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamUIFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..6dbf4e41848307ed86b4730ff6b3813f5faab341 --- /dev/null +++ b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamUIFactory.java @@ -0,0 +1,53 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.course.nodes.livestream.ui; + +import org.olat.core.gui.components.form.flexible.elements.TextElement; +import org.olat.core.util.StringHelper; + +/** + * + * Initial date: 5 Jun 2019<br> + * @author uhensler, urs.hensler@frentix.com, http://www.frentix.com + * + */ +class LiveStreamUIFactory { + + static boolean validateInteger(TextElement el, boolean mandatory) { + boolean allOk = true; + el.clearError(); + if(el.isEnabled() && el.isVisible()) { + String val = el.getValue(); + if (StringHelper.containsNonWhitespace(val)) { + try { + Integer.parseInt(val); + } catch (NumberFormatException e) { + el.setErrorKey("form.error.wrong.int", null); + allOk = false; + } + } else if (mandatory) { + el.setErrorKey("form.mandatory.hover", null); + allOk = false; + } + } + return allOk; + } + +} diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties index 412ca080337bc985b678252e05daae695e3b3619..64015ecc6c6fa0ddf043d016ef01677bc0196f69 100644 --- a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties @@ -1,3 +1,12 @@ +admin.buffer.before.min=$:\config.buffer.before.min +admin.buffer.after.min=$:\config.buffer.after.min +admin.default.values.title=Initialwerte +admin.default.values.desc=Hier k\u00F6nnen Sie die Initialwerte eines neuen Kursbausteines konfigurieren. +admin.coach.edit=$:\config.coach.edit +admin.general.title=$:\admin.menu.title +admin.menu.title=Livestream +admin.menu.title.alt=$:\admin.menu.title +admin.module.enabled=Kursbaustein condition.accessibility.title=Zugang config.buffer.before.min=Vorlaufzeit (in Minuten) config.buffer.after.min=Nachlaufzeit (in Minuten) diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties index c40834169c0887bfaba82655912b1f2f9a1c8591..75ab5aa3dcb00c125743427edafbc20d8ad27e60 100644 --- a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties @@ -1,3 +1,12 @@ +admin.buffer.before.min=$:\config.buffer.before.min +admin.buffer.after.min=$:\config.buffer.after.min +admin.coach.edit=$:\config.coach.edit +admin.default.values.title=Default values +admin.default.values.desc=Modify the default values of a new course node. +admin.general.title=$:\admin.menu.title +admin.menu.title=Live stream +admin.menu.title.alt=$:\admin.menu.title +admin.module.enabled=Course element condition.accessibility.title=Access config.buffer.before.min=Buffer time before start (in minutes) config.buffer.after.min=Buffer time after end (in minutes) diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index 64d39e3f0f4f6715080b1b20ee4a37f9c1903862..149a54fd940d09d5eed338c4a064b277a56c59d4 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -1596,3 +1596,5 @@ live.stream.enabled=false # and vice versa. live.stream.buffer.before.min=5 live.stream.buffer.after.min=5 +live.stream.edit.coach=false +