diff --git a/src/Handler/Utils/Exam.hs b/src/Handler/Utils/Exam.hs index 00d3a90b4..3ed6e30db 100644 --- a/src/Handler/Utils/Exam.hs +++ b/src/Handler/Utils/Exam.hs @@ -416,7 +416,11 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences w = offsets Array.! j - offsets Array.! i 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) breakCost' + | remainingWords > remainingLineSpace + = PosInf | j < Map.size wordMap , j > 0 = breakCost (wordIx # pred j) (wordIx # j)