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)
|
||||
return user
|
||||
|
||||
let
|
||||
userToResponse (Entity uid User{..}) = do
|
||||
uuid <- encrypt uid
|
||||
return CorrectInterfaceUser
|
||||
{ ciuSurname = userSurname
|
||||
, ciuDisplayName = userDisplayName
|
||||
, ciuMatNr = userMatrikelnummer
|
||||
, ciuId = uuid
|
||||
}
|
||||
|
||||
if
|
||||
-- on no-op request, answer with 200 and a set of all participant matches
|
||||
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
||||
|
||||
@ -81,16 +81,6 @@ postEECorrectR tid ssh coursen examn = do
|
||||
Nothing -> E.false)
|
||||
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
|
||||
| is _Nothing ciqResults, is _Nothing ciqGrade -> do
|
||||
users <- traverse userToResponse matches
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
module Utils.Exam
|
||||
( CorrectInterfaceRequest(..)
|
||||
, CorrectInterfaceResponse(..)
|
||||
, CorrectInterfaceUser(..)
|
||||
, CorrectInterfaceUser(..), userToResponse
|
||||
) where
|
||||
|
||||
import Import.NoFoundation
|
||||
@ -22,6 +22,16 @@ deriveJSON defaultOptions
|
||||
{ fieldLabelModifier = camelToPathPiece' 1
|
||||
} ''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
|
||||
= CorrectInterfaceResponseSuccess
|
||||
|
||||
Loading…
Reference in New Issue
Block a user