From 648d4b8c338c8b205f75d39e0e6f4ce0fbf5439f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 18 Jul 2018 19:54:57 +0200 Subject: [PATCH] Make rating parse expect more rigid structure Fixes #127 --- src/Handler/Utils/Rating.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Handler/Utils/Rating.hs b/src/Handler/Utils/Rating.hs index 5f35365e1..2ec19d999 100644 --- a/src/Handler/Utils/Rating.hs +++ b/src/Handler/Utils/Rating.hs @@ -131,7 +131,7 @@ formatRating cID Rating{ ratingValues = Rating'{..}, ..} = let [ Just $ "Veranstaltung:" <+> pretty ratingCourseName , Just $ "Blatt:" <+> pretty ratingSheetName , ("Korrektor:" <+>) . pretty <$> ratingCorrectorName - , Just $ "Blatt-Bewertung:" <+> pretty (display ratingSheetType) + , Just $ "Bewertung:" <+> pretty (display ratingSheetType) ] , "Abgabe-Id:" <+> pretty (ciphertext cID) , "=============================================" @@ -153,9 +153,11 @@ parseRating :: MonadThrow m => File -> m Rating' parseRating File{ fileContent = Just input, .. } = do inputText <- either (throw . RatingNotUnicode) return $ Text.decodeUtf8' input let - (headerLines, commentLines) = break (sep `Text.isInfixOf`) $ Text.lines inputText - ratingLines = filter (rating `Text.isInfixOf`) headerLines + (headerLines', commentLines) = break (sep `Text.isInfixOf`) $ Text.lines inputText + (reverse -> ratingLines, reverse -> headerLines) = break (sep' `Text.isInfixOf`) $ reverse headerLines' + ratingLines' = filter (rating `Text.isInfixOf`) ratingLines sep = "Beginn der Kommentare" + sep' = Text.pack $ replicate 40 '=' rating = "Bewertung:" comment' <- case commentLines of (_:commentLines') -> return . Text.strip $ Text.unlines commentLines'