fix(course-deregistration): fix check on exam registration
Never delete exam-results
This commit is contained in:
parent
7765b058fa
commit
0b8c30f534
@ -709,7 +709,16 @@ tagAccessPredicate AuthTime = APDB $ \mAuthId route _ -> case route of
|
||||
E.where_ $ exam E.^. ExamCourse E.==. E.val cid
|
||||
return $ exam E.^. ExamDeregisterUntil
|
||||
forM_ exams $ \(E.Value deregUntil) ->
|
||||
guard $ NTop (Just now) >= NTop deregUntil
|
||||
guard $ NTop (Just now) <= NTop deregUntil
|
||||
|
||||
tutorials <- lift . E.select . E.from $ \tutorial -> do
|
||||
E.where_ . E.exists . E.from $ \tutorialParticipant ->
|
||||
E.where_ $ tutorialParticipant E.^. TutorialParticipantTutorial E.==. tutorial E.^. TutorialId
|
||||
E.&&. tutorialParticipant E.^. TutorialParticipantUser E.==. E.val uid
|
||||
E.where_ $ tutorial E.^. TutorialCourse E.==. E.val cid
|
||||
return $ (tutorial E.^. TutorialRegisterFrom, tutorial E.^. TutorialDeregisterUntil)
|
||||
forM_ tutorials $ \(E.Value deregUntil) ->
|
||||
guard $ NTop (Just now) <= NTop deregUntil
|
||||
return Authorized
|
||||
_other -> unauthorizedI MsgUnauthorizedCourseTime
|
||||
|
||||
|
||||
@ -258,16 +258,7 @@ deregisterParticipant uid cid = do
|
||||
forM_ examRegistrations $ \(Entity erId ExamRegistration{..}) -> do
|
||||
delete erId
|
||||
audit $ TransactionExamDeregister examRegistrationExam uid
|
||||
|
||||
examResults <- E.select . E.from $ \(examResult `E.InnerJoin` exam) -> do
|
||||
E.on $ examResult E.^. ExamResultExam E.==. exam E.^. ExamId
|
||||
E.where_ $ exam E.^. ExamCourse E.==. E.val cid
|
||||
E.&&. examResult E.^. ExamResultUser E.==. E.val uid
|
||||
return examResult
|
||||
forM_ examResults $ \(Entity erId ExamResult{..}) -> do
|
||||
delete erId
|
||||
audit $ TransactionExamResultDeleted examResultExam uid
|
||||
|
||||
|
||||
E.delete . E.from $ \tutorialParticipant -> do
|
||||
let tutorialCourse = E.subSelectForeign tutorialParticipant TutorialParticipantTutorial (E.^. TutorialCourse)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user