From ff5d27cdf37729f0147dbc6ff35fee947497e402 Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Tue, 16 Mar 2021 13:37:15 +0100 Subject: [PATCH] refactor: don't store order of unrestrictedOccurrences --- src/Handler/Utils/Exam.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index c1f784c6d..044acc092 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -278,9 +278,9 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences shuffledUsers :: [UserId] shuffledUsers = shuffle' (Map.keys unassignedUsers) (length unassignedUsers) (mkStdGen seed) restrictedOccurrences :: Map ExamOccurrenceId Natural - unrestrictedOccurrences :: [ExamOccurrenceId] + unrestrictedOccurrences :: Set ExamOccurrenceId (unrestrictedOccurrences, restrictedOccurrences) - = second Map.fromList $ partitionRestricted ([], []) occurrences'' + = bimap Set.fromList Map.fromList $ partitionRestricted ([], []) occurrences'' -- reduce available space until to excess space is left while keeping the filling ratio as equal as possible decreaseBiggestOutlier :: Natural -> Map ExamOccurrenceId Natural -> Map ExamOccurrenceId Natural decreaseBiggestOutlier 0 currentOccurrences = currentOccurrences @@ -311,7 +311,7 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences finalOccurrences = Map.toList $ decreaseBiggestOutlier extraCapacity restrictedOccurrences -- fill in users in a random order randomlyAssignedUsers :: Map UserId (Maybe ExamOccurrenceId) - randomlyAssignedUsers = Map.fromList $ fillUnrestricted (List.cycle unrestrictedOccurrences) + randomlyAssignedUsers = Map.fromList $ fillUnrestricted (List.cycle $ Set.toList unrestrictedOccurrences) $ foldl' addUsers ([], shuffledUsers) finalOccurrences addUsers :: ([(UserId, Maybe ExamOccurrenceId)], [UserId]) -> (ExamOccurrenceId, Natural)