From 9b0adab023833b6828fb0b4edbd6d0bae72cb60b Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Tue, 2 Mar 2021 15:01:21 +0100 Subject: [PATCH] chore: extende random distribution with nudges --- src/Handler/Utils/Exam.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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