diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index 4291d68e4..8c3798c8a 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -569,7 +569,16 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences -- userTags is guaranteed nonNull end = case t of [] -> replicate (length start) $ last alphabet - _nonEmpty -> maximum $ impureNonNull $ map (transformTag start) userTags + _nonEmpty + | length biggestTag < length start + -- add padding, to keep equal length + -> biggestTag ++ replicate (length start - length biggestTag) paddingChar + | otherwise -> biggestTag + where + biggestTag :: [CI Char] + biggestTag = maximum $ impureNonNull $ map (transformTag start) userTags + paddingChar :: CI Char + paddingChar = CI.mk ' ' nextStart :: NonNull [CI Char] -- end is guaranteed nonNull, all empty tags are filtered out in users' nextStart = impureNonNull $ reverse $ increase $ reverse end @@ -578,8 +587,12 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences increase :: [CI Char] -> [CI Char] increase [] = [] increase (c:cs) - | nextChar == head alphabet = nextChar : increase cs - | otherwise = nextChar : cs + | nextChar == head alphabet + = nextChar : increase cs + | nextChar == paddingChar + = head alphabet : cs + | otherwise + = nextChar : cs where nextChar :: CI Char nextChar = dropWhile (/= c) alphabetCycle List.!! 1