From 43038ff3840c26a10dcf4a3021a195472f74433c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?=
 <janis.daehne2@student.uni-halle.de>
Date: Thu, 14 Nov 2019 19:53:47 +0100
Subject: [PATCH] - fixed issue where a null assessment would respond with an
 error even if this can happen and is valid in certain circumstances   - e.g.
 auto assessment has not finished yet

---
 src/ClientServer/Config/Constants.cs          |  2 +-
 .../DoExerciseAfterSolutionController.cs      | 22 ++++++++++++++++---
 .../Core/Exercises/DoExerciseController.cs    | 14 +++++++++---
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/src/ClientServer/Config/Constants.cs b/src/ClientServer/Config/Constants.cs
index 71fa0dc..79be811 100644
--- a/src/ClientServer/Config/Constants.cs
+++ b/src/ClientServer/Config/Constants.cs
@@ -13,7 +13,7 @@ namespace ClientServer.Helpers
     /// </summary>
     public static class Constants
     {
-        public static string VersionString = "2.5.6";
+        public static string VersionString = "2.5.8";
 
         /// <summary>
         /// this is only set once at program.cs!!
diff --git a/src/ClientServer/Controllers/Core/Exercises/DoExerciseAfterSolution/DoExerciseAfterSolutionController.cs b/src/ClientServer/Controllers/Core/Exercises/DoExerciseAfterSolution/DoExerciseAfterSolutionController.cs
index fe94152..5df260b 100644
--- a/src/ClientServer/Controllers/Core/Exercises/DoExerciseAfterSolution/DoExerciseAfterSolutionController.cs
+++ b/src/ClientServer/Controllers/Core/Exercises/DoExerciseAfterSolution/DoExerciseAfterSolutionController.cs
@@ -864,14 +864,30 @@ namespace ClientServer.Controllers.Core.Exercises.DoExerciseAfterSolution
                 return;
             }
 
-            if (solution?.Assessment == null)
+            if (afterSolution == null)
+            {
+                await
+                    Response.WriteAsync(
+                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "after solution not found")));
+                return;
+            }
+            
+            if (solution == null)
             {
-                //this can happen if the solution assessment has started but has not yet finished...
                 await
                     Response.WriteAsync(
-                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution or assessment not found")));
+                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution not found")));
                 return;
             }
+            
+            if (solution.Assessment == null)
+            {
+                //this can happen if the solution assessment has started but has not yet finished...
+//                await
+//                    Response.WriteAsync(
+//                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution or assessment not found")));
+//                return;
+            }
 
             var submitTests = _context.Tests
                     .Where(p => p.IsSubmitTest == true &&
diff --git a/src/ClientServer/Controllers/Core/Exercises/DoExerciseController.cs b/src/ClientServer/Controllers/Core/Exercises/DoExerciseController.cs
index 451e091..c4ec07b 100644
--- a/src/ClientServer/Controllers/Core/Exercises/DoExerciseController.cs
+++ b/src/ClientServer/Controllers/Core/Exercises/DoExerciseController.cs
@@ -1169,14 +1169,22 @@ namespace ClientServer.Controllers.Core.Exercises
                 return;
             }
 
-            if (solution?.Assessment == null)
+            if (solution == null)
             {
-                //this can happen if the solution assessment has started but has not yet finished...
                 await
                     Response.WriteAsync(
-                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution or assessment not found")));
+                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution not found")));
                 return;
             }
+            
+            if (solution?.Assessment == null)
+            {
+                //this can happen if the solution assessment has started but has not yet finished...
+//                await
+//                    Response.WriteAsync(
+//                        Jc.Serialize(new BasicResponse(ResponseCode.NotFound, "solution or assessment not found")));
+//                return;
+            }
 
             //check if assessment already run
             //var submitTestResults = _context.TestResults
-- 
GitLab