fix(exam-correct): fix returning null if old and new results are equal
This commit is contained in:
parent
e252be2fef
commit
2e7bca6333
@ -147,8 +147,12 @@ postECorrectR tid ssh csh examn = do
|
|||||||
delete oldId
|
delete oldId
|
||||||
audit $ TransactionExamPartResultDeleted examPartId uid
|
audit $ TransactionExamPartResultDeleted examPartId uid
|
||||||
return Nothing
|
return Nothing
|
||||||
| Just partResult <- mPartResult
|
| Just partResult <- mPartResult -> let
|
||||||
, fmap (examPartResultResult . entityVal) mOldResult /= fmap ExamAttended mPartResult -> do
|
mOld = (examPartResultResult . entityVal) <$> mOldResult
|
||||||
|
mNew = ExamAttended <$> mPartResult
|
||||||
|
resultVal = _entityVal . _examPartResultResult . _ExamAttended
|
||||||
|
in if
|
||||||
|
| mOld /= mNew -> do
|
||||||
newExamPartResult <- upsert ExamPartResult
|
newExamPartResult <- upsert ExamPartResult
|
||||||
{ examPartResultExamPart = examPartId
|
{ examPartResultExamPart = examPartId
|
||||||
, examPartResultUser = uid
|
, examPartResultUser = uid
|
||||||
@ -159,7 +163,8 @@ postECorrectR tid ssh csh examn = do
|
|||||||
, ExamPartResultLastChanged =. now
|
, ExamPartResultLastChanged =. now
|
||||||
]
|
]
|
||||||
audit $ TransactionExamPartResultEdit examPartId uid
|
audit $ TransactionExamPartResultEdit examPartId uid
|
||||||
return $ newExamPartResult ^? _entityVal . _examPartResultResult . _ExamAttended
|
return $ newExamPartResult ^? resultVal
|
||||||
|
| otherwise -> return $ mOldResult ^? _Just . resultVal
|
||||||
| otherwise -> return Nothing
|
| otherwise -> return Nothing
|
||||||
user <- userToResponse match
|
user <- userToResponse match
|
||||||
return CorrectInterfaceResponseSuccess
|
return CorrectInterfaceResponseSuccess
|
||||||
|
|||||||
Reference in New Issue
Block a user