fix(exam-correct): cut off at maxPoints for now (TODO)
This commit is contained in:
parent
b8e48d08d9
commit
af8d77c4a4
@ -151,7 +151,7 @@ postECorrectR tid ssh csh examn = do
|
||||
now <- liftIO getCurrentTime
|
||||
newExamPartResults <- if
|
||||
| Just results <- ciqResults -> iforM (toNullable results) $ \partNumber mPartResult -> do
|
||||
examPartId <- getKeyBy404 $ UniqueExamPartNumber eId partNumber
|
||||
(Entity examPartId ExamPart{..}) <- getBy404 $ UniqueExamPartNumber eId partNumber
|
||||
mOldResult <- getBy $ UniqueExamPartResult examPartId uid
|
||||
if
|
||||
| Just (Entity oldId _) <- mOldResult, is _Nothing mPartResult -> do
|
||||
@ -163,18 +163,24 @@ postECorrectR tid ssh csh examn = do
|
||||
mNew = ExamAttended <$> mPartResult
|
||||
resultVal = _entityVal . _examPartResultResult
|
||||
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
|
||||
| mOld /= mNew -> let
|
||||
-- cut off part results that exceed the maximum number of points for this exam part for now
|
||||
-- TODO answer with new failure response type instead
|
||||
partResult' = if
|
||||
| Just maxPts <- examPartMaxPoints, maxPts < partResult -> maxPts
|
||||
| otherwise -> partResult
|
||||
in 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
|
||||
| otherwise -> return mempty
|
||||
|
||||
Loading…
Reference in New Issue
Block a user