From 8d5560d3c45f1780400c39987a023c16dda0dec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Mon, 12 Apr 2021 15:59:42 +0200 Subject: [PATCH] SEBWIN-451: Implemented dynamic reconfiguration for proctoring. --- .../ProctoringController.cs | 20 +++++++++++-------- ...toringConfigurationReceivedEventHandler.cs | 2 +- SafeExamBrowser.Server/Data/Attributes.cs | 2 +- SafeExamBrowser.Server/Parser.cs | 2 +- SafeExamBrowser.Server/ServerProxy.cs | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/SafeExamBrowser.Proctoring/ProctoringController.cs b/SafeExamBrowser.Proctoring/ProctoringController.cs index 00163424..7161c9dc 100644 --- a/SafeExamBrowser.Proctoring/ProctoringController.cs +++ b/SafeExamBrowser.Proctoring/ProctoringController.cs @@ -117,21 +117,25 @@ namespace SafeExamBrowser.Proctoring settings.JitsiMeet.ServerUrl = serverUrl.Replace(Uri.UriSchemeHttps, "").Replace(Uri.UriSchemeHttp, "").Replace(Uri.SchemeDelimiter, ""); settings.JitsiMeet.Token = token; - if (window != default(IProctoringWindow)) - { - StopProctoring(); - } - + StopProctoring(); StartProctoring(); } - private void Server_ProctoringConfigurationReceived(bool enableChat, bool receiveAudio, bool receiveVideo) + private void Server_ProctoringConfigurationReceived(bool allowChat, bool receiveAudio, bool receiveVideo) { logger.Info("Proctoring configuration received."); - // TODO: How to set these things dynamically?!? + settings.JitsiMeet.AllowChat = allowChat; + settings.JitsiMeet.ReceiveAudio = receiveAudio; + settings.JitsiMeet.ReceiveVideo = receiveVideo; - control.ExecuteScriptAsync("api.executeCommand('toggleChat');"); + if (allowChat || receiveVideo) + { + settings.WindowVisibility = WindowVisibility.AllowToHide; + } + + StopProctoring(); + StartProctoring(); } private void StartProctoring() diff --git a/SafeExamBrowser.Server.Contracts/Events/ProctoringConfigurationReceivedEventHandler.cs b/SafeExamBrowser.Server.Contracts/Events/ProctoringConfigurationReceivedEventHandler.cs index 55e26ee0..c4c33ff1 100644 --- a/SafeExamBrowser.Server.Contracts/Events/ProctoringConfigurationReceivedEventHandler.cs +++ b/SafeExamBrowser.Server.Contracts/Events/ProctoringConfigurationReceivedEventHandler.cs @@ -11,5 +11,5 @@ namespace SafeExamBrowser.Server.Contracts.Events /// /// Event handler used to indicate that proctoring configuration data has been received. /// - public delegate void ProctoringConfigurationReceivedEventHandler(bool enableChat, bool receiveAudio, bool receiveVideo); + public delegate void ProctoringConfigurationReceivedEventHandler(bool allowChat, bool receiveAudio, bool receiveVideo); } diff --git a/SafeExamBrowser.Server/Data/Attributes.cs b/SafeExamBrowser.Server/Data/Attributes.cs index 9e735cb0..2174f633 100644 --- a/SafeExamBrowser.Server/Data/Attributes.cs +++ b/SafeExamBrowser.Server/Data/Attributes.cs @@ -10,7 +10,7 @@ namespace SafeExamBrowser.Server.Data { internal class Attributes { - public bool EnableChat { get; set; } + public bool AllowChat { get; set; } public bool ReceiveAudio { get; set; } public bool ReceiveVideo { get; set; } public string RoomName { get; set; } diff --git a/SafeExamBrowser.Server/Parser.cs b/SafeExamBrowser.Server/Parser.cs index fea161c2..54d7bb76 100644 --- a/SafeExamBrowser.Server/Parser.cs +++ b/SafeExamBrowser.Server/Parser.cs @@ -169,7 +169,7 @@ namespace SafeExamBrowser.Server attributes.Token = attributesJson["jitsiMeetToken"].Value(); break; case Instructions.PROCTORING_RECONFIGURATION: - attributes.EnableChat = attributesJson["jitsiMeetFeatureFlagChat"].Value(); + attributes.AllowChat = attributesJson["jitsiMeetFeatureFlagChat"].Value(); attributes.ReceiveAudio = attributesJson["jitsiMeetReceiveAudio"].Value(); attributes.ReceiveVideo = attributesJson["jitsiMeetReceiveVideo"].Value(); break; diff --git a/SafeExamBrowser.Server/ServerProxy.cs b/SafeExamBrowser.Server/ServerProxy.cs index cdf3fd55..afae8e45 100644 --- a/SafeExamBrowser.Server/ServerProxy.cs +++ b/SafeExamBrowser.Server/ServerProxy.cs @@ -396,7 +396,7 @@ namespace SafeExamBrowser.Server Task.Run(() => ProctoringInstructionReceived?.Invoke(attributes.RoomName, attributes.ServerUrl, attributes.Token)); break; case Instructions.PROCTORING_RECONFIGURATION: - Task.Run(() => ProctoringConfigurationReceived?.Invoke(attributes.EnableChat, attributes.ReceiveAudio, attributes.ReceiveVideo)); + Task.Run(() => ProctoringConfigurationReceived?.Invoke(attributes.AllowChat, attributes.ReceiveAudio, attributes.ReceiveVideo)); break; case Instructions.QUIT: Task.Run(() => TerminationRequested?.Invoke());