diff --git a/src/Handler/Exam/Correct.hs b/src/Handler/Exam/Correct.hs index d03af8000..772fcef85 100644 --- a/src/Handler/Exam/Correct.hs +++ b/src/Handler/Exam/Correct.hs @@ -186,13 +186,7 @@ postECorrectR tid ssh csh examn = do , ciraUsers = Set.fromList users } - let - responseStatus = case response of - CorrectInterfaceResponseSuccess{} -> ok200 - CorrectInterfaceResponseNoOp{} -> ok200 - _ -> badRequest400 - whenM acceptsJson $ - sendResponseStatus responseStatus $ toJSON response + sendResponseStatus (ciResponseStatus response) $ toJSON response redirect $ CExamR tid ssh csh examn EShowR diff --git a/src/Handler/ExternalExam/Correct.hs b/src/Handler/ExternalExam/Correct.hs index 319b78318..f7e3d9270 100644 --- a/src/Handler/ExternalExam/Correct.hs +++ b/src/Handler/ExternalExam/Correct.hs @@ -139,13 +139,7 @@ postEECorrectR tid ssh coursen examn = do , ciraMessage = mr MsgExamCorrectErrorMultipleMatchingParticipants -- TODO use new msg } - let - responseStatus = case response of - CorrectInterfaceResponseSuccess{} -> ok200 - CorrectInterfaceResponseNoOp{} -> ok200 - _ -> badRequest400 - whenM acceptsJson $ - sendResponseStatus responseStatus $ toJSON response + sendResponseStatus (ciResponseStatus response) $ toJSON response redirect $ EExamR tid ssh coursen examn EEShowR diff --git a/src/Utils/Exam.hs b/src/Utils/Exam.hs index 40dd0f18d..c7847d6f5 100644 --- a/src/Utils/Exam.hs +++ b/src/Utils/Exam.hs @@ -1,6 +1,6 @@ module Utils.Exam ( CorrectInterfaceRequest(..) - , CorrectInterfaceResponse(..) + , CorrectInterfaceResponse(..), ciResponseStatus , CorrectInterfaceUser(..), userToResponse ) where @@ -59,6 +59,11 @@ deriveToJSON defaultOptions , omitNothingFields = True } ''CorrectInterfaceResponse +ciResponseStatus :: CorrectInterfaceResponse -> Status +ciResponseStatus CorrectInterfaceResponseSuccess{} = ok200 +ciResponseStatus CorrectInterfaceResponseNoOp{} = ok200 +ciResponseStatus _ = badRequest400 + data CorrectInterfaceRequest = CorrectInterfaceRequest