SEBSP-107: Implemented resp. improved configuration for metadata capturing.

This commit is contained in:
Damian Büchel 2024-02-22 18:04:00 +01:00
parent 91f2c14a77
commit e5c02a1f74
8 changed files with 107 additions and 49 deletions

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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

View file

@ -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();
@ -73,18 +82,22 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data
private void CaptureApplicationData()
{
if (applicationMonitor.TryGetActiveApplication(out var application))
{
if (settings.CaptureApplicationData)
{
applicationInfo = BuildApplicationInfo(application);
}
if (settings.CaptureWindowTitle)
{
windowTitle = string.IsNullOrEmpty(application.Window.Title) ? "-" : application.Window.Title;
}
else
{
applicationInfo = "-";
windowTitle = "-";
}
}
private void CaptureBrowserData()
{
if (settings.CaptureBrowserData)
{
var windows = browser.GetWindows();
@ -93,6 +106,7 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring.Data
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 = "-";
}
}
}

View file

@ -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);

View file

@ -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
{
/// <summary>
/// All settings related to the metadata capturing of the screen proctoring.
/// </summary>
[Serializable]
public class MetaDataSettings
{
/// <summary>
/// Determines whether data of the active application shall be captured and transmitted.
/// </summary>
public bool CaptureApplicationData { get; set; }
/// <summary>
/// Determines whether data of the browser application shall be captured and transmitted.
/// </summary>
public bool CaptureBrowserData { get; set; }
/// <summary>
/// Determines whether the title of the currently active window shall be captured and transmitted.
/// </summary>
public bool CaptureWindowTitle { get; set; }
}
}

View file

@ -16,21 +16,6 @@ namespace SafeExamBrowser.Settings.Proctoring
[Serializable]
public class ScreenProctoringSettings
{
/// <summary>
/// Determines whether the name of the active application shall be captured and transmitted as part of the image meta data.
/// </summary>
public bool CaptureApplicationName { get; set; }
/// <summary>
/// Determines whether the URL of the currently opened web page shall be captured and transmitted as part of the image meta data.
/// </summary>
public bool CaptureBrowserUrl { get; set; }
/// <summary>
/// Determines whether the title of the currently active window shall be captured and transmitted as part of the image meta data.
/// </summary>
public bool CaptureWindowTitle { get; set; }
/// <summary>
/// The client identifier used for authentication with the screen proctoring service.
/// </summary>
@ -71,6 +56,11 @@ namespace SafeExamBrowser.Settings.Proctoring
/// </summary>
public int MaxInterval { get; set; }
/// <summary>
/// All settings related to the metadata capturing of the screen proctoring.
/// </summary>
public MetaDataSettings MetaData { get; set; }
/// <summary>
/// The minimum time interval in milliseconds between screen shot transmissions.
/// </summary>
@ -80,5 +70,10 @@ namespace SafeExamBrowser.Settings.Proctoring
/// The URL of the screen proctoring service.
/// </summary>
public string ServiceUrl { get; set; }
public ScreenProctoringSettings()
{
MetaData = new MetaDataSettings();
}
}
}

View file

@ -76,6 +76,7 @@
<Compile Include="Proctoring\ImageFormat.cs" />
<Compile Include="Proctoring\ImageQuantization.cs" />
<Compile Include="Proctoring\JitsiMeetSettings.cs" />
<Compile Include="Proctoring\MetaDataSettings.cs" />
<Compile Include="Proctoring\ProctoringSettings.cs" />
<Compile Include="Proctoring\ScreenProctoringSettings.cs" />
<Compile Include="Proctoring\WindowVisibility.cs" />