]> hydra-www.ietfng.org Git - grade/commitdiff
Improve suppression of Additional Grader Comments
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 21 Sep 2015 15:59:52 +0000 (11:59 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Mon, 21 Sep 2015 15:59:52 +0000 (11:59 -0400)
Rather than emitting any time there's a comment block at all, scan to
see if there are any non-whitespace bytes.  Since the skeleton files
always contain empty comment blocks, this should help in the case when
graders do not delete them.

lib/Grade/Parse.hs
lib/Grade/Print.hs
lib/Grade/Types.hs

index fa6b2ba87b479aeda52b35310e072eb3bc7ed73b..df50f097402dd9e33d741cddb3210d1a67b54086 100644 (file)
@@ -137,7 +137,7 @@ parseData defs = do
                     T.string commentStart *> T.newline *>
                     toUtf8 (T.sliced (T.manyTill T.anyChar (T.lookAhead cend))) <* cend
           _   <- T.whiteSpace
-          ((sn, ExDFS $ DFS smeta sat sc ds mcs) :)
+          ((sn, ExDFS $ DFS smeta sat sc ds (maybe "" id mcs)) :)
             <$> (modify (M.delete sn) >> go (M.insert sn () already))
 
     cend = T.string commentEnd *> T.newline
index fd85d5dcef7f6eff12fc0b6e2bd349d62e963316..4ab609a2e6bfe20be84f9254757ed55cb46b468b 100644 (file)
@@ -2,7 +2,9 @@
 
 module Grade.Print where
 
+import qualified Data.Char                    as C
 import qualified Data.Set                     as S
+import qualified Data.Text                    as T
 import           Numeric
 import           Text.PrettyPrint.Free
 
@@ -35,14 +37,14 @@ printGrade e t = brackets (p e <> "/" <> p t) <+> parens ((p $ e / t * 100.0) <>
   p x = text $ showFFloat (Just 1) x ""
 
 printSection :: ReportFileSection -> Doc e
-printSection (RFS st ss smax sdc msgc) =
+printSection (RFS st ss smax sdc sgc) =
   pretty st <> ":" <+> printGrade ss smax <> line
   `above` indent 1
     (vcat (punctuate empty (map pretty sdc))
-     <> maybe empty
-              (\x -> (if null sdc then empty else line)
-                     <> "Additional Grader Comments:" <> line `above` indent 1 (pretty x))
-              msgc)
+     <> (if null sdc then empty else line) <> magc sgc)
+ where
+  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
index 57b3a2c322ac124b462c63856f95212de5db6b04..8addb14444fcf8783d9cc10c71cb041a77f1580e 100644 (file)
@@ -151,7 +151,7 @@ data DataFileSection sat sdt loc = DFS
   , _dfs_sec_arg         :: sat
   , _dfs_loc             :: loc
   , _dfs_dings           :: [DataFileDing sdt loc]
-  , _dfs_grader_comments :: Maybe Text
+  , _dfs_grader_comments :: Text
   }
  deriving (Typeable)
 $(LTH.makeLenses ''DataFileSection)
@@ -191,7 +191,7 @@ data ReportFileSection = RFS
   , _rfs_score    :: Double
   , _rfs_max      :: Double
   , _rfs_dingtext :: [Text]
-  , _rfs_comments :: Maybe Text
+  , _rfs_comments :: Text
   }
  deriving (Show, Typeable)
 $(LTH.makeLenses ''ReportFileSection)