]> hydra-www.ietfng.org Git - grade/commitdiff
Add function for totaling report
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 26 Sep 2015 02:53:51 +0000 (22:53 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 26 Sep 2015 02:53:51 +0000 (22:53 -0400)
lib/Grade/Grade.hs
lib/Grade/Print.hs

index 9ffab2eedea161e8e7f7a5635333f92332cf1f14..35ffbe0efa092bf16fac716e8a07b9a2efee1580 100644 (file)
@@ -1,7 +1,7 @@
 {-# LANGUAGE FlexibleContexts #-}
 {-# OPTIONS_GHC -Wall #-}
 
-module Grade.Grade (gradeOne) where
+module Grade.Grade (gradeOne, totalReport) where
 
 import           Control.Lens
 import           Data.Either
@@ -42,3 +42,7 @@ gradeOne (Defs defs _) (DF dfss) =
           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
+
index f5a8af9c0206caca421679e3ee25f8089cd00944..474ed5925feed7c9c1bab714a21daa5590d075e8 100644 (file)
@@ -9,6 +9,7 @@ import           Numeric
 import           Text.PrettyPrint.Free
 
 import           Grade.Types
+import           Grade.Grade
 
 printSectionError :: (loc -> Doc e) -> SectionError loc -> Doc e
 printSectionError pl (SEUndefinedDing dn dl) =
@@ -46,10 +47,8 @@ printSection (RFS st ss smax sdc sgc) =
   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