seb-win-refactoring/SafeExamBrowser.Client/Operations/ProctoringOperation.cs

61 lines
1.7 KiB
C#
Raw Normal View History

/*
* 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 SafeExamBrowser.Core.Contracts.OperationModel;
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.Proctoring.Contracts;
namespace SafeExamBrowser.Client.Operations
{
internal class ProctoringOperation : ClientOperation
{
private readonly ILogger logger;
private readonly IProctoringController controller;
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
public override event StatusChangedEventHandler StatusChanged;
public ProctoringOperation(ClientContext context, ILogger logger, IProctoringController controller) : base(context)
{
this.controller = controller;
this.logger = logger;
}
public override OperationResult Perform()
{
// TODO
Context.Settings.Proctoring.Enabled = true;
if (Context.Settings.Proctoring.Enabled)
{
logger.Info("Initializing proctoring...");
StatusChanged?.Invoke(TextKey.OperationStatus_InitializeProctoring);
controller.Initialize(Context.Settings.Proctoring);
}
return OperationResult.Success;
}
public override OperationResult Revert()
{
if (Context.Settings.Proctoring.Enabled)
{
logger.Info("Terminating proctoring...");
StatusChanged?.Invoke(TextKey.OperationStatus_TerminateProctoring);
controller.Terminate();
}
return OperationResult.Success;
}
}
}