refactor(exam-correct): move userToResponse to utils
This commit is contained in:
parent
33691556ab
commit
36d45fcc0e
@ -83,16 +83,6 @@ postECorrectR tid ssh csh examn = do
|
|||||||
Nothing -> E.val False)
|
Nothing -> E.val False)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
let
|
|
||||||
userToResponse (Entity uid User{..}) = do
|
|
||||||
uuid <- encrypt uid
|
|
||||||
return CorrectInterfaceUser
|
|
||||||
{ ciuSurname = userSurname
|
|
||||||
, ciuDisplayName = userDisplayName
|
|
||||||
, ciuMatNr = userMatrikelnummer
|
|
||||||
, ciuId = uuid
|
|
||||||
}
|
|
||||||
|
|
||||||
if
|
if
|
||||||
-- on no-op request, answer with 200 and a set of all participant matches
|
-- on no-op request, answer with 200 and a set of all participant matches
|
||||||
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
||||||
|
|||||||
@ -81,16 +81,6 @@ postEECorrectR tid ssh coursen examn = do
|
|||||||
Nothing -> E.false)
|
Nothing -> E.false)
|
||||||
return user
|
return user
|
||||||
|
|
||||||
let
|
|
||||||
userToResponse (Entity uid User{..}) = do -- TODO move to util
|
|
||||||
uuid <- encrypt uid
|
|
||||||
return CorrectInterfaceUser
|
|
||||||
{ ciuSurname = userSurname
|
|
||||||
, ciuDisplayName = userDisplayName
|
|
||||||
, ciuMatNr = userMatrikelnummer
|
|
||||||
, ciuId = uuid
|
|
||||||
}
|
|
||||||
|
|
||||||
if
|
if
|
||||||
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
||||||
users <- traverse userToResponse matches
|
users <- traverse userToResponse matches
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
module Utils.Exam
|
module Utils.Exam
|
||||||
( CorrectInterfaceRequest(..)
|
( CorrectInterfaceRequest(..)
|
||||||
, CorrectInterfaceResponse(..)
|
, CorrectInterfaceResponse(..)
|
||||||
, CorrectInterfaceUser(..)
|
, CorrectInterfaceUser(..), userToResponse
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Import.NoFoundation
|
import Import.NoFoundation
|
||||||
@ -22,6 +22,16 @@ deriveJSON defaultOptions
|
|||||||
{ fieldLabelModifier = camelToPathPiece' 1
|
{ fieldLabelModifier = camelToPathPiece' 1
|
||||||
} ''CorrectInterfaceUser
|
} ''CorrectInterfaceUser
|
||||||
|
|
||||||
|
userToResponse :: (MonadHandler m, MonadCrypto m, MonadCryptoKey m ~ CryptoIDKey) => Entity User -> m CorrectInterfaceUser
|
||||||
|
userToResponse (Entity uid User{..}) = do
|
||||||
|
uuid <- encrypt uid
|
||||||
|
return CorrectInterfaceUser
|
||||||
|
{ ciuSurname = userSurname
|
||||||
|
, ciuDisplayName = userDisplayName
|
||||||
|
, ciuMatNr = userMatrikelnummer
|
||||||
|
, ciuId = uuid
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
data CorrectInterfaceResponse
|
data CorrectInterfaceResponse
|
||||||
= CorrectInterfaceResponseSuccess
|
= CorrectInterfaceResponseSuccess
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user