diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/RaiseHandRule.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/RaiseHandRule.java new file mode 100644 index 00000000..7a1b19b9 --- /dev/null +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/rules/RaiseHandRule.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2021 ETH Zürich, Educational Development and Technology (LET) + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +package ch.ethz.seb.sebserver.gui.service.examconfig.impl.rules; + +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; + +import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; +import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationValue; +import ch.ethz.seb.sebserver.gbl.profile.GuiProfile; +import ch.ethz.seb.sebserver.gui.service.examconfig.ValueChangeRule; +import ch.ethz.seb.sebserver.gui.service.examconfig.impl.ViewContext; + +@Lazy +@Service +@GuiProfile +public class RaiseHandRule implements ValueChangeRule { + + public static final String KEY_RAISE_HAND = "raiseHandButtonShow"; + public static final String KEY_PROMPT_MESSAGE = "raiseHandButtonAlwaysPromptMessage"; + + @Override + public boolean observesAttribute(final ConfigurationAttribute attribute) { + return KEY_RAISE_HAND.equals(attribute.name); + } + + @Override + public void applyRule(final ViewContext context, final ConfigurationAttribute attribute, + final ConfigurationValue value) { + + if (context.isReadonly()) { + return; + } + + if (BooleanUtils.toBoolean(value.value)) { + context.enable(KEY_PROMPT_MESSAGE); + } else { + context.disable(KEY_PROMPT_MESSAGE); + context.setValue( + KEY_PROMPT_MESSAGE, + context.getAttributeByName(KEY_PROMPT_MESSAGE).defaultValue); + } + } + +} diff --git a/src/main/resources/config/sql/base/V11__sebSettings_v1_3.sql b/src/main/resources/config/sql/base/V11__sebSettings_v1_3.sql index 13bad1f7..2045d341 100644 --- a/src/main/resources/config/sql/base/V11__sebSettings_v1_3.sql +++ b/src/main/resources/config/sql/base/V11__sebSettings_v1_3.sql @@ -35,4 +35,16 @@ INSERT IGNORE INTO orientation (config_attribute_id, template_id, view_id, group UPDATE orientation SET width=2 WHERE config_attribute_id=53; INSERT IGNORE INTO orientation (config_attribute_id, template_id, view_id, group_id, x_position, y_position, width, height, title) VALUES - (904, 0, 3, 'userAgentTouch', 9, 5, 3, 1, 'NONE'); \ No newline at end of file + (904, 0, 3, 'userAgentTouch', 9, 5, 3, 1, 'NONE'); + +-- ----------------------------------------------------------------- +-- SEBSERV-201 Number 5 (raise hand) +-- ----------------------------------------------------------------- + +INSERT IGNORE INTO configuration_attribute VALUES + (974, 'raiseHandButtonShow', 'CHECKBOX', null, null, null, null, 'false'), + (975, 'raiseHandButtonAlwaysPromptMessage', 'CHECKBOX', null, null, null, null, 'false'); + +INSERT IGNORE INTO orientation (config_attribute_id, template_id, view_id, group_id, x_position, y_position, width, height, title) VALUES + (974, 0, 2, 'taskbar', 0, 11, 3, 1, 'NONE'), + (975, 0, 2, 'taskbar', 0, 12, 3, 1, 'NONE'); \ No newline at end of file diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index 23b8a2a3..befbf7d7 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -943,6 +943,12 @@ sebserver.examconfig.props.label.showTime=Show time sebserver.examconfig.props.label.showTime.tooltip=Show current time sebserver.examconfig.props.label.showInputLanguage=Show keyboard layout sebserver.examconfig.props.label.showInputLanguage.tooltip=Shows current keyboard layout and allows to switch between other active keyboard layouts +sebserver.examconfig.props.label.raiseHandButtonShow=Show raise hand button +sebserver.examconfig.props.label.raiseHandButtonShow.tooltip= +sebserver.examconfig.props.label.raiseHandButtonAlwaysPromptMessage=Raise hand prompt message +sebserver.examconfig.props.label.raiseHandButtonAlwaysPromptMessage.tooltip=if this is enabled the raise hand function will always prompt the user to give a message for the raise hand action + + sebserver.examconfig.props.group.zoom=Enable Zoom (Win/Mac) sebserver.examconfig.props.label.enableZoomPage=Enable page zoom