diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index 5b441f8ff..28c3b2403 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -274,11 +274,11 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences = case rule of ExamRoomRandom -> ( Nothing - , Map.union (Map.map snd assignedUsers) randomlyAssignedUsers + , Map.union (view _2 <$> assignedUsers) randomlyAssignedUsers ) where assignedUsers,unassignedUsers :: Map UserId (User, Maybe ExamOccurrenceId) - (assignedUsers, unassignedUsers) = Map.partition (isJust . snd) users + (assignedUsers, unassignedUsers) = Map.partition (has $ _2 . _Just) users shuffledUsers :: [UserId] shuffledUsers = shuffle' (Map.keys unassignedUsers) (length unassignedUsers) (mkStdGen seed) occurrencesMap :: Map ExamOccurrenceId Natural @@ -292,9 +292,9 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences currentRatios :: Map ExamOccurrenceId (Ratio Natural) currentRatios = Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched $ const (%)) currentOccurrences occurrencesMap biggestOutlier :: ExamOccurrenceId - biggestOutlier = fst $ List.maximumBy (\a b -> compare (snd a) (snd b)) $ Map.toList currentRatios + biggestOutlier = fst . List.maximumBy (comparing $ view _2) $ Map.toList currentRatios extraCapacity :: Natural - extraCapacity = sum (map snd occurrences'') - fromIntegral (length unassignedUsers) + extraCapacity = sumOf (folded . _2) occurrences'' - fromIntegral (length unassignedUsers) finalOccurrences :: [(ExamOccurrenceId, Natural)] finalOccurrences = Map.toList $ decreaseBiggestOutlier extraCapacity occurrencesMap -- fill in users in a random order @@ -454,7 +454,7 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences prevMin <- ST.readArray minima i let cost = prevMin + widthCost l potWidth w + breakCost' remainingWords = offsets Array.! Map.size wordMap - offsets Array.! i - remainingLineSpace = sum (map snd $ drop lineIx lineLengths) + remainingLineSpace = sumOf (folded . _2) $ drop lineIx lineLengths breakCost' | remainingWords > remainingLineSpace = PosInf