diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index ef6050f7e..dfc895c92 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -535,7 +535,7 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences postprocess result = seq resultAscList (resultAscList, resultUsers) where maxTagLength :: Int - maxTagLength = maximum $ map (length . snd) result + maxTagLength = maybe 0 maximum $ fromNullable $ map (length . snd) result rangeAlphabet :: [CI Char] rangeAlphabet = case rule of @@ -565,7 +565,7 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences | length start < maxTagLength = go (impureNonNull $ replicate (succ $ length start) $ head alphabet) [] result | otherwise - = Map.empty + = [] where mappingDescription :: ExamOccurrenceMappingDescription mappingDescription = ExamOccurrenceMappingRange (toNullable start) end @@ -592,10 +592,10 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences increase :: [CI Char] -> [CI Char] increase [] = [] increase (c:cs) + | c < head alphabet + = head alphabet : cs | nextChar == head alphabet = nextChar : increase cs - | nextChar == paddingChar - = head alphabet : cs | otherwise = nextChar : cs where @@ -603,9 +603,7 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences nextChar | c `elem` alphabet = dropWhile (/= c) alphabetCycle List.!! 1 - | c < head alphabet -- includes padding char - = head alphabet - | c > last alphabet -- basically all non-ascii printable characters + | otherwise -- includes padding char = head alphabet -- TODO what if the border is between to non-ascii characters? diff --git a/test/Handler/Utils/ExamSpec.hs b/test/Handler/Utils/ExamSpec.hs index c6a431222..9de995308 100644 --- a/test/Handler/Utils/ExamSpec.hs +++ b/test/Handler/Utils/ExamSpec.hs @@ -193,7 +193,7 @@ spec = do , "Martin", "Jackson", "Thompson", "White" , "Lopez", "Lee", "Gonzalez", "Harris" , "Clark", "Lewis", "Robinson", "Walker" - , "Perez", "Hall", "Young", "zu Allen" + , "Perez", "Hall", "Young", "zu Allen", "Fu" , "Únîcòdé", "Ähm-Ümlaüte", "von Leerzeichen" ] occurrenceMap :: Map UserId (Maybe ExamOccurrenceId) -> Map ExamOccurrenceId [UserId]