diff --git a/messages/uniworx/de.msg b/messages/uniworx/de.msg index 4b7c8a3b0..7c03d6713 100644 --- a/messages/uniworx/de.msg +++ b/messages/uniworx/de.msg @@ -258,6 +258,7 @@ RatingDone: Bewertung fertiggestellt RatingPercent: Erreicht RatingFiles: Korrigierte Dateien PointsNotPositive: Punktzahl darf nicht negativ sein +PointsTooHigh maxPoints@Points: Punktzahl darf nicht höher als #{tshow maxPoints} sein RatingPointsDone: Abgabe zählt als korrigiert, gdw. Punktezahl gesetzt ist ColumnRatingPointsDone: Punktzahl/Abgeschlossen Pseudonyms: Pseudonyme diff --git a/src/Foundation.hs b/src/Foundation.hs index cd09b4ad8..dc350557d 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -228,6 +228,15 @@ embedRenderMessage ''UniWorX ''CorrectorState id embedRenderMessage ''UniWorX ''SheetGrading ("SheetGrading" <>) embedRenderMessage ''UniWorX ''SheetType ("SheetType" <>) +newtype SheetTypeComplete = SheetTypeComplete SheetType +instance RenderMessage UniWorX (SheetTypeComplete) where + renderMessage foundation ls (SheetTypeComplete st) = case st of + NotGraded -> mr NotGraded + other -> mr (grading other) <> ", " <> mr other + where + mr :: RenderMessage UniWorX msg => msg -> Text + mr = renderMessage foundation ls + newtype ErrorResponseTitle = ErrorResponseTitle ErrorResponse embedRenderMessageVariant ''UniWorX ''ErrorResponseTitle ("ErrorResponseTitle" <>) diff --git a/src/Handler/Corrections.hs b/src/Handler/Corrections.hs index 9e2285d40..7e4247d19 100644 --- a/src/Handler/Corrections.hs +++ b/src/Handler/Corrections.hs @@ -486,7 +486,9 @@ postCorrectionR tid ssh csh shn cid = do let ratingComment = fmap Text.strip submissionRatingComment >>= (\c -> c <$ guard (not $ null c)) pointsForm = case sheetType of NotGraded -> pure Nothing - _otherwise -> aopt pointsField (fslpI MsgRatingPoints "Punktezahl") (Just $ submissionRatingPoints) + _otherwise -> aopt (pointsFieldMax $ preview (_grading . _maxPoints) sheetType) + (fslpI MsgRatingPoints "Punktezahl") + (Just $ submissionRatingPoints) ((corrResult, corrForm), corrEncoding) <- runFormPost . identForm FIDcorrection . renderAForm FormStandard $ (,,) <$> areq checkBoxField (fslI MsgRatingDone) (Just $ submissionRatingDone Submission{..}) diff --git a/src/Handler/Utils/Form.hs b/src/Handler/Utils/Form.hs index cc3d146fc..9fc3a8daf 100644 --- a/src/Handler/Utils/Form.hs +++ b/src/Handler/Utils/Form.hs @@ -193,6 +193,9 @@ pointsField = checkBool (>= 0) MsgPointsNotPositive Field{..} sci <- maybe (Left $ MsgInvalidNumber t) Right (readMaybe $ unpack t :: Maybe Scientific) return . fromRational $ round (sci * 100) % 100 +pointsFieldMax :: (Monad m, HandlerSite m ~ UniWorX) => Maybe Points -> Field m Points --TODO allow fractions +pointsFieldMax Nothing = pointsField +pointsFieldMax (Just maxp) = checkBool (<= maxp) (MsgPointsTooHigh maxp) pointsField termsActiveField :: Field Handler TermId termsActiveField = selectField $ optionsPersistKey [TermActive ==. True] [Desc TermStart] termName diff --git a/templates/sheetShow.hamlet b/templates/sheetShow.hamlet index 9efdc5e24..7776c0bc8 100644 --- a/templates/sheetShow.hamlet +++ b/templates/sheetShow.hamlet @@ -18,7 +18,7 @@ $maybe descr <- sheetDescription sheet
_{MsgSheetSolutionFrom}
#{solution}
_{MsgSheetType} -
_{sheetType sheet} +
_{SheetTypeComplete (sheetType sheet)} $if CorrectorSubmissions == sheetSubmissionMode sheet
_{MsgSheetPseudonym}