SEBWIN-449: Implemented workaround due to webcam and microphone access issue when using data URI for proctoring content.
This commit is contained in:
parent
52217fa477
commit
f92c717e32
10 changed files with 44 additions and 9 deletions
|
@ -249,7 +249,7 @@ namespace SafeExamBrowser.Client
|
||||||
|
|
||||||
private IOperation BuildProctoringOperation()
|
private IOperation BuildProctoringOperation()
|
||||||
{
|
{
|
||||||
var controller = new ProctoringController(ModuleLogger(nameof(ProctoringController)), uiFactory);
|
var controller = new ProctoringController(context.AppConfig, new FileSystem(), ModuleLogger(nameof(ProctoringController)), uiFactory);
|
||||||
var operation = new ProctoringOperation(context, logger, controller);
|
var operation = new ProctoringOperation(context, logger, controller);
|
||||||
|
|
||||||
context.ProctoringController = controller;
|
context.ProctoringController = controller;
|
||||||
|
|
|
@ -30,9 +30,6 @@ namespace SafeExamBrowser.Client.Operations
|
||||||
|
|
||||||
public override OperationResult Perform()
|
public override OperationResult Perform()
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
Context.Settings.Proctoring.Enabled = true;
|
|
||||||
|
|
||||||
if (Context.Settings.Proctoring.Enabled)
|
if (Context.Settings.Proctoring.Enabled)
|
||||||
{
|
{
|
||||||
logger.Info("Initializing proctoring...");
|
logger.Info("Initializing proctoring...");
|
||||||
|
|
|
@ -2,12 +2,18 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="margin: 0">
|
||||||
<div id="placeholder" />
|
<div id="placeholder" />
|
||||||
<script src='https://meet.jit.si/external_api.js'></script>
|
<script src='https://meet.jit.si/external_api.js'></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var domain = "%%_DOMAIN_%%";
|
var domain = "%%_DOMAIN_%%";
|
||||||
var options = {
|
var options = {
|
||||||
|
configOverwrite: {
|
||||||
|
startAudioOnly: false,
|
||||||
|
startWithAudioMuted: true,
|
||||||
|
startWithVideoMuted: false,
|
||||||
|
disable1On1Mode: true
|
||||||
|
},
|
||||||
height: "100%",
|
height: "100%",
|
||||||
jwt: "%%_TOKEN_%%",
|
jwt: "%%_TOKEN_%%",
|
||||||
parentNode: document.querySelector('#placeholder'),
|
parentNode: document.querySelector('#placeholder'),
|
||||||
|
|
|
@ -27,6 +27,7 @@ namespace SafeExamBrowser.Proctoring
|
||||||
{
|
{
|
||||||
if (e.PermissionKind == CoreWebView2PermissionKind.Camera || e.PermissionKind == CoreWebView2PermissionKind.Microphone)
|
if (e.PermissionKind == CoreWebView2PermissionKind.Camera || e.PermissionKind == CoreWebView2PermissionKind.Microphone)
|
||||||
{
|
{
|
||||||
|
e.State = CoreWebView2PermissionState.Allow;
|
||||||
logger.Info($"Granted access to {e.PermissionKind}.");
|
logger.Info($"Granted access to {e.PermissionKind}.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using SafeExamBrowser.Configuration.Contracts;
|
||||||
using SafeExamBrowser.Logging.Contracts;
|
using SafeExamBrowser.Logging.Contracts;
|
||||||
using SafeExamBrowser.Proctoring.Contracts;
|
using SafeExamBrowser.Proctoring.Contracts;
|
||||||
using SafeExamBrowser.Settings.Proctoring;
|
using SafeExamBrowser.Settings.Proctoring;
|
||||||
|
using SafeExamBrowser.SystemComponents.Contracts;
|
||||||
using SafeExamBrowser.UserInterface.Contracts;
|
using SafeExamBrowser.UserInterface.Contracts;
|
||||||
using SafeExamBrowser.UserInterface.Contracts.Proctoring;
|
using SafeExamBrowser.UserInterface.Contracts.Proctoring;
|
||||||
|
|
||||||
|
@ -19,13 +21,18 @@ namespace SafeExamBrowser.Proctoring
|
||||||
{
|
{
|
||||||
public class ProctoringController : IProctoringController
|
public class ProctoringController : IProctoringController
|
||||||
{
|
{
|
||||||
|
private readonly AppConfig appConfig;
|
||||||
|
private readonly IFileSystem fileSystem;
|
||||||
private readonly IModuleLogger logger;
|
private readonly IModuleLogger logger;
|
||||||
private readonly IUserInterfaceFactory uiFactory;
|
private readonly IUserInterfaceFactory uiFactory;
|
||||||
|
|
||||||
|
private string filePath;
|
||||||
private IProctoringWindow window;
|
private IProctoringWindow window;
|
||||||
|
|
||||||
public ProctoringController(IModuleLogger logger, IUserInterfaceFactory uiFactory)
|
public ProctoringController(AppConfig appConfig, IFileSystem fileSystem, IModuleLogger logger, IUserInterfaceFactory uiFactory)
|
||||||
{
|
{
|
||||||
|
this.appConfig = appConfig;
|
||||||
|
this.fileSystem = fileSystem;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.uiFactory = uiFactory;
|
this.uiFactory = uiFactory;
|
||||||
}
|
}
|
||||||
|
@ -34,11 +41,15 @@ namespace SafeExamBrowser.Proctoring
|
||||||
{
|
{
|
||||||
if (settings.JitsiMeet.Enabled || settings.Zoom.Enabled)
|
if (settings.JitsiMeet.Enabled || settings.Zoom.Enabled)
|
||||||
{
|
{
|
||||||
|
var content = LoadContent(settings);
|
||||||
var control = new ProctoringControl(logger.CloneFor(nameof(ProctoringControl)));
|
var control = new ProctoringControl(logger.CloneFor(nameof(ProctoringControl)));
|
||||||
|
|
||||||
|
filePath = Path.Combine(appConfig.TemporaryDirectory, $"{Path.GetRandomFileName()}_index.html");
|
||||||
|
fileSystem.Save(content, filePath);
|
||||||
|
|
||||||
control.EnsureCoreWebView2Async().ContinueWith(_ =>
|
control.EnsureCoreWebView2Async().ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
control.Dispatcher.Invoke(() => control.NavigateToString(LoadContent(settings)));
|
control.Dispatcher.Invoke(() => control.CoreWebView2.Navigate(filePath));
|
||||||
});
|
});
|
||||||
|
|
||||||
window = uiFactory.CreateProctoringWindow(control);
|
window = uiFactory.CreateProctoringWindow(control);
|
||||||
|
@ -55,6 +66,7 @@ namespace SafeExamBrowser.Proctoring
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
{
|
{
|
||||||
window?.Close();
|
window?.Close();
|
||||||
|
fileSystem.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string LoadContent(ProctoringSettings settings)
|
private string LoadContent(ProctoringSettings settings)
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.Configuration.Contracts\SafeExamBrowser.Configuration.Contracts.csproj">
|
||||||
|
<Project>{7d74555e-63e1-4c46-bd0a-8580552368c8}</Project>
|
||||||
|
<Name>SafeExamBrowser.Configuration.Contracts</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.Logging.Contracts\SafeExamBrowser.Logging.Contracts.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.Logging.Contracts\SafeExamBrowser.Logging.Contracts.csproj">
|
||||||
<Project>{64ea30fb-11d4-436a-9c2b-88566285363e}</Project>
|
<Project>{64ea30fb-11d4-436a-9c2b-88566285363e}</Project>
|
||||||
<Name>SafeExamBrowser.Logging.Contracts</Name>
|
<Name>SafeExamBrowser.Logging.Contracts</Name>
|
||||||
|
@ -86,6 +90,10 @@
|
||||||
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
|
<Project>{30b2d907-5861-4f39-abad-c4abf1b3470e}</Project>
|
||||||
<Name>SafeExamBrowser.Settings</Name>
|
<Name>SafeExamBrowser.Settings</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\SafeExamBrowser.SystemComponents.Contracts\SafeExamBrowser.SystemComponents.Contracts.csproj">
|
||||||
|
<Project>{903129c6-e236-493b-9ad6-c6a57f647a3a}</Project>
|
||||||
|
<Name>SafeExamBrowser.SystemComponents.Contracts</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\SafeExamBrowser.UserInterface.Contracts\SafeExamBrowser.UserInterface.Contracts.csproj">
|
<ProjectReference Include="..\SafeExamBrowser.UserInterface.Contracts\SafeExamBrowser.UserInterface.Contracts.csproj">
|
||||||
<Project>{c7889e97-6ff6-4a58-b7cb-521ed276b316}</Project>
|
<Project>{c7889e97-6ff6-4a58-b7cb-521ed276b316}</Project>
|
||||||
<Name>SafeExamBrowser.UserInterface.Contracts</Name>
|
<Name>SafeExamBrowser.UserInterface.Contracts</Name>
|
||||||
|
|
|
@ -22,5 +22,10 @@ namespace SafeExamBrowser.SystemComponents.Contracts
|
||||||
/// Deletes the item at the given path, if it exists. Directories will be completely deleted, including all subdirectories and files.
|
/// Deletes the item at the given path, if it exists. Directories will be completely deleted, including all subdirectories and files.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Delete(string path);
|
void Delete(string path);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the given content as a file under the specified path. If the file doesn't yet exist, it will be created, otherwise overwritten.
|
||||||
|
/// </summary>
|
||||||
|
void Save(string content, string path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,10 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
Directory.Delete(path, true);
|
Directory.Delete(path, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Save(string content, string path)
|
||||||
|
{
|
||||||
|
File.WriteAllText(path, content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Desktop.Windows"
|
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Desktop.Windows"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d" Height="250" Width="350" Topmost="True" WindowStyle="None">
|
||||||
Title="ProctoringWindow" Height="450" Width="800">
|
|
||||||
<DockPanel Name="ControlContainer" />
|
<DockPanel Name="ControlContainer" />
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
@ -75,6 +75,8 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
Closing += ProctoringWindow_Closing;
|
Closing += ProctoringWindow_Closing;
|
||||||
|
Top = SystemParameters.WorkArea.Height - Height;
|
||||||
|
Left = SystemParameters.WorkArea.Width - Width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue