Skip to content

Commit

Permalink
Update MoodleManager.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
fwild authored Sep 21, 2023
1 parent 36c7e61 commit d9de3ea
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Assets/MirageXR/Player/Scripts/Moodle/MoodleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ private void Update() //TODO: remove ui logic
/// <summary>
/// Logs in a user with the given credentials
/// </summary>
/// <param name="username">The username of the user which should be logged in</param>
/// <param name="password">The password of the user which should be logged in</param>
/// <param name="username">The username of the user to log in</param>
/// <param name="password">The password of the user to log in</param>
/// <returns>Returns true if the login was successful, otherwise false</returns>
public async Task<bool> Login(string username, string password)
{
Expand Down Expand Up @@ -85,7 +85,7 @@ public async Task<bool> Login(string username, string password)

if (!DBManager.LoggedIn)
{
Debug.LogError("You are not logged in");
Debug.LogError("[MoodleManager] Moodle upload failed: User not logged in");
return (false, "Error: You are not logged in");
}

Expand Down Expand Up @@ -125,12 +125,12 @@ public async Task<bool> Login(string username, string password)
// The file handling response should be displayed as Log, not LogError
if (response.Contains("File exist"))
{
Debug.LogError($"Error on uploading: {response}");
Debug.LogError($"[MoodleManager] Error on uploading: {response}");
}
else
{
Maggie.Speak("Uploading ARLEM failed. Check your system administrator.");
Debug.LogError($"Error on uploading: {response}");
Maggie.Speak("Upload of the activity failed. Please check with your system administrator.");
Debug.LogError($"[MoodleManager] Error on uploading: {response}");
}

if (_progressText)
Expand Down Expand Up @@ -164,7 +164,7 @@ public async Task<string> GetUserId()
var (result, response) = await Network.GetCustomDataFromAPIRequestAsync(DBManager.token, DBManager.domain, requestValue, function, parametersValueFormat);
if (!result)
{
Debug.LogError($"Can't get UserId, error: {response}");
Debug.LogError($"[MoodleManager] Can't get UserId, error: {response}");
return null;
}
DBManager.userid = Regex.Replace(response, "[^0-9]+", string.Empty); // only numbers
Expand All @@ -184,7 +184,7 @@ public async Task<string> GetUserMail()
var (result, response) = await Network.GetCustomDataFromAPIRequestAsync(DBManager.token, DBManager.domain, requestValue, function, parametersValueFormat);
if (!result)
{
Debug.LogError($"Can't get Usermail, error: {response}");
Debug.LogError($"[MoodleManager] Can't get Usermail, error: {response}");
return null;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ private static async Task<string> GetArlemListJson(string serverUrl)

if (!result || response.StartsWith("Error"))
{
Debug.LogError($"Network error\nmessage: {response}");
Debug.LogError($"[MoodleManager] Network error: {response}");
return null;
}

Expand All @@ -246,7 +246,7 @@ private static List<Session> ParseArlemListJson(string json)

if (json == emptyJson)
{
Debug.LogWarning("Probably there is no public activity on the server.");
Debug.LogWarning("[MoodleManager] Probably there is no public activity on the server.");
return arlemList;
}

Expand All @@ -264,7 +264,7 @@ private static List<Session> ParseArlemListJson(string json)
}
catch (Exception e)
{
Debug.LogError($"ParseArlemListJson error\nmessage: {e}");
Debug.LogError($"[MoodleManager] ParseArlemListJson error\nmessage: {e}");
return null;
}
}
Expand All @@ -282,11 +282,11 @@ public async Task<bool> DeleteArlem(string itemID, string sessionID)
var value = result && !response.StartsWith("Error");
if (value)
{
Debug.LogInfo(sessionID + " is deleted from server");
Debug.LogInfo("[MoodleManager] " + sessionID + " is deleted from server");
}
else
{
Debug.LogError(response);
Debug.LogError("[MoodleManager] error deleting:" + response);
}

return value;
Expand All @@ -304,11 +304,11 @@ public async Task UpdateViewsOfActivity(string itemID)
if (!result || response.StartsWith("Error"))
{
var maxLenght = 200;
Debug.LogError(response.Length > maxLenght ? response.Substring(0, maxLenght) : response);
Debug.LogError("[MoodleManager] error while increasing the hit counter of the activity:" + response.Length > maxLenght ? response.Substring(0, maxLenght) : response);
}
else
{
Debug.LogTrace(" Views column of the activity is increased");
Debug.LogTrace("[MoodleManager] hit counter of activity successfully increased");
}
}

Expand Down Expand Up @@ -336,7 +336,7 @@ private static async Task<byte[]> CompressRecord(string path, string recordingId
}
catch (Exception e)
{
Debug.LogError($"compression error: {e}");
Debug.LogError($"[MoodleManager] compression error: {e}");
}

return bytes;
Expand Down Expand Up @@ -379,7 +379,7 @@ private static async Task<byte[]> CompressRecord(string path, string recordingId
}
else
{
Debug.LogError(error);
Debug.LogError("[MoodleManager] error during download of activity: " + error);
}
}
catch (Exception e)
Expand All @@ -399,4 +399,4 @@ private static async Task<byte[]> CompressRecord(string path, string recordingId
return (result, activity);
}
}
}
}

0 comments on commit d9de3ea

Please sign in to comment.