From 27cbff2aaa1c9997551b1f75b6a2a033e9592980 Mon Sep 17 00:00:00 2001 From: SJost Date: Sat, 15 Sep 2018 11:23:55 +0200 Subject: [PATCH] =?UTF-8?q?Matrikelnummern=20bei=20Abgaben=20anzeigen,=20R?= =?UTF-8?q?enderMessage=20Instanz=20f=C3=BCr=20Load=20=C3=BCberarbeitet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/uniworx/de.msg | 6 ++++-- src/Foundation.hs | 20 +++++--------------- src/Handler/Corrections.hs | 6 ++++++ src/Utils.hs | 12 ++++++++++++ 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index eda91acdf..77edf6cf3 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -169,9 +169,11 @@ Corrector: Korrektor Correctors: Korrektoren CorState: Status CorByTut: Nach Tutorium -Tutorial: Tutorium CorProportion: Anteil -CorrectionProportion: Anteile +CorByProportionOnly proportion@Rational: #{display proportion} Anteile +CorByProportionIncludingTutorial proportion@Rational: #{display proportion} Anteile - Tutorium +CorByProportionExcludingTutorial proportion@Rational: #{display proportion} Anteile + Tutorium + DeleteRow: Zeile entfernen ProportionNegative: Anteile dürfen nicht negativ sein CorrectorsUpdated: Korrektoren erfolgreich aktualisiert diff --git a/src/Foundation.hs b/src/Foundation.hs index 6ee75a3e2..ab3649634 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -207,22 +207,12 @@ instance RenderMessage UniWorX CorrectorState where instance RenderMessage UniWorX Load where - renderMessage foundation ls (Load {..}) = loadText <> tutorialText - where - loadText = if byProportion > 0 - then (tshow $ fromRational byProportion) <> " " <> renderMessage' MsgCorrectionProportion - else mempty + renderMessage foundation ls = \case + (Load {byTutorial=Nothing , byProportion=p}) -> renderMessage' $ MsgCorByProportionOnly p + (Load {byTutorial=Just True , byProportion=p}) -> renderMessage' $ MsgCorByProportionIncludingTutorial p + (Load {byTutorial=Just False, byProportion=p}) -> renderMessage' $ MsgCorByProportionExcludingTutorial p + where renderMessage' = renderMessage foundation ls - tutorialText = case byTutorial of - Nothing -> mempty - (Just plusLoad) -> - let connector = if - | loadText == mempty -> mempty - | plusLoad -> " - " - | otherwise -> " + " - in connector <> renderMessage' MsgTutorial - - renderMessage' = renderMessage foundation ls instance RenderMessage UniWorX (UnsupportedAuthPredicate (Route UniWorX)) where renderMessage f ls (UnsupportedAuthPredicate tag route) = renderMessage f ls $ MsgUnsupportedAuthPredicate tag (show route) diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index cf548a8df..793e34772 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -125,6 +125,11 @@ colSubmittors :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a) colSubmittors = sortable Nothing (i18nCell MsgSubmissionUsers) $ \DBRow{ dbrOutput=(_, _, _, _, users) } -> let cell = listCell (Map.toList users) $ \(userId, User{..}) -> anchorCellM (AdminUserR <$> encrypt userId) (toWidget userDisplayName) in cell & cellAttrs <>~ [("class", "list--inline list--comma-separated")] + +colSMatrikel :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a) +colSMatrikel = sortable Nothing (i18nCell MsgMatrikelNr) $ \DBRow{ dbrOutput=(_, _, _, _, users) } -> let + cell = listCell (Map.toList users) $ \(userId, User{..}) -> anchorCellM (AdminUserR <$> encrypt userId) (maybe mempty toWidget userMatrikelnummer) + in cell & cellAttrs <>~ [("class", "list--inline list--comma-separated")] colRating :: IsDBTable m a => Colonnade _ CorrectionTableData (DBCell m a) colRating = sortable (Just "rating") (i18nCell MsgRating) $ \DBRow{ dbrOutput=(Entity subId Submission{..}, Entity _ Sheet{..}, course, _, _) } -> @@ -354,6 +359,7 @@ postCCorrectionsR tid ssh csh = do , dbRow , colSheet , colCorrector + , colSMatrikel , colSubmittors , colSubmissionLink , colRating diff --git a/src/Utils.hs b/src/Utils.hs index 950756cbd..b0671d4af 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -27,6 +27,9 @@ import Utils.PathPiece as Utils import Text.Blaze (Markup, ToMarkup) +import Data.Text (dropWhileEnd) +import Numeric (showFFloat) + import Control.Lens import Data.Set (Set) import qualified Data.Set as Set @@ -136,6 +139,15 @@ instance DisplayAble a => DisplayAble (Maybe a) where display Nothing = "" display (Just x) = display x +instance DisplayAble Rational where + display r = showFFloat (Just 2) (rat2float r) "" + & pack + & dropWhileEnd ('0'==) + & dropWhileEnd ('.'==) + where + rat2float :: Rational -> Double + rat2float = fromRational + instance DisplayAble a => DisplayAble (E.Value a) where display = display . E.unValue