diff --git a/messages/de.msg b/messages/de.msg index efced8907..25ceda435 100644 --- a/messages/de.msg +++ b/messages/de.msg @@ -68,7 +68,7 @@ SheetHintFrom: Hinweis ab SheetSolution: Lösung SheetSolutionFrom: Lösung ab SheetMarking: Hinweise für Korrektoren -SheetType: Bewertung +SheetType: Wertung SheetInvisible: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar! SheetInvisibleUntil mFrom@Text: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar bis #{mFrom}! @@ -197,8 +197,8 @@ RatingTime: Korrigiert RatingComment: Kommentar SubmissionUsers: Studenten Rating: Korrektur - RatingPoints: Punkte +RatingPercent: Erreicht RatingFiles: Korrigierte Dateien PointsNotPositive: Punktzahl darf nicht negativ sein diff --git a/src/Handler/Sheet.hs b/src/Handler/Sheet.hs index c70ac4781..fe2f56aa8 100644 --- a/src/Handler/Sheet.hs +++ b/src/Handler/Sheet.hs @@ -200,6 +200,17 @@ getSheetListR tid csh = do cid <- mkCid return $ CSubmissionR tid csh sheetName cid CorrectionR in anchorCellM mkRoute $(widgetFile "widgets/rating") + , sortable Nothing -- (Just "percent") + (i18nCell MsgRatingPercent) + $ \(Entity _ Sheet{sheetType=sType}, _, mbSub) -> case mbSub of + (Just (Entity _ Submission{submissionRatingPoints=Just sPoints})) -> + case sType of + NotGraded -> mempty + _ | maxPoints sType > 0 -> + let percent = sPoints / maxPoints sType + in textCell $ textPercent $ realToFrac percent + _other -> mempty + _other -> mempty ] psValidator = def & defaultSorting [("submission-since", SortAsc)] @@ -225,12 +236,19 @@ getSheetListR tid csh = do , ( "rating" , SortColumn $ \(_ `E.LeftOuterJoin` (submission `E.InnerJoin` submissionUser)) -> submission E.?. SubmissionRatingPoints ) +-- GitLab Issue $1??: +-- , ( "percent" +-- , SortColumn $ \(sheet `E.LeftOuterJoin` (submission `E.InnerJoin` ))) -> +-- case sheetType of -- no Haskell inside Esqueleto, right? +-- (submission E.?. SubmissionRatingPoints) E./. (sheet ) +-- ) ] , dbtFilter = Map.fromList [] , dbtStyle = def , dbtIdent = "sheets" :: Text } +-- <- runDB defaultLayout $ do $(widgetFile "sheetList") diff --git a/src/Utils.hs b/src/Utils.hs index 20b1309e2..5a5428d70 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -14,6 +14,7 @@ module Utils import ClassyPrelude.Yesod +-- import Data.Double.Conversion.Text -- faster implementation for textPercent? import Data.List (foldl) import Data.Foldable as Fold import qualified Data.Char as Char @@ -150,6 +151,14 @@ instance DisplayAble a => DisplayAble (CI a) where instance {-# OVERLAPPABLE #-} Show a => DisplayAble a where display = pack . show +textPercent :: Double -> Text -- slow, maybe use Data.Double.Conversion.Text.toFixed instead? +textPercent x = lz <> (pack $ show rx) <> "%" + where + round' :: Double -> Int -- avoids annoying warning + round' = round + rx :: Double + rx = fromIntegral (round' $ 1000.0*x) / 10.0 + lz = if rx < 10.0 then "0" else "" ------------