fix(exam-correct): fix returning null if old and new results are equal
This commit is contained in:
parent
e252be2fef
commit
2e7bca6333
@ -147,20 +147,25 @@ 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
|
||||||
newExamPartResult <- upsert ExamPartResult
|
mNew = ExamAttended <$> mPartResult
|
||||||
{ examPartResultExamPart = examPartId
|
resultVal = _entityVal . _examPartResultResult . _ExamAttended
|
||||||
, examPartResultUser = uid
|
in if
|
||||||
, examPartResultResult = ExamAttended partResult
|
| mOld /= mNew -> do
|
||||||
, examPartResultLastChanged = now
|
newExamPartResult <- upsert ExamPartResult
|
||||||
}
|
{ examPartResultExamPart = examPartId
|
||||||
[ ExamPartResultResult =. ExamAttended partResult
|
, examPartResultUser = uid
|
||||||
, ExamPartResultLastChanged =. now
|
, examPartResultResult = ExamAttended partResult
|
||||||
]
|
, examPartResultLastChanged = now
|
||||||
audit $ TransactionExamPartResultEdit examPartId uid
|
}
|
||||||
return $ newExamPartResult ^? _entityVal . _examPartResultResult . _ExamAttended
|
[ ExamPartResultResult =. ExamAttended partResult
|
||||||
| otherwise -> return Nothing
|
, ExamPartResultLastChanged =. now
|
||||||
|
]
|
||||||
|
audit $ TransactionExamPartResultEdit examPartId uid
|
||||||
|
return $ newExamPartResult ^? resultVal
|
||||||
|
| otherwise -> return $ mOldResult ^? _Just . resultVal
|
||||||
|
| otherwise -> return Nothing
|
||||||
user <- userToResponse match
|
user <- userToResponse match
|
||||||
return CorrectInterfaceResponseSuccess
|
return CorrectInterfaceResponseSuccess
|
||||||
{ cirsUser = user
|
{ cirsUser = user
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user