Merge branch 'master' into 'live'
Make rating parse expect more rigid structure Closes #127 See merge request !61
This commit is contained in:
commit
8a99ef4d69
@ -131,7 +131,7 @@ formatRating cID Rating{ ratingValues = Rating'{..}, ..} = let
|
|||||||
[ Just $ "Veranstaltung:" <+> pretty ratingCourseName
|
[ Just $ "Veranstaltung:" <+> pretty ratingCourseName
|
||||||
, Just $ "Blatt:" <+> pretty ratingSheetName
|
, Just $ "Blatt:" <+> pretty ratingSheetName
|
||||||
, ("Korrektor:" <+>) . pretty <$> ratingCorrectorName
|
, ("Korrektor:" <+>) . pretty <$> ratingCorrectorName
|
||||||
, Just $ "Blatt-Bewertung:" <+> pretty (display ratingSheetType)
|
, Just $ "Bewertung:" <+> pretty (display ratingSheetType)
|
||||||
]
|
]
|
||||||
, "Abgabe-Id:" <+> pretty (ciphertext cID)
|
, "Abgabe-Id:" <+> pretty (ciphertext cID)
|
||||||
, "============================================="
|
, "============================================="
|
||||||
@ -153,9 +153,11 @@ parseRating :: MonadThrow m => File -> m Rating'
|
|||||||
parseRating File{ fileContent = Just input, .. } = do
|
parseRating File{ fileContent = Just input, .. } = do
|
||||||
inputText <- either (throw . RatingNotUnicode) return $ Text.decodeUtf8' input
|
inputText <- either (throw . RatingNotUnicode) return $ Text.decodeUtf8' input
|
||||||
let
|
let
|
||||||
(headerLines, commentLines) = break (sep `Text.isInfixOf`) $ Text.lines inputText
|
(headerLines', commentLines) = break (sep `Text.isInfixOf`) $ Text.lines inputText
|
||||||
ratingLines = filter (rating `Text.isInfixOf`) headerLines
|
(reverse -> ratingLines, reverse -> headerLines) = break (sep' `Text.isInfixOf`) $ reverse headerLines'
|
||||||
|
ratingLines' = filter (rating `Text.isInfixOf`) ratingLines
|
||||||
sep = "Beginn der Kommentare"
|
sep = "Beginn der Kommentare"
|
||||||
|
sep' = Text.pack $ replicate 40 '='
|
||||||
rating = "Bewertung:"
|
rating = "Bewertung:"
|
||||||
comment' <- case commentLines of
|
comment' <- case commentLines of
|
||||||
(_:commentLines') -> return . Text.strip $ Text.unlines commentLines'
|
(_:commentLines') -> return . Text.strip $ Text.unlines commentLines'
|
||||||
|
|||||||
Reference in New Issue
Block a user