From 2bc68946e379e7d29a85148017ca9fd14b01ab18 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 26 Sep 2019 14:37:55 +0200 Subject: [PATCH] fix(exams): include bonus points in sum for exam participants --- src/Handler/Exam/Show.hs | 8 +++++++- src/Utils/Form.hs | 2 +- templates/exam-show.hamlet | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Handler/Exam/Show.hs b/src/Handler/Exam/Show.hs index 27c55a9b4..9ee2da005 100644 --- a/src/Handler/Exam/Show.hs +++ b/src/Handler/Exam/Show.hs @@ -72,11 +72,17 @@ getEShowR tid ssh csh examn = do examClosedShown = lecturerInfoShown sumMaxPoints = sum [ fromRational examPartWeight * mPoints | Entity _ ExamPart{..} <- examParts, let Just mPoints = examPartMaxPoints ] - sumPoints = getSum <$> foldMap (fmap Sum . examPartResultResult . entityVal) results noBonus = fromMaybe False $ do guardM $ bonusOnlyPassed <$> examBonusRule return . fromMaybe True $ result ^? _Just . _entityVal . _examResultResult . _examResult . passingGrade . _Wrapped . to not + + sumPoints = fmap getSum . mconcat $ catMaybes + [ Just $ foldMap (fmap Sum . examPartResultResult . entityVal) results + , guard (not noBonus) *> fmap (pure . Sum . examBonusBonus . entityVal) bonus + ] + + hasRegistration = any snd occurrences let examTimes = all (\(Entity _ ExamOccurrence{..}, _) -> Just examOccurrenceStart == examStart && examOccurrenceEnd == examEnd) occurrences diff --git a/src/Utils/Form.hs b/src/Utils/Form.hs index 1a7d32b74..31bc5ad08 100644 --- a/src/Utils/Form.hs +++ b/src/Utils/Form.hs @@ -328,7 +328,7 @@ combinedButtonField :: forall a m. ) => [a] -> FieldSettings (HandlerSite m) -> AForm m [Maybe a] combinedButtonField bs FieldSettings{..} = formToAForm $ do mr <- getMessageRender - fvId <- maybe newFormIdent return fsId + fvId <- maybe newIdent return fsId name <- maybe newFormIdent return fsName (ress, fvs) <- fmap unzip . for bs $ \b -> mopt (buttonField b) ("" { fsId = Just $ fvId <> "__" <> toPathPiece b , fsName = Just $ name <> "__" <> toPathPiece b diff --git a/templates/exam-show.hamlet b/templates/exam-show.hamlet index b05d2c2b6..44ff63632 100644 --- a/templates/exam-show.hamlet +++ b/templates/exam-show.hamlet @@ -114,7 +114,7 @@ $if not (null occurrences) _{MsgExamRoomDescription} $forall (Entity _occId ExamOccurrence{examOccurrenceName, examOccurrenceRoom, examOccurrenceStart, examOccurrenceEnd, examOccurrenceDescription}, registered) <- occurrences - + $if occurrenceNamesShown #{examOccurrenceName} $if occurrenceAssignmentsShown