SEBWIN-444: Ensured server connectivity is maintained when reconfiguring and fixed detection of Moodle sessions.

This commit is contained in:
Damian Büchel 2020-12-02 17:43:02 +01:00
parent 786193aff4
commit a3292a7977
5 changed files with 23 additions and 9 deletions

View file

@ -286,7 +286,7 @@ namespace SafeExamBrowser.Browser.Handlers
{
try
{
var location = locations.FirstOrDefault(l => l.Contains("moodle/login/index.php?testsession"));
var location = locations.FirstOrDefault(l => l.Contains("/login/index.php?testsession"));
if (location != default(string))
{

View file

@ -41,8 +41,6 @@ namespace SafeExamBrowser.Client.Operations
public override OperationResult Perform()
{
var result = OperationResult.Success;
if (Context.Settings.SessionMode == SessionMode.Server)
{
logger.Info("Initializing server...");
@ -54,15 +52,18 @@ namespace SafeExamBrowser.Client.Operations
Context.AppConfig.ServerExamId,
Context.AppConfig.ServerOauth2Token,
Context.Settings.Server);
if (Context.AppConfig.ServerConnectivityAutoStart)
{
server.StartConnectivity();
}
}
return result;
return OperationResult.Success;
}
public override OperationResult Revert()
{
var result = OperationResult.Success;
if (Context.Settings?.SessionMode == SessionMode.Server)
{
logger.Info("Finalizing server...");
@ -71,7 +72,7 @@ namespace SafeExamBrowser.Client.Operations
server.StopConnectivity();
}
return result;
return OperationResult.Success;
}
}
}

View file

@ -161,6 +161,11 @@ namespace SafeExamBrowser.Configuration.Contracts
/// </summary>
public string ServerConnectionToken { get; set; }
/// <summary>
/// Determines whether the server connectivity should automatically be started in case of a reconfiguration.
/// </summary>
public bool ServerConnectivityAutoStart { get; set; }
/// <summary>
/// The identifier of the selected server exam.
/// </summary>

View file

@ -135,8 +135,11 @@ namespace SafeExamBrowser.Runtime.Operations
{
if (Context.Current.Settings.SessionMode == SessionMode.Server)
{
logger.Info("Initializing server configuration for next session...");
Context.Next.AppConfig.ServerApi = Context.Current.AppConfig.ServerApi;
Context.Next.AppConfig.ServerConnectionToken = Context.Current.AppConfig.ServerConnectionToken;
Context.Next.AppConfig.ServerConnectivityAutoStart = true;
Context.Next.AppConfig.ServerExamId = Context.Current.AppConfig.ServerExamId;
Context.Next.AppConfig.ServerOauth2Token = Context.Current.AppConfig.ServerOauth2Token;

View file

@ -321,9 +321,14 @@ namespace SafeExamBrowser.Server
if (success)
{
if (TryParseInstruction(response.Content, out var instruction) && instruction == "SEB_QUIT")
if (TryParseInstruction(response.Content, out var instruction))
{
Task.Run(() => TerminationRequested?.Invoke());
switch (instruction)
{
case "SEB_QUIT":
Task.Run(() => TerminationRequested?.Invoke());
break;
}
}
}
else