fix(correction-upload): better error messages wrt rating files
This commit is contained in:
parent
92a709125a
commit
8bb3bc50a2
@ -688,12 +688,14 @@ RatingNotExpected: Keine Bewertungen erlaubt
|
|||||||
RatingBinaryExpected: Bewertung muss 0 (=durchgefallen) oder 1 (=bestanden) sein
|
RatingBinaryExpected: Bewertung muss 0 (=durchgefallen) oder 1 (=bestanden) sein
|
||||||
RatingPointsRequired: Bewertung erfordert für dieses Blatt eine Punktzahl
|
RatingPointsRequired: Bewertung erfordert für dieses Blatt eine Punktzahl
|
||||||
RatingFile: Bewertungsdatei
|
RatingFile: Bewertungsdatei
|
||||||
|
RatingFileException file@FilePath ratingException@Text: Beim Verarbeiten von Bewertungsdatei „#{file}“ ist folgender Fehler aufgetreten: #{ratingException}
|
||||||
|
RatingSubmissionException smid@CryptoFileNameSubmission ratingException@Text: Beim Verarbeiten der Bewertungsdatei für Abgabe „#{toPathPiece smid}“ ist folgender Fehler aufgetreten: #{ratingException}
|
||||||
|
|
||||||
SubmissionSinkExceptionDuplicateFileTitle file@FilePath: Dateiname #{show file} kommt mehrfach im Zip-Archiv vor
|
SubmissionSinkExceptionDuplicateFileTitle file@FilePath: Dateiname #{file} kommt mehrfach im Zip-Archiv vor
|
||||||
SubmissionSinkExceptionDuplicateRating: Mehr als eine Bewertung gefunden.
|
SubmissionSinkExceptionDuplicateRating: Mehr als eine Bewertung gefunden.
|
||||||
SubmissionSinkExceptionRatingWithoutUpdate: Bewertung gefunden, es ist hier aber keine Bewertung der Abgabe möglich.
|
SubmissionSinkExceptionRatingWithoutUpdate: Bewertung gefunden, es ist hier aber keine Bewertung der Abgabe möglich.
|
||||||
SubmissionSinkExceptionForeignRating smid@CryptoFileNameSubmission: Fremde Bewertung für Abgabe #{toPathPiece smid} enthalten. Bewertungen müssen sich immer auf die gleiche Abgabe beziehen!
|
SubmissionSinkExceptionForeignRating smid@CryptoFileNameSubmission: Fremde Bewertung für Abgabe #{toPathPiece smid} enthalten. Bewertungen müssen sich immer auf die gleiche Abgabe beziehen!
|
||||||
SubmissionSinkExceptionInvalidFileTitleExtension file@FilePath: Dateiname „#{show file}“ hat keine der für dieses Übungsblatt zulässigen Dateiendungen.
|
SubmissionSinkExceptionInvalidFileTitleExtension file@FilePath: Dateiname „#{file}“ hat keine der für dieses Übungsblatt zulässigen Dateiendungen.
|
||||||
|
|
||||||
MultiSinkException name@Text error@Text: In Abgabe „#{name}“ ist ein Fehler aufgetreten: #{error}
|
MultiSinkException name@Text error@Text: In Abgabe „#{name}“ ist ein Fehler aufgetreten: #{error}
|
||||||
|
|
||||||
|
|||||||
@ -685,6 +685,8 @@ RatingNotExpected: No marking points expected for this sheet
|
|||||||
RatingBinaryExpected: Marking must be 0 (=failed) or 1(=passed)
|
RatingBinaryExpected: Marking must be 0 (=failed) or 1(=passed)
|
||||||
RatingPointsRequired: Marking points required for this sheet
|
RatingPointsRequired: Marking points required for this sheet
|
||||||
RatingFile: Marking file
|
RatingFile: Marking file
|
||||||
|
RatingFileException file ratingException: While processing the rating file “#{file}” the following error occurred: #{ratingException}
|
||||||
|
RatingSubmissionException smid ratingException: While processing the rating file for the submission “#{toPathPiece smid}” the following error occurred: #{ratingException}
|
||||||
|
|
||||||
SubmissionSinkExceptionDuplicateFileTitle file: File #{show file} occurs multiple files within zip-archive.
|
SubmissionSinkExceptionDuplicateFileTitle file: File #{show file} occurs multiple files within zip-archive.
|
||||||
SubmissionSinkExceptionDuplicateRating: Found more than one marking file
|
SubmissionSinkExceptionDuplicateRating: Found more than one marking file
|
||||||
|
|||||||
@ -205,6 +205,14 @@ embedRenderMessage ''UniWorX ''ExamGradingMode id
|
|||||||
|
|
||||||
embedRenderMessage ''UniWorX ''AuthenticationMode id
|
embedRenderMessage ''UniWorX ''AuthenticationMode id
|
||||||
|
|
||||||
|
instance RenderMessage UniWorX RatingFileException where
|
||||||
|
renderMessage foundation ls = \case
|
||||||
|
RatingFileException{..} -> mr . MsgRatingFileException ratingExceptionFile $ mr ratingException
|
||||||
|
RatingSubmissionException{..} -> mr . MsgRatingSubmissionException ratingExceptionSubmission $ mr ratingException
|
||||||
|
where
|
||||||
|
mr :: RenderMessage UniWorX msg => msg -> Text
|
||||||
|
mr = renderMessage foundation ls
|
||||||
|
|
||||||
newtype ShortSex = ShortSex Sex
|
newtype ShortSex = ShortSex Sex
|
||||||
embedRenderMessageVariant ''UniWorX ''ShortSex ("Short" <>)
|
embedRenderMessageVariant ''UniWorX ''ShortSex ("Short" <>)
|
||||||
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ extractRatings = Conduit.mapM $ \f@File{..} -> do
|
|||||||
case () of
|
case () of
|
||||||
_ | Just sId <- msId
|
_ | Just sId <- msId
|
||||||
, isJust fileContent
|
, isJust fileContent
|
||||||
-> Right . (sId, ) <$> parseRating f
|
-> handle (throwM . RatingFileException fileTitle) $ Right . (sId, ) <$> parseRating f
|
||||||
| otherwise -> return $ Left f
|
| otherwise -> return $ Left f
|
||||||
|
|
||||||
isRatingFile :: ( MonadHandler m
|
isRatingFile :: ( MonadHandler m
|
||||||
|
|||||||
@ -436,7 +436,7 @@ extractRatingsMsg = do
|
|||||||
-- | Nicht innerhalb von runDB aufrufen, damit das DB Rollback passieren kann!
|
-- | Nicht innerhalb von runDB aufrufen, damit das DB Rollback passieren kann!
|
||||||
msgSubmissionErrors :: (MonadHandler m, MonadCatch m, HandlerSite m ~ UniWorX) => m a -> m (Maybe a)
|
msgSubmissionErrors :: (MonadHandler m, MonadCatch m, HandlerSite m ~ UniWorX) => m a -> m (Maybe a)
|
||||||
msgSubmissionErrors = flip catches
|
msgSubmissionErrors = flip catches
|
||||||
[ E.Handler $ \e -> Nothing <$ addMessageI Error (e :: RatingException)
|
[ E.Handler $ \e -> Nothing <$ addMessageI Error (e :: RatingFileException)
|
||||||
, E.Handler $ \e -> Nothing <$ addMessageI Error (e :: SubmissionSinkException)
|
, E.Handler $ \e -> Nothing <$ addMessageI Error (e :: SubmissionSinkException)
|
||||||
, E.Handler $ \(SubmissionSinkException sinkId _ sinkEx) -> do
|
, E.Handler $ \(SubmissionSinkException sinkId _ sinkEx) -> do
|
||||||
mr <- getMessageRender
|
mr <- getMessageRender
|
||||||
@ -552,9 +552,9 @@ sinkSubmission userId mExists isUpdate = do
|
|||||||
|
|
||||||
Right (submissionId', r) -> do
|
Right (submissionId', r) -> do
|
||||||
$logDebugS "sinkSubmission" $ tshow submissionId'
|
$logDebugS "sinkSubmission" $ tshow submissionId'
|
||||||
|
cID <- encrypt submissionId'
|
||||||
|
|
||||||
unless (submissionId' == submissionId) $ do
|
unless (submissionId' == submissionId) $
|
||||||
cID <- encrypt submissionId'
|
|
||||||
throwM $ ForeignRating cID
|
throwM $ ForeignRating cID
|
||||||
|
|
||||||
alreadySeen <- gets $ is (_Wrapped . _Just) . sinkSeenRating
|
alreadySeen <- gets $ is (_Wrapped . _Just) . sinkSeenRating
|
||||||
@ -594,7 +594,7 @@ sinkSubmission userId mExists isUpdate = do
|
|||||||
|
|
||||||
Sheet{..} <- lift . getJust $ submissionSheet submission'
|
Sheet{..} <- lift . getJust $ submissionSheet submission'
|
||||||
|
|
||||||
mapM_ throwM $ validateRating sheetType r'
|
mapM_ (throwM . RatingSubmissionException cID) $ validateRating sheetType r'
|
||||||
|
|
||||||
when (submissionRatingDone submission' && not (submissionRatingDone submission)) $
|
when (submissionRatingDone submission' && not (submissionRatingDone submission)) $
|
||||||
tellSt mempty { sinkSubmissionNotifyRating = Any True }
|
tellSt mempty { sinkSubmissionNotifyRating = Any True }
|
||||||
|
|||||||
@ -2,6 +2,7 @@ module Model.Rating where
|
|||||||
|
|
||||||
import ClassyPrelude.Yesod
|
import ClassyPrelude.Yesod
|
||||||
import Model
|
import Model
|
||||||
|
import CryptoID
|
||||||
-- import Data.Text (Text)
|
-- import Data.Text (Text)
|
||||||
import Data.Text.Encoding.Error (UnicodeException(..))
|
import Data.Text.Encoding.Error (UnicodeException(..))
|
||||||
|
|
||||||
@ -31,5 +32,16 @@ data RatingException = RatingNotUnicode UnicodeException -- ^ Rating failed to p
|
|||||||
| RatingBinaryExpected -- ^ Rating must be 0 or 1
|
| RatingBinaryExpected -- ^ Rating must be 0 or 1
|
||||||
| RatingPointsRequired -- ^ Rating without points for sheet that requires there to be points
|
| RatingPointsRequired -- ^ Rating without points for sheet that requires there to be points
|
||||||
deriving (Show, Eq, Generic, Typeable)
|
deriving (Show, Eq, Generic, Typeable)
|
||||||
|
deriving anyclass (Exception)
|
||||||
|
|
||||||
instance Exception RatingException
|
data RatingFileException
|
||||||
|
= RatingFileException
|
||||||
|
{ ratingExceptionFile :: FilePath
|
||||||
|
, ratingException :: RatingException
|
||||||
|
}
|
||||||
|
| RatingSubmissionException
|
||||||
|
{ ratingExceptionSubmission :: CryptoFileNameSubmission
|
||||||
|
, ratingException :: RatingException
|
||||||
|
}
|
||||||
|
deriving (Show, Eq, Generic, Typeable)
|
||||||
|
deriving anyclass (Exception)
|
||||||
|
|||||||
Reference in New Issue
Block a user