diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs index 5441a513..90e5d197 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataMapping/ProctoringDataMapper.cs @@ -75,15 +75,6 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping case Keys.Proctoring.JitsiMeet.VideoMuted: MapJitsiMeetVideoMuted(settings, value); break; - case Keys.Proctoring.ScreenProctoring.CaptureApplicationName: - MapCaptureApplicationName(settings, value); - break; - case Keys.Proctoring.ScreenProctoring.CaptureBrowserUrl: - MapCaptureBrowserUrl(settings, value); - break; - case Keys.Proctoring.ScreenProctoring.CaptureWindowTitle: - MapCaptureWindowTitle(settings, value); - break; case Keys.Proctoring.ScreenProctoring.ClientId: MapClientId(settings, value); break; @@ -108,6 +99,15 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping case Keys.Proctoring.ScreenProctoring.MaxInterval: MapMaxInterval(settings, value); break; + case Keys.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData: + MapCaptureApplicationData(settings, value); + break; + case Keys.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData: + MapCaptureBrowserData(settings, value); + break; + case Keys.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle: + MapCaptureWindowTitle(settings, value); + break; case Keys.Proctoring.ScreenProctoring.MinInterval: MapMinInterval(settings, value); break; @@ -320,19 +320,19 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping } } - private void MapCaptureApplicationName(AppSettings settings, object value) + private void MapCaptureApplicationData(AppSettings settings, object value) { if (value is bool capture) { - settings.Proctoring.ScreenProctoring.CaptureApplicationName = capture; + settings.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData = capture; } } - private void MapCaptureBrowserUrl(AppSettings settings, object value) + private void MapCaptureBrowserData(AppSettings settings, object value) { if (value is bool capture) { - settings.Proctoring.ScreenProctoring.CaptureBrowserUrl = capture; + settings.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData = capture; } } @@ -340,7 +340,7 @@ namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping { if (value is bool capture) { - settings.Proctoring.ScreenProctoring.CaptureWindowTitle = capture; + settings.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle = capture; } } diff --git a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs index 0e17e0ff..3c73070b 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/DataValues.cs @@ -257,14 +257,14 @@ namespace SafeExamBrowser.Configuration.ConfigurationData settings.Proctoring.JitsiMeet.SendVideo = true; settings.Proctoring.JitsiMeet.ShowMeetingName = false; settings.Proctoring.JitsiMeet.VideoMuted = false; - settings.Proctoring.ScreenProctoring.CaptureApplicationName = true; - settings.Proctoring.ScreenProctoring.CaptureBrowserUrl = true; - settings.Proctoring.ScreenProctoring.CaptureWindowTitle = true; settings.Proctoring.ScreenProctoring.Enabled = false; settings.Proctoring.ScreenProctoring.ImageDownscaling = 1.0; settings.Proctoring.ScreenProctoring.ImageFormat = ImageFormat.Png; settings.Proctoring.ScreenProctoring.ImageQuantization = ImageQuantization.Grayscale4bpp; settings.Proctoring.ScreenProctoring.MaxInterval = 5000; + settings.Proctoring.ScreenProctoring.MetaData.CaptureApplicationData = true; + settings.Proctoring.ScreenProctoring.MetaData.CaptureBrowserData = true; + settings.Proctoring.ScreenProctoring.MetaData.CaptureWindowTitle = true; settings.Proctoring.ScreenProctoring.MinInterval = 1000; settings.Proctoring.ShowRaiseHandNotification = true; settings.Proctoring.ShowTaskbarNotification = true; diff --git a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs index 8ba91236..32ab06dd 100644 --- a/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs +++ b/SafeExamBrowser.Configuration/ConfigurationData/Keys.cs @@ -258,9 +258,6 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal static class ScreenProctoring { - internal const string CaptureApplicationName = "screenProctoringMetadataActiveAppEnabled"; - internal const string CaptureBrowserUrl = "screenProctoringMetadataURLEnabled"; - internal const string CaptureWindowTitle = "screenProctoringMetadataWindowTitleEnabled"; internal const string ClientId = "screenProctoringClientId"; internal const string ClientSecret = "screenProctoringClientSecret"; internal const string Enabled = "enableScreenProctoring"; @@ -271,6 +268,13 @@ namespace SafeExamBrowser.Configuration.ConfigurationData internal const string MaxInterval = "screenProctoringScreenshotMaxInterval"; internal const string MinInterval = "screenProctoringScreenshotMinInterval"; internal const string ServiceUrl = "screenProctoringServiceURL"; + + internal static class MetaData + { + internal const string CaptureApplicationData = "screenProctoringMetadataActiveAppEnabled"; + internal const string CaptureBrowserData = "screenProctoringMetadataURLEnabled"; + internal const string CaptureWindowTitle = "screenProctoringMetadataWindowTitleEnabled"; + } } internal static class Zoom diff --git a/SafeExamBrowser.Proctoring/ScreenProctoring/Data/MetaDataAggregator.cs b/SafeExamBrowser.Proctoring/ScreenProctoring/Data/MetaDataAggregator.cs index 1f7e9f57..7567a43c 100644 --- a/SafeExamBrowser.Proctoring/ScreenProctoring/Data/MetaDataAggregator.cs +++ b/SafeExamBrowser.Proctoring/ScreenProctoring/Data/MetaDataAggregator.cs @@ -12,6 +12,7 @@ using System.Text; using SafeExamBrowser.Browser.Contracts; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Monitoring.Contracts.Applications; +using SafeExamBrowser.Settings.Proctoring; using SafeExamBrowser.WindowsApi.Contracts.Events; namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data @@ -21,6 +22,7 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data private readonly IApplicationMonitor applicationMonitor; private readonly IBrowserApplication browser; private readonly ILogger logger; + private readonly MetaDataSettings settings; private string applicationInfo; private string browserInfo; @@ -41,16 +43,23 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data WindowTitle = windowTitle }; - internal MetaDataAggregator(IApplicationMonitor applicationMonitor, IBrowserApplication browser, TimeSpan elapsed, ILogger logger) + internal MetaDataAggregator( + IApplicationMonitor applicationMonitor, + IBrowserApplication browser, + TimeSpan elapsed, + ILogger logger, + MetaDataSettings settings) { this.applicationMonitor = applicationMonitor; this.browser = browser; this.elapsed = elapsed; this.logger = logger; + this.settings = settings; } internal void Capture(IntervalTrigger interval = default, KeyboardTrigger keyboard = default, MouseTrigger mouse = default) { + Initialize(); CaptureApplicationData(); CaptureBrowserData(); @@ -74,24 +83,29 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data { if (applicationMonitor.TryGetActiveApplication(out var application)) { - applicationInfo = BuildApplicationInfo(application); - windowTitle = string.IsNullOrEmpty(application.Window.Title) ? "-" : application.Window.Title; - } - else - { - applicationInfo = "-"; - windowTitle = "-"; + if (settings.CaptureApplicationData) + { + applicationInfo = BuildApplicationInfo(application); + } + + if (settings.CaptureWindowTitle) + { + windowTitle = string.IsNullOrEmpty(application.Window.Title) ? "-" : application.Window.Title; + } } } private void CaptureBrowserData() { - var windows = browser.GetWindows(); + if (settings.CaptureBrowserData) + { + var windows = browser.GetWindows(); - browserInfo = string.Join(", ", windows.Select(w => $"{(w.IsMainWindow ? "Main" : "Additional")} Window: {w.Title} ({w.Url})")); - browserInfoWithoutUrls = string.Join(", ", windows.Select(w => $"{(w.IsMainWindow ? "Main" : "Additional")} Window: {w.Title}")); - urls = string.Join(", ", windows.Select(w => w.Url)); - urlCount = windows.Count(); + browserInfo = string.Join(", ", windows.Select(w => $"{(w.IsMainWindow ? "Main" : "Additional")} Window: {w.Title} ({w.Url})")); + browserInfoWithoutUrls = string.Join(", ", windows.Select(w => $"{(w.IsMainWindow ? "Main" : "Additional")} Window: {w.Title}")); + urls = string.Join(", ", windows.Select(w => w.Url)); + urlCount = windows.Count(); + } } private void CaptureIntervalTrigger(IntervalTrigger interval) @@ -137,5 +151,15 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data return info.ToString(); } + + private void Initialize() + { + applicationInfo = "-"; + browserInfo = "-"; + browserInfoWithoutUrls = "-"; + triggerInfo = "-"; + urls = "-"; + windowTitle = "-"; + } } } diff --git a/SafeExamBrowser.Proctoring/ScreenProctoring/DataCollector.cs b/SafeExamBrowser.Proctoring/ScreenProctoring/DataCollector.cs index f9809358..f2998d7c 100644 --- a/SafeExamBrowser.Proctoring/ScreenProctoring/DataCollector.cs +++ b/SafeExamBrowser.Proctoring/ScreenProctoring/DataCollector.cs @@ -147,7 +147,7 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring { try { - var metaData = new MetaDataAggregator(applicationMonitor, browser, elapsed, logger.CloneFor(nameof(MetaDataAggregator))); + var metaData = new MetaDataAggregator(applicationMonitor, browser, elapsed, logger.CloneFor(nameof(MetaDataAggregator)), settings.MetaData); var screenShot = new ScreenShotProcessor(logger.CloneFor(nameof(ScreenShotProcessor)), settings); metaData.Capture(interval, keyboard, mouse); diff --git a/SafeExamBrowser.Settings/Proctoring/MetaDataSettings.cs b/SafeExamBrowser.Settings/Proctoring/MetaDataSettings.cs new file mode 100644 index 00000000..92b609dd --- /dev/null +++ b/SafeExamBrowser.Settings/Proctoring/MetaDataSettings.cs @@ -0,0 +1,34 @@ +/* + * 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 System; + +namespace SafeExamBrowser.Settings.Proctoring +{ + /// + /// All settings related to the metadata capturing of the screen proctoring. + /// + [Serializable] + public class MetaDataSettings + { + /// + /// Determines whether data of the active application shall be captured and transmitted. + /// + public bool CaptureApplicationData { get; set; } + + /// + /// Determines whether data of the browser application shall be captured and transmitted. + /// + public bool CaptureBrowserData { get; set; } + + /// + /// Determines whether the title of the currently active window shall be captured and transmitted. + /// + public bool CaptureWindowTitle { get; set; } + } +} diff --git a/SafeExamBrowser.Settings/Proctoring/ScreenProctoringSettings.cs b/SafeExamBrowser.Settings/Proctoring/ScreenProctoringSettings.cs index 799b9a1b..069742d7 100644 --- a/SafeExamBrowser.Settings/Proctoring/ScreenProctoringSettings.cs +++ b/SafeExamBrowser.Settings/Proctoring/ScreenProctoringSettings.cs @@ -16,21 +16,6 @@ namespace SafeExamBrowser.Settings.Proctoring [Serializable] public class ScreenProctoringSettings { - /// - /// Determines whether the name of the active application shall be captured and transmitted as part of the image meta data. - /// - public bool CaptureApplicationName { get; set; } - - /// - /// Determines whether the URL of the currently opened web page shall be captured and transmitted as part of the image meta data. - /// - public bool CaptureBrowserUrl { get; set; } - - /// - /// Determines whether the title of the currently active window shall be captured and transmitted as part of the image meta data. - /// - public bool CaptureWindowTitle { get; set; } - /// /// The client identifier used for authentication with the screen proctoring service. /// @@ -71,6 +56,11 @@ namespace SafeExamBrowser.Settings.Proctoring /// public int MaxInterval { get; set; } + /// + /// All settings related to the metadata capturing of the screen proctoring. + /// + public MetaDataSettings MetaData { get; set; } + /// /// The minimum time interval in milliseconds between screen shot transmissions. /// @@ -80,5 +70,10 @@ namespace SafeExamBrowser.Settings.Proctoring /// The URL of the screen proctoring service. /// public string ServiceUrl { get; set; } + + public ScreenProctoringSettings() + { + MetaData = new MetaDataSettings(); + } } } diff --git a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj index 40006ad4..2d0e2e76 100644 --- a/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj +++ b/SafeExamBrowser.Settings/SafeExamBrowser.Settings.csproj @@ -76,6 +76,7 @@ +