diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 02a12ef45..95f49812d 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -1138,17 +1138,22 @@ assignHandler tid ssh csh cid assignSids = do E.on $ corrector E.^. SheetCorrectorUser E.==. user E.^. UserId E.where_ $ corrector E.^. SheetCorrectorSheet `E.in_` E.valList sheetIds return (corrector, user) - let correctorMap :: Map UserId (User, Map SheetName SheetCorrector) - correctorMap = (\f -> foldl f Map.empty correctors) (\acc (Entity _ sheetcorr@SheetCorrector{sheetCorrectorSheet}, Entity uid user) -> - let shn = sheetName $ sheets ! sheetCorrectorSheet - in Map.insertWith (\(usr, ma) (_, mb) -> (usr, Map.union ma mb)) uid (user, Map.singleton shn sheetcorr) acc - ) + let regular_correctors = nub $ fmap (\(_,Entity uid _) -> uid) correctors + act_correctors <- E.select . E.distinct . E.from $ \(submission `E.InnerJoin` user) -> do + E.on $ submission E.^. SubmissionRatingBy E.==. (E.just $ user E.^. UserId) + E.where_ $ submission E.^. SubmissionSheet `E.in_` E.valList sheetIds + E.where_ $ user E.^. UserId `E.notIn` E.valList regular_correctors + return (submission E.^. SubmissionSheet, user) - -- -- lecturerNames :: Map UserId User - -- lecturerNames <- fmap entities2map $ E.select $ E.from $ \(user `E.InnerJoin` lecturer) -> do - -- E.on $ user E.^. UserId E.==. lecturer E.^. LecturerUser - -- E.where_ $ lecturer E.^. LecturerCourse E.==. E.val cid - -- return user + let fakeSheetCorrector :: (E.Value SheetId, Entity User) -> (Entity SheetCorrector, Entity User) + fakeSheetCorrector (E.Value shid, usr@(Entity uid _)) = (Entity (error "Fake SheetId") (SheetCorrector uid shid mempty CorrectorExcused), usr) + + let correctorMap :: Map UserId (User, Map SheetName SheetCorrector) + correctorMap = (\f -> foldl f Map.empty (correctors ++ (fakeSheetCorrector <$> act_correctors)) ) + (\acc (Entity _ sheetcorr@SheetCorrector{sheetCorrectorSheet}, Entity uid user) -> + let shn = sheetName $ sheets ! sheetCorrectorSheet + in Map.insertWith (\(usr, ma) (_, mb) -> (usr, Map.union ma mb)) uid (user, Map.singleton shn sheetcorr) acc + ) submissions <- E.select . E.from $ \submission -> do E.where_ $ submission E.^. SubmissionSheet `E.in_` E.valList sheetIds diff --git a/templates/corrections-overview.hamlet b/templates/corrections-overview.hamlet index 152ba73e5..64a647387 100644 --- a/templates/corrections-overview.hamlet +++ b/templates/corrections-overview.hamlet @@ -130,6 +130,16 @@
_{MsgAssignSubmissionsRandomWarning} \ No newline at end of file