From: Nathaniel Wesley Filardo Date: Mon, 30 Nov 2015 22:15:19 +0000 (-0500) Subject: snapshot X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fexperimental;p=grade snapshot --- diff --git a/README.rst b/README.rst index 265b03d..64c9291 100644 --- a/README.rst +++ b/README.rst @@ -157,13 +157,13 @@ where extra loss. * The word ``commenting`` followed by (whitespace and) another ``type`` - will permit the definitions of flags with argument ``!C`` which will + will permit the definitions of flags with argument ``!C``, which will not influence the score at all and will not print out a score modifier before the flag text in generated reports. * The word ``zeroing`` followed by (whitespace and) another ``type`` - will permit the definitions of flags with argument ``!0`` which will - set the section score to zero. + will permit the definitions of flags with score-modifier ``!0``, which + will set the section score to zero. Some shorthands are defined: @@ -200,13 +200,6 @@ more than once. score by that percentage of the maximum number of points available in the section. - * The literal string ``!0``. Engaging any whole number of flags so - defined will set the section's score to zero. - -* For ``equal`` sections, the only permitted non-empty ``score-modifier`` - is ``!0``, which is interpreted as in ``simple`` sections. All other - flags in this type of section should have an empty ``score-modifier``. - Text between the line beginning with ``:`` (or ``;``) and the dot on a line by itself will be copied into student grade reports whenever the flag is given in a grade data file. In many cases, there are many conditions that diff --git a/grade.cabal b/grade.cabal index b62ba7a..3bcc0d2 100644 --- a/grade.cabal +++ b/grade.cabal @@ -39,7 +39,7 @@ library text >=1.2 && <2, trifecta >=1.5 && <2, ansi-wl-pprint >= 0.6 && <1, - wl-pprint-extras >=3.5 && <4 + wl-pprint-extras >=3.5 && <3.6 executable grade Main-Is: Grade.hs @@ -52,5 +52,31 @@ executable grade filepath >= 1.4 && <2, trifecta >=1.5 && <2, ansi-wl-pprint >= 0.6 && <1, - wl-pprint-extras >=3.5 && <4, + wl-pprint-extras >=3.5 && <3.6, + grade >=0.1 + +executable phf-xml + Main-Is: phf-xml.hs + hs-source-dirs: prog + default-language: Haskell2010 + other-extensions: CPP + build-depends: base >=4.6 && <5, + bytestring >=0.10 && <0.11, + cmdlib >= 0.3 && <1, + conduit >= 1.2 && <2, + conduit-extra >= 1.1 && <2, + containers >=0.5 && <1, + directory >= 1.2 && <2, + filepath >= 1.4 && <2, + lens >=4 && <5, + mtl >=2.2 && <3, + reducers >= 3.12 && <4, + resourcet >= 1 && <2, + text >=1.2 && <2, + transformers >=0.4 && <1, + trifecta >=1.5 && <2, + ansi-wl-pprint >= 0.6 && <1, + wl-pprint-extras >=3.5 && <3.6, + xml-conduit >=1.3 && <2, + xml-lens >=0.1 && <1, grade >=0.1 diff --git a/lib/Grade/ParseUtils.hs b/lib/Grade/ParseUtils.hs index 3a6efee..df6a96c 100644 --- a/lib/Grade/ParseUtils.hs +++ b/lib/Grade/ParseUtils.hs @@ -1,7 +1,7 @@ -- Header -------------------------------------------------------------- {{{ module Grade.ParseUtils ( - toUtf8, sseof, word, hashComment, parseMapKeys + toUtf8, sseof, wordish, word, hashComment, parseMapKeys ) where import Control.Applicative @@ -21,10 +21,13 @@ toUtf8 = (>>= either (\e -> T.unexpected ("Invalid UTF-8: " ++ show e)) (pure) . sseof :: (T.TokenParsing f) => f () sseof = (T.someSpace <|> T.eof) +wordish :: (T.DeltaParsing f) => f Text +wordish = toUtf8 (T.sliced (some (T.notFollowedBy T.someSpace *> T.anyChar))) + -- | Grab a word in its entirety. Note that this is a little strange as -- we check the 'notFollowedBy' condition *first*! word :: (T.DeltaParsing f) => f Text -word = toUtf8 (T.sliced (many $ T.notFollowedBy T.someSpace *> T.anyChar)) <* sseof +word = wordish <* sseof -- | Grab a comment beginning with # and going to end of line. hashComment :: T.DeltaParsing f => f Text diff --git a/lib/Grade/Score/Commenting.hs b/lib/Grade/Score/Commenting.hs index fb82fca..601f587 100644 --- a/lib/Grade/Score/Commenting.hs +++ b/lib/Grade/Score/Commenting.hs @@ -15,7 +15,7 @@ parseCommented :: (T.TokenParsing f, Monoid sds) -> f (sdt,sds) -- ^ What is the underlying ding parser? -> f (Maybe sdt, sds) parseCommented pc pd = T.choice - [ -- Try parsing a zeroizing form + [ -- Try parsing a commenting form T.try pc *> pure (Nothing, mempty) , -- Otherwise, invoke the underlying parser (\(a,b) -> (Just a, b)) <$> pd diff --git a/lib/Grade/Types.hs b/lib/Grade/Types.hs index 61c4002..388120b 100644 --- a/lib/Grade/Types.hs +++ b/lib/Grade/Types.hs @@ -42,21 +42,9 @@ data DingDefn mt loc = DingDefn , _dingd_multiple :: Bool , _dingd_comment_lines :: [Text] } - deriving (Eq,Ord,{-Show-}Typeable) + deriving (Eq,Ord,{-Show,-}Typeable) $(LTH.makeLenses ''DingDefn) -data SecMeta sat sdt = SecMeta - { -- | Title of the section as displayed to the user, not - -- necessarily the internal name - _sm_title :: Text - , -- | Maximum score - _sm_max :: Double - , -- | Given a reduced sdsdum, format the score for presentation - -- or indicate that there has been an error. - _sm_scorefn :: sat -> sdt -> Either String Double - , -- | Provide text for printing out the impact of a particular - -- score adjustment. - _sm_dingprinter :: sat -> sdt -> Maybe String } $(LTH.makeLenses ''SecMeta) @@ -68,9 +56,13 @@ $(LTH.makeLenses ''SecMeta) -- It also conains a section scoring function, which -- reduces dingmods to a score. data Section f sat sdt loc = Sec - { _sec_meta :: SecMeta sat sdt + { -- | The section header, as displayed to the students + _sec_title :: Text + -- | The location in the defines file , _sec_loc :: loc + -- | Is this section to be emitted into the skeleton? , _sec_hidden :: Bool + -- | Comment lines preceeding the section definition. , _sec_comment_lines :: [Text] , _sec_ding_by_name :: Map DingName (DingDefn sdt loc) , _sec_dings :: [(DingName, DingDefn sdt loc)] @@ -79,25 +71,9 @@ data Section f sat sdt loc = Sec deriving (Typeable) $(LTH.makeLenses ''Section) -{- -instance (Show sdt, Show loc) => Show (Section sdt loc) where - show (Sec t m h _ d c) = "Section " - ++ (show t) ++ " " - ++ (show m) ++ " " - ++ (show h) ++ " " - ++ " " - ++ (show d) ++ " " - ++ (show c) --} - -- | Existentially quantify the section data type for a given section data ExSection f loc = forall sat sdt . ({-Show sdt,-} Monoid sdt) => ExSec (Section f sat sdt loc) -{- -instance (Show loc) => Show (ExSection loc) where - show es = case es of ExSec s -> show s --} - -- | A Section Callback object, as returned by a section type parser data SecCallback f sps sat sdt = SC { -- | Section header parser for data file. This allows one to @@ -106,14 +82,18 @@ data SecCallback f sps sat sdt = SC -- -- The String is for use by the skeleton generator. sc_datline_parse :: (Maybe String, f sat) + , -- | Parse section-specific ding weights sc_ding_parse :: f (sdt,sps) + , -- | Optional printout of the sdt data, given -- the section's final sps. sc_show_sdt :: sps -> sat -> sdt -> Maybe String + , -- | Scoring function, given section maximum -- value and the monoidal summary of section-specific dings sc_score :: sps -> sat -> sdt -> Either String Double + , -- | Maximum scoring function sc_max :: sps -> Double } @@ -122,6 +102,52 @@ data SecCallback f sps sat sdt = SC data ExSecCallback f = forall sps sat sdt . ({-Show sdt,-} Monoid sdt, Monoid sps) => ExSecCB (SecCallback f sps sat sdt) +{- +-- | We often want to modify the action of dings in a section. This is +-- rather like a 'SecCallback' without the at-line types. +data SecModCallback sps sdt = SMC + { -- | Parse a modified ding defintion. If this succeeds, the remainder + -- of the ding definition chain will not be considered for this ding. + -- + -- XXX Could maybe have a Boolean indicating whether to continue + -- parsing at the next stage. We'd fan out the occurrence of the + -- ding to all subscribed stages, essentially... + -- + -- XXX Also consider per-ding arguments in the *data* file... + smc_ding_parse :: f (sdt, sps) + + , -- | Render a ding that was parsed by this section. Rather than taking + -- the section heading value, if any, these take the computed section + -- maximum. + smc_show_sdt :: sdt -> Double -> sdt -> Maybe String + + , -- | Compute the new score after this modifier + smc_score :: sps -- ^ Cumulative section *parser* state + -> sdt -- ^ Cumulative section *ding* state + -> Double -- ^ Section maxiumum after all pipeline mods + -> Double -- ^ Section score from earlier stages + -> Either String Double -- ^ Resulting section score + + , -- | Given the maximum as computed by earlier modules, possibly alter it + -- in light of the cumulative parser state + smc_max_mod :: sps -> Double -> Double + } +-} + +{- +data SecStatus sps sdt = SMC + { -- | The callback operations for this section + ss_smc :: SecModCallback sps sdt + + , -- | The set of dings that have been claimed by this section. + ss_dings :: + + -- | The section's parser state itself; this will be updated during + -- the parser's run as the callback accepts various dings. + , ss_sps :: sps + } +-} + newtype SecName = SN { unSN :: Text } deriving (Eq,Ord,Show,Typeable)