From d113d592231cb6bd22ab7707c78f7be7432b0ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Wed, 10 Feb 2021 00:49:32 +0100 Subject: [PATCH] SEBWIN-448: Added configuration scaffolding for remote proctoring. --- .../ConfigurationData/DataMapper.cs | 1 + .../DataMapping/ProctoringDataMapper.cs | 37 +++++++++++++++++++ .../ConfigurationData/Keys.cs | 8 ++-- .../SafeExamBrowser.Configuration.csproj | 1 + .../Operations/DisclaimerOperation.cs | 18 ++++++++- SafeExamBrowser.Settings/AppSettings.cs | 7 ++++ .../Proctoring/ProctoringSettings.cs | 24 ++++++++++++ .../SafeExamBrowser.Settings.csproj | 1 + 8 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs create mode 100644 SafeExamBrowser.Settings/Proctoring/ProctoringSettings.cs diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs index 52040b4a..c694d176 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapper.cs @@ -22,6 +22,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData new ConfigurationFileDataMapper(), new GeneralDataMapper(), new InputDataMapper(), + new ProctoringDataMapper(), new SecurityDataMapper(), new ServerDataMapper(), new ServiceDataMapper(), diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs new file mode 100644 index 00000000..23097435 --- /dev/null +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs @@ -0,0 +1,37 @@ +/* + * 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/. + */ + +using System.Collections.Generic; +using SafeExamBrowser.Settings; + +namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping +{ + internal class ProctoringDataMapper : BaseDataMapper + { + internal override void Map(string key, object value, AppSettings settings) + { + switch (key) + { + // TODO + } + } + + internal override void MapGlobal(IDictionary rawData, AppSettings settings) + { + MapProctoringEnabled(rawData, settings); + } + + private void MapProctoringEnabled(IDictionary rawData, AppSettings settings) + { + var jitsiEnabled = rawData.TryGetValue(Keys.Proctoring.JitsiMeet.Enabled, out var v) && v is bool b && b; + var zoomEnabled = rawData.TryGetValue(Keys.Proctoring.Zoom.Enabled, out v) && v is bool b2 && b2; + + settings.Proctoring.Enabled = jitsiEnabled || zoomEnabled; + } + } +} diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index bd48f557..c9b9d4de 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -214,18 +214,16 @@ namespace SafeExamBrowser.Configuration.ConfigurationData } } - internal static class RemoteProctoring + internal static class Proctoring { - internal const string Enabled = "jitsiMeetEnable"; - internal static class JitsiMeet { - + internal const string Enabled = "jitsiMeetEnable"; } internal static class Zoom { - + internal const string Enabled = "zoomEnable"; } } diff --git a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj index 2f52f6ef..4d9aa905 100644 --- a/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj +++ b/SafeExamBrowser.Configuration/SafeExamBrowser.Configuration.csproj @@ -63,6 +63,7 @@ + diff --git a/SafeExamBrowser.Runtime/Operations/DisclaimerOperation.cs b/SafeExamBrowser.Runtime/Operations/DisclaimerOperation.cs index 77c84f4a..55c85f50 100644 --- a/SafeExamBrowser.Runtime/Operations/DisclaimerOperation.cs +++ b/SafeExamBrowser.Runtime/Operations/DisclaimerOperation.cs @@ -29,12 +29,26 @@ namespace SafeExamBrowser.Runtime.Operations public override OperationResult Perform() { - return ShowDisclaimer(); + if (Context.Next.Settings.Proctoring.Enabled) + { + return ShowDisclaimer(); + } + + logger.Info("Remote proctoring is disabled, skipping disclaimer."); + + return OperationResult.Success; } public override OperationResult Repeat() { - return ShowDisclaimer(); + if (Context.Next.Settings.Proctoring.Enabled) + { + return ShowDisclaimer(); + } + + logger.Info("Remote proctoring is disabled, skipping disclaimer."); + + return OperationResult.Success; } public override OperationResult Revert() diff --git a/SafeExamBrowser.Settings/AppSettings.cs b/SafeExamBrowser.Settings/AppSettings.cs index d7710387..f5ce07a6 100644 --- a/SafeExamBrowser.Settings/AppSettings.cs +++ b/SafeExamBrowser.Settings/AppSettings.cs @@ -11,6 +11,7 @@ using SafeExamBrowser.Settings.Applications; using SafeExamBrowser.Settings.Browser; using SafeExamBrowser.Settings.Logging; using SafeExamBrowser.Settings.Monitoring; +using SafeExamBrowser.Settings.Proctoring; using SafeExamBrowser.Settings.Security; using SafeExamBrowser.Settings.Server; using SafeExamBrowser.Settings.Service; @@ -65,6 +66,11 @@ namespace SafeExamBrowser.Settings /// public MouseSettings Mouse { get; set; } + /// + /// All proctoring-related settings. + /// + public ProctoringSettings Proctoring { get; set; } + /// /// All security-related settings. /// @@ -103,6 +109,7 @@ namespace SafeExamBrowser.Settings Browser = new BrowserSettings(); Keyboard = new KeyboardSettings(); Mouse = new MouseSettings(); + Proctoring = new ProctoringSettings(); Security = new SecuritySettings(); Server = new ServerSettings(); Service = new ServiceSettings(); diff --git a/SafeExamBrowser.Settings/Proctoring/ProctoringSettings.cs b/SafeExamBrowser.Settings/Proctoring/ProctoringSettings.cs new file mode 100644 index 00000000..306c68e8 --- /dev/null +++ b/SafeExamBrowser.Settings/Proctoring/ProctoringSettings.cs @@ -0,0 +1,24 @@ +/* + * 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/. + */ + +using System; + +namespace SafeExamBrowser.Settings.Proctoring +{ + /// + /// Defines all settings related to remote proctoring. + /// + [Serializable] + public class ProctoringSettings + { + /// + /// Determines whether the entire remote proctoring feature is enabled. + /// + public bool Enabled { get; set; } + } +} diff --git a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj index 4dfd9afe..5f85298c 100644 --- a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj +++ b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj @@ -71,6 +71,7 @@ +