Don't attempt to dequeue corrector who isn't (also) proportional
This commit is contained in:
parent
6d7522410a
commit
99d112b31c
@ -50,7 +50,7 @@ instance Exception AssignSubmissionException
|
||||
assignSubmissions :: SheetId -> YesodDB UniWorX ()
|
||||
assignSubmissions sid = do
|
||||
correctors <- selectList [SheetCorrectorSheet ==. sid] []
|
||||
let (corrsGroup, corrsProp) = partition (is _ByTutorial . sheetCorrectorLoad . entityVal) correctors
|
||||
let (corrsGroup, (filterNonPositive -> corrsProp)) = partition (is _ByTutorial . sheetCorrectorLoad . entityVal) correctors
|
||||
countsToLoad' :: UserId -> Bool
|
||||
countsToLoad' uid = fromMaybe (error "Called `countsToLoad'` on entity not element of `corrsGroup`") $ listToMaybe [sheetCorrectorLoad | Entity _ SheetCorrector{..} <- corrsGroup, sheetCorrectorUser == uid] >>= preview _ByTutorial
|
||||
subs <- E.select . E.from $ \(submission `E.LeftOuterJoin` user) -> do
|
||||
@ -74,7 +74,7 @@ assignSubmissions sid = do
|
||||
subTutor <- fmap fst . flip execStateT (Map.empty, queue) . forM_ (Map.toList subTutor') $ \case
|
||||
(smid, Just tutid) -> do
|
||||
_1 %= Map.insert smid tutid
|
||||
when (countsToLoad' tutid) $
|
||||
when (any ((== tutid) . sheetCorrectorUser . entityVal) corrsProp && countsToLoad' tutid) $
|
||||
_2 %= delFirst (Just tutid)
|
||||
(smid, Nothing) -> do
|
||||
(q:qs) <- use _2
|
||||
@ -87,6 +87,8 @@ assignSubmissions sid = do
|
||||
|
||||
return ()
|
||||
where
|
||||
filterNonPositive = filter $ (> 0) . load . sheetCorrectorLoad . entityVal
|
||||
|
||||
delFirst _ [] = []
|
||||
delFirst x (y:ys)
|
||||
| x == y = ys
|
||||
|
||||
Loading…
Reference in New Issue
Block a user