Minor fixes toward percentage column, unfinished but compiles.
This commit is contained in:
parent
d05ccc9c6d
commit
f92001510b
@ -68,7 +68,7 @@ SheetHintFrom: Hinweis ab
|
|||||||
SheetSolution: Lösung
|
SheetSolution: Lösung
|
||||||
SheetSolutionFrom: Lösung ab
|
SheetSolutionFrom: Lösung ab
|
||||||
SheetMarking: Hinweise für Korrektoren
|
SheetMarking: Hinweise für Korrektoren
|
||||||
SheetType: Bewertung
|
SheetType: Wertung
|
||||||
|
|
||||||
SheetInvisible: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar!
|
SheetInvisible: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar!
|
||||||
SheetInvisibleUntil mFrom@Text: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar bis #{mFrom}!
|
SheetInvisibleUntil mFrom@Text: Dieses Übungsblatt ist für Teilnehmer momentan unsichtbar bis #{mFrom}!
|
||||||
@ -197,8 +197,8 @@ RatingTime: Korrigiert
|
|||||||
RatingComment: Kommentar
|
RatingComment: Kommentar
|
||||||
SubmissionUsers: Studenten
|
SubmissionUsers: Studenten
|
||||||
Rating: Korrektur
|
Rating: Korrektur
|
||||||
|
|
||||||
RatingPoints: Punkte
|
RatingPoints: Punkte
|
||||||
|
RatingPercent: Erreicht
|
||||||
RatingFiles: Korrigierte Dateien
|
RatingFiles: Korrigierte Dateien
|
||||||
PointsNotPositive: Punktzahl darf nicht negativ sein
|
PointsNotPositive: Punktzahl darf nicht negativ sein
|
||||||
|
|
||||||
|
|||||||
@ -200,6 +200,17 @@ getSheetListR tid csh = do
|
|||||||
cid <- mkCid
|
cid <- mkCid
|
||||||
return $ CSubmissionR tid csh sheetName cid CorrectionR
|
return $ CSubmissionR tid csh sheetName cid CorrectionR
|
||||||
in anchorCellM mkRoute $(widgetFile "widgets/rating")
|
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
|
psValidator = def
|
||||||
& defaultSorting [("submission-since", SortAsc)]
|
& defaultSorting [("submission-since", SortAsc)]
|
||||||
@ -225,12 +236,19 @@ getSheetListR tid csh = do
|
|||||||
, ( "rating"
|
, ( "rating"
|
||||||
, SortColumn $ \(_ `E.LeftOuterJoin` (submission `E.InnerJoin` submissionUser)) -> submission E.?. SubmissionRatingPoints
|
, 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
|
, dbtFilter = Map.fromList
|
||||||
[]
|
[]
|
||||||
, dbtStyle = def
|
, dbtStyle = def
|
||||||
, dbtIdent = "sheets" :: Text
|
, dbtIdent = "sheets" :: Text
|
||||||
}
|
}
|
||||||
|
-- <- runDB
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
$(widgetFile "sheetList")
|
$(widgetFile "sheetList")
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ module Utils
|
|||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
|
|
||||||
|
-- import Data.Double.Conversion.Text -- faster implementation for textPercent?
|
||||||
import Data.List (foldl)
|
import Data.List (foldl)
|
||||||
import Data.Foldable as Fold
|
import Data.Foldable as Fold
|
||||||
import qualified Data.Char as Char
|
import qualified Data.Char as Char
|
||||||
@ -150,6 +151,14 @@ instance DisplayAble a => DisplayAble (CI a) where
|
|||||||
instance {-# OVERLAPPABLE #-} Show a => DisplayAble a where
|
instance {-# OVERLAPPABLE #-} Show a => DisplayAble a where
|
||||||
display = pack . show
|
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 ""
|
||||||
|
|
||||||
|
|
||||||
------------
|
------------
|
||||||
|
|||||||
Reference in New Issue
Block a user