diff --git a/src/Handler/Exam/Correct.hs b/src/Handler/Exam/Correct.hs index c74970da7..d03af8000 100644 --- a/src/Handler/Exam/Correct.hs +++ b/src/Handler/Exam/Correct.hs @@ -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 diff --git a/src/Handler/ExternalExam/Correct.hs b/src/Handler/ExternalExam/Correct.hs index a4472ea91..319b78318 100644 --- a/src/Handler/ExternalExam/Correct.hs +++ b/src/Handler/ExternalExam/Correct.hs @@ -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 diff --git a/src/Utils/Exam.hs b/src/Utils/Exam.hs index bca2727ca..40dd0f18d 100644 --- a/src/Utils/Exam.hs +++ b/src/Utils/Exam.hs @@ -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