diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index ce751ecaf..10e4f9b00 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -51,7 +51,6 @@ import qualified Data.List as List import Data.Either.Combinators (maybeToRight) import Data.ExtendedReal -import Data.Ratio (Ratio) import qualified Data.RFC5051 as RFC5051 @@ -306,8 +305,11 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences decreaseBiggestOutlier n currentOccurrences = decreaseBiggestOutlier (pred n) $ Map.update predToPositive biggestOutlier currentOccurrences where - currentRatios :: Map ExamOccurrenceId (Ratio Natural) - currentRatios = Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched $ const (%)) currentOccurrences occurrencesMap + currentRatios :: Map ExamOccurrenceId Rational + currentRatios = Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched calculateRatio) + currentOccurrences occurrencesMap + calculateRatio :: ExamOccurrenceId -> Natural -> Natural -> Rational + calculateRatio k c m = fromIntegral c % fromIntegral m - eaocNudgeSize * fromIntegral (lineNudges k) biggestOutlier :: ExamOccurrenceId biggestOutlier = fst . List.maximumBy (comparing $ view _2) $ Map.toList currentRatios extraCapacity :: Natural