fix(assign-submissions): avoid division by zero
This commit is contained in:
parent
e4788d8f11
commit
640326ca5d
@ -197,6 +197,10 @@ planSubmissions sid restriction = do
|
||||
proportionSum = getSum . foldMap corrProportion . fromMaybe Map.empty $ correctors !? sheetId
|
||||
where corrProportion (_, CorrectorExcused) = mempty
|
||||
corrProportion (Load{..}, _) = Sum byProportion
|
||||
relativeProportion :: Rational -> Rational
|
||||
relativeProportion prop
|
||||
| proportionSum == 0 = 0
|
||||
| otherwise = prop / proportionSum
|
||||
extra
|
||||
| Just (Load{..}, corrState) <- correctors !? sheetId >>= Map.lookup corrector
|
||||
= sum
|
||||
@ -208,7 +212,7 @@ planSubmissions sid restriction = do
|
||||
return . negate . fromIntegral . Map.size $ Map.filter (\(mCorr, tutors, sheetId') -> mCorr == Just corrector && sheetId == sheetId' && Map.member corrector tutors) submissionState
|
||||
, fromMaybe 0 $ do
|
||||
guard $ corrState /= CorrectorExcused
|
||||
return . negate $ (byProportion / proportionSum) * fromIntegral sheetSize
|
||||
return . negate $ relativeProportion byProportion * fromIntegral sheetSize
|
||||
]
|
||||
| otherwise
|
||||
= assigned
|
||||
|
||||
Loading…
Reference in New Issue
Block a user