refactor(exam-correct): move userToResponse to utils

This commit is contained in:
Sarah Vaupel 2020-08-12 13:35:06 +02:00
parent 33691556ab
commit 36d45fcc0e
3 changed files with 11 additions and 21 deletions

View File

@ -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

View File

@ -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

View File

@ -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