diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index cfb4124c2..097ff62f1 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -311,14 +311,13 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences occurrences' :: Map ExamOccurrenceId Natural -- ^ reduce room capacity for every pre-assigned user by 1 - occurrences' = foldl' (flip $ Map.update predToPositive) occurrences $ Map.mapMaybe snd users - -- FIXME what about capacity-0 in occurrences? - -- what if the first word is too big for the first room? - where - predToPositive :: Natural -> Maybe Natural - predToPositive 0 = Nothing - predToPositive 1 = Nothing - predToPositive n = Just $ pred n + -- also remove empty/pre-filled rooms + occurrences' = foldl' (flip $ Map.update predToPositive) (Map.filter (> 0) occurrences) $ Map.mapMaybe snd users + + predToPositive :: Natural -> Maybe Natural + predToPositive 0 = Nothing + predToPositive 1 = Nothing + predToPositive n = Just $ pred n occurrences'' :: [(ExamOccurrenceId, Natural)] -- ^ Minimise number of occurrences used