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
|
||||
audit $ TransactionExamPartResultDeleted examPartId uid
|
||||
return Nothing
|
||||
| Just partResult <- mPartResult
|
||||
, fmap (examPartResultResult . entityVal) mOldResult /= fmap ExamAttended mPartResult -> do
|
||||
newExamPartResult <- upsert ExamPartResult
|
||||
{ examPartResultExamPart = examPartId
|
||||
, examPartResultUser = uid
|
||||
, examPartResultResult = ExamAttended partResult
|
||||
, examPartResultLastChanged = now
|
||||
}
|
||||
[ ExamPartResultResult =. ExamAttended partResult
|
||||
, ExamPartResultLastChanged =. now
|
||||
]
|
||||
audit $ TransactionExamPartResultEdit examPartId uid
|
||||
return $ newExamPartResult ^? _entityVal . _examPartResultResult . _ExamAttended
|
||||
| otherwise -> return Nothing
|
||||
| Just partResult <- mPartResult -> let
|
||||
mOld = (examPartResultResult . entityVal) <$> mOldResult
|
||||
mNew = ExamAttended <$> mPartResult
|
||||
resultVal = _entityVal . _examPartResultResult . _ExamAttended
|
||||
in if
|
||||
| mOld /= mNew -> do
|
||||
newExamPartResult <- upsert ExamPartResult
|
||||
{ examPartResultExamPart = examPartId
|
||||
, examPartResultUser = uid
|
||||
, examPartResultResult = ExamAttended partResult
|
||||
, examPartResultLastChanged = now
|
||||
}
|
||||
[ ExamPartResultResult =. ExamAttended partResult
|
||||
, ExamPartResultLastChanged =. now
|
||||
]
|
||||
audit $ TransactionExamPartResultEdit examPartId uid
|
||||
return $ newExamPartResult ^? resultVal
|
||||
| otherwise -> return $ mOldResult ^? _Just . resultVal
|
||||
| otherwise -> return Nothing
|
||||
user <- userToResponse match
|
||||
return CorrectInterfaceResponseSuccess
|
||||
{ cirsUser = user
|
||||
|
||||
Loading…
Reference in New Issue
Block a user