fix(authorship-statements): resolve exam-part to exam properly

This commit is contained in:
Gregor Kleen 2021-07-21 14:46:54 +02:00
parent 0b5b2ae025
commit 3a2d031bb5

View File

@ -75,10 +75,12 @@ getSheetAuthorshipStatement (Entity _ Sheet{..}) = withCompatibleBackend @SqlBac
E.where_ $ course E.^. CourseId E.==. E.val sheetCourse
return school
let examId = sheetAuthorshipStatementExam
<|> sheetType ^? _examPart . re _SqlKey
<|> sheetRequireExamRegistration
exam <- lift $ traverse getJust examId
let examId = fmap Right sheetAuthorshipStatementExam
<|> fmap Left (sheetType ^? _examPart . re _SqlKey)
<|> fmap Right sheetRequireExamRegistration
exam <- lift . for examId $ \case
Right e -> getJust e
Left epId -> getJust epId >>= getJust . examPartExam
let
examAuthorshipStatement' = exam >>= examAuthorshipStatement