refactor(exam-correct): move responseStatus to utils
This commit is contained in:
parent
36d45fcc0e
commit
4515987446
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user