{-# LANGUAGE FlexibleContexts #-}
{-# OPTIONS_GHC -Wall #-}
-module Grade.Grade (gradeOne) where
+module Grade.Grade (gradeOne, totalReport) where
import Control.Lens
import Data.Either
Right _ -> Left [e]
where
processSec (sn,s) = bimap (RESectionError sn . pure . SEScoreError) id $ processDFS s
+
+totalReport :: ReportFile -> (Double,Double)
+totalReport (RF secs) = foldr (\(RFS _ ss sm _ _) (e,t) -> (ss+e,sm+t)) (0.0,0.0) secs
+
import Text.PrettyPrint.Free
import Grade.Types
+import Grade.Grade
printSectionError :: (loc -> Doc e) -> SectionError loc -> Doc e
printSectionError pl (SEUndefinedDing dn dl) =
magc x = if T.any (not . C.isSpace) x then agc x else empty
agc x = "Additional Grader Comments:" <> line `above` indent 1 (pretty x)
-total :: ReportFile -> (Double,Double)
-total (RF secs) = foldr (\(RFS _ ss sm _ _) (e,t) -> (ss+e,sm+t)) (0.0,0.0) secs
printReport :: ReportFile -> Doc e
printReport r@(RF s) =
vcat (map printSection s) <> line
- <> "TOTAL:" <+> (uncurry printGrade $ total r) <> line
+ <> "TOTAL:" <+> (uncurry printGrade $ totalReport r) <> line