fix: make sure it compiles again + add 2-letter name

This commit is contained in:
Wolfgang Witt 2021-02-11 15:51:51 +01:00 committed by Wolfgang Witt
parent a66c61cecc
commit d60f93561f
2 changed files with 6 additions and 8 deletions

View File

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

View File

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