From d4907cd776467dcd863ea761f9c0c88408e7248a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 19 Nov 2019 11:54:14 +0100 Subject: [PATCH] fix(sheet list): only show corrections after they are finished Fixes #533 --- src/Handler/Sheet.hs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Handler/Sheet.hs b/src/Handler/Sheet.hs index 661744614..bfbbdccaa 100644 --- a/src/Handler/Sheet.hs +++ b/src/Handler/Sheet.hs @@ -250,26 +250,34 @@ getSheetListR tid ssh csh = do return $ CSubmissionR tid ssh csh sheetName cid' SubShowR in anchorCellM mkRoute (mkCid >>= \cid2 -> [whamlet|#{cid2}|]) , sortable (Just "rating") (i18nCell MsgRating) - $ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, mbSub,_)} -> + $ \DBRow{dbrOutput=(Entity _ Sheet{..}, _, mbSub,_)} -> let stats = sheetTypeSum sheetType in -- for statistics over all shown rows case mbSub of Nothing -> cellTell mempty $ stats Nothing (Just (Entity sid sub@Submission{..})) -> - let mkCid = encrypt sid - mkRoute = do - cid' <- mkCid + let + mkRoute :: (MonadHandler m, HandlerSite m ~ UniWorX) => m (Route UniWorX) + mkRoute = liftHandler $ do + cid' <- encrypt sid return $ CSubmissionR tid ssh csh sheetName cid' CorrectionR mTuple mA mB = (,) <$> mA <*> mB -- Hamlet does not support enough haskell-syntax for this acell = anchorCellM mkRoute $(widgetFile "widgets/rating/rating") - in cellTell acell $ stats submissionRatingPoints + tellStats = do + r <- mkRoute + showRating <- hasReadAccessTo r + tell . stats $ bool Nothing submissionRatingPoints showRating + in acell & cellContents %~ (<* tellStats) , sortable Nothing -- (Just "percent") (i18nCell MsgRatingPercent) - $ \DBRow{dbrOutput=(Entity _ Sheet{sheetType=sType}, _, mbSub,_)} -> case mbSub of - (Just (Entity _ Submission{submissionRatingPoints=Just sPoints})) -> + $ \DBRow{dbrOutput=(Entity _ Sheet{sheetType=sType, sheetName}, _, mbSub,_)} -> case mbSub of + (Just (Entity sid Submission{submissionRatingPoints=Just sPoints})) -> case preview (_grading . _maxPoints) sType of Just maxPoints - | maxPoints /= 0 -> textCell $ textPercent sPoints maxPoints + | maxPoints /= 0 -> cell $ do + cID <- encrypt sid + showRating <- hasReadAccessTo $ CSubmissionR tid ssh csh sheetName cID CorrectionR + bool (return ()) (toWidget . toMessage $ textPercent sPoints maxPoints) showRating _other -> mempty _other -> mempty ]