refactor: don't store order of unrestrictedOccurrences

This commit is contained in:
Wolfgang Witt 2021-03-16 13:37:15 +01:00 committed by Gregor Kleen
parent 2be9d76af2
commit ff5d27cdf3

View File

@ -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)