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
|
proportionSum = getSum . foldMap corrProportion . fromMaybe Map.empty $ correctors !? sheetId
|
||||||
where corrProportion (_, CorrectorExcused) = mempty
|
where corrProportion (_, CorrectorExcused) = mempty
|
||||||
corrProportion (Load{..}, _) = Sum byProportion
|
corrProportion (Load{..}, _) = Sum byProportion
|
||||||
|
relativeProportion :: Rational -> Rational
|
||||||
|
relativeProportion prop
|
||||||
|
| proportionSum == 0 = 0
|
||||||
|
| otherwise = prop / proportionSum
|
||||||
extra
|
extra
|
||||||
| Just (Load{..}, corrState) <- correctors !? sheetId >>= Map.lookup corrector
|
| Just (Load{..}, corrState) <- correctors !? sheetId >>= Map.lookup corrector
|
||||||
= sum
|
= 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
|
return . negate . fromIntegral . Map.size $ Map.filter (\(mCorr, tutors, sheetId') -> mCorr == Just corrector && sheetId == sheetId' && Map.member corrector tutors) submissionState
|
||||||
, fromMaybe 0 $ do
|
, fromMaybe 0 $ do
|
||||||
guard $ corrState /= CorrectorExcused
|
guard $ corrState /= CorrectorExcused
|
||||||
return . negate $ (byProportion / proportionSum) * fromIntegral sheetSize
|
return . negate $ relativeProportion byProportion * fromIntegral sheetSize
|
||||||
]
|
]
|
||||||
| otherwise
|
| otherwise
|
||||||
= assigned
|
= assigned
|
||||||
|
|||||||
Reference in New Issue
Block a user