diff --git a/src/Handler/Exam/AutoOccurrence.hs b/src/Handler/Exam/AutoOccurrence.hs index a1e10a38e..df036163b 100644 --- a/src/Handler/Exam/AutoOccurrence.hs +++ b/src/Handler/Exam/AutoOccurrence.hs @@ -171,16 +171,16 @@ examAutoOccurrenceCalculateWidget tid ssh csh examn = do postEAutoOccurrenceR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html postEAutoOccurrenceR tid ssh csh examn = do - (Entity eId Exam{ examOccurrenceRule }, occurrences) <- runDB $ do + (Entity eId Exam{ examOccurrenceRule }, occurrences, participants) <- runDB $ do exam@(Entity eId _) <- fetchExam tid ssh csh examn occurrences <- selectList [ ExamOccurrenceExam ==. eId ] [ Asc ExamOccurrenceName ] - return (exam, occurrences) - - - participants <- runDB $ E.select . E.from $ \(registration `E.InnerJoin` user) -> do + participants <- E.select . E.from $ \(registration `E.InnerJoin` user) -> do E.on $ registration E.^. ExamRegistrationUser E.==. user E.^. UserId E.where_ $ registration E.^. ExamRegistrationExam E.==. E.val eId return (user, registration) + return (exam, occurrences, participants) + + let participants' = Map.fromList $ do (Entity uid userRec, Entity _ ExamRegistration{..}) <- participants return (uid, (userRec, examRegistrationOccurrence))