SEBWIN-821: Forgot to implement default values and data mapping for always on configuration.

This commit is contained in:
Damian Büchel 2024-01-11 12:32:48 +01:00
parent 181346b810
commit 8c45af88fb
6 changed files with 59 additions and 1 deletions

View file

@ -14,7 +14,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
{ {
internal class DataMapper internal class DataMapper
{ {
private BaseDataMapper[] mappers = private readonly BaseDataMapper[] mappers =
{ {
new ApplicationDataMapper(), new ApplicationDataMapper(),
new AudioDataMapper(), new AudioDataMapper(),
@ -27,6 +27,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
new SecurityDataMapper(), new SecurityDataMapper(),
new ServerDataMapper(), new ServerDataMapper(),
new ServiceDataMapper(), new ServiceDataMapper(),
new SystemDataMapper(),
new UserInterfaceDataMapper() new UserInterfaceDataMapper()
}; };

View file

@ -19,6 +19,9 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
case Keys.Display.AllowedDisplays: case Keys.Display.AllowedDisplays:
MapAllowedDisplays(settings, value); MapAllowedDisplays(settings, value);
break; break;
case Keys.Display.AlwaysOn:
MapAlwaysOn(settings, value);
break;
case Keys.Display.IgnoreError: case Keys.Display.IgnoreError:
MapIgnoreError(settings, value); MapIgnoreError(settings, value);
break; break;
@ -36,6 +39,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
} }
} }
private void MapAlwaysOn(AppSettings settings, object value)
{
if (value is bool alwaysOn)
{
settings.Display.AlwaysOn = alwaysOn;
}
}
private void MapIgnoreError(AppSettings settings, object value) private void MapIgnoreError(AppSettings settings, object value)
{ {
if (value is bool ignore) if (value is bool ignore)

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2023 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/.
*/
using SafeExamBrowser.Settings;
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
{
internal class SystemDataMapper : BaseDataMapper
{
internal override void Map(string key, object value, AppSettings settings)
{
switch (key)
{
case Keys.System.AlwaysOn:
MapAlwaysOn(settings, value);
break;
}
}
private void MapAlwaysOn(AppSettings settings, object value)
{
if (value is bool alwaysOn)
{
settings.System.AlwaysOn = alwaysOn;
}
}
}
}

View file

@ -177,6 +177,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal static class Display internal static class Display
{ {
internal const string AllowedDisplays = "allowedDisplaysMaxNumber"; internal const string AllowedDisplays = "allowedDisplaysMaxNumber";
internal const string AlwaysOn = "displayAlwaysOn";
internal const string IgnoreError = "allowedDisplaysIgnoreFailure"; internal const string IgnoreError = "allowedDisplaysIgnoreFailure";
internal const string InternalDisplayOnly = "allowedDisplayBuiltinEnforce"; internal const string InternalDisplayOnly = "allowedDisplayBuiltinEnforce";
} }
@ -326,6 +327,11 @@ namespace SafeExamBrowser.Configuration.ConfigurationData
internal const string SetVmwareConfiguration = "setVmwareConfiguration"; internal const string SetVmwareConfiguration = "setVmwareConfiguration";
} }
internal static class System
{
internal const string AlwaysOn = "systemAlwaysOn";
}
internal static class UserInterface internal static class UserInterface
{ {
internal const string ShowAudio = "audioControlEnabled"; internal const string ShowAudio = "audioControlEnabled";

View file

@ -68,6 +68,7 @@
<Compile Include="ConfigurationData\DataMapping\SecurityDataMapper.cs" /> <Compile Include="ConfigurationData\DataMapping\SecurityDataMapper.cs" />
<Compile Include="ConfigurationData\DataMapping\ServerDataMapper.cs" /> <Compile Include="ConfigurationData\DataMapping\ServerDataMapper.cs" />
<Compile Include="ConfigurationData\DataMapping\ServiceDataMapper.cs" /> <Compile Include="ConfigurationData\DataMapping\ServiceDataMapper.cs" />
<Compile Include="ConfigurationData\DataMapping\SystemDataMapper.cs" />
<Compile Include="ConfigurationData\DataMapping\UserInterfaceDataMapper.cs" /> <Compile Include="ConfigurationData\DataMapping\UserInterfaceDataMapper.cs" />
<Compile Include="ConfigurationData\DataProcessor.cs" /> <Compile Include="ConfigurationData\DataProcessor.cs" />
<Compile Include="ConfigurationData\Json.cs" /> <Compile Include="ConfigurationData\Json.cs" />

View file

@ -435,6 +435,9 @@ namespace SebWindowsConfig
public const String KeyEnableF11 = "enableF11"; public const String KeyEnableF11 = "enableF11";
public const String KeyEnableF12 = "enableF12"; public const String KeyEnableF12 = "enableF12";
public const String KeyDisplayAlwaysOn = "displayAlwaysOn";
public const String KeySystemAlwaysOn = "systemAlwaysOn";
public enum sebConfigPurposes public enum sebConfigPurposes
{ {
sebConfigPurposeStartingExam, sebConfigPurposeConfiguringClient sebConfigPurposeStartingExam, sebConfigPurposeConfiguringClient
@ -1056,6 +1059,9 @@ namespace SebWindowsConfig
SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF11, true); SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF11, true);
SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF12, true); SEBSettings.settingsDefault.Add(SEBSettings.KeyEnableF12, true);
SEBSettings.settingsDefault.Add(SEBSettings.KeyDisplayAlwaysOn, true);
SEBSettings.settingsDefault.Add(SEBSettings.KeySystemAlwaysOn, true);
// Clear all "current" lists and dictionaries // Clear all "current" lists and dictionaries