diff --git a/messages/uniworx/de-de-formal.msg b/messages/uniworx/de-de-formal.msg index 4ad9b7456..190b73635 100644 --- a/messages/uniworx/de-de-formal.msg +++ b/messages/uniworx/de-de-formal.msg @@ -636,8 +636,8 @@ CorrectionTime: Korrekturdauer AssignSubmissionsRandomWarning: Die Zuteilungsvorschau kann von der tatsächlichen Zuteilung abweichen, wenn mehrere Blätter auf einmal zugeteilt werden, da beim Ausgleich der Kontigente nur bereits zugeteilte Abgaben berücksichtigt werden. Da es ein randomisierte Prozess ist, kann es auch bei einzelnen Blättern gerinfgügige Abweichungen geben. AssignSubmissionsAssignableSheets: Korrekturen verteilen für: -CorrectionsUploaded num@Int64: #{num} Korrekturen wurden gespeichert: -NoCorrectionsUploaded: In der hochgeladenen Datei wurden keine Korrekturen gefunden. +CorrectionsUploaded num@Int64: #{num} #{pluralDE num "Korrektur wurde" "Korrekturen wurden"} gespeichert +NoCorrectionsUploaded: In den hochgeladenen Dateien wurden keine Korrekturen gefunden. RatingBy: Korrigiert von HasCorrector: Korrektor zugeteilt @@ -2632,4 +2632,10 @@ RatingYAMLChangePointsComment: TODO: Hier die Punktezahl statt null eintragen (b RatingYAMLChangePassedComment: TODO: Hier true oder false statt null eintragen (true entspricht Bestanden) RatingYAMLChangeDoneComment: TODO: Von false auf true setzen, sobald Bewertung abgeschlossen; sonst Korrektur für die Studierenden nicht sichtbar und keine Anrechnung auf Klausurbonus RatingYAMLChangeCommentComment: TODO: Korrektur-Kommentar für die Studierenden unterhalb der Abtrennung (...) eintragen -RatingYAMLSubmissionIdComment: Abgabenummer; wird beim Hochladen mit dem Dateinamen abgeglichen \ No newline at end of file +RatingYAMLSubmissionIdComment: Abgabenummer; wird beim Hochladen mit dem Dateinamen abgeglichen + +SubmissionDoneNever: Nie +SubmissionDoneByFile: Je nach Bewertungsdatei +SubmissionDoneAlways: Immer +CorrUploadSubmissionDoneMode: Bewertung abgeschlossen +CorrUploadSubmissionDoneModeTip: Sollen hochgeladene Korrekturen als abgeschlossen markiert werden? Bewertungen sind erst für Studierende sichtbar und zählen gegen Examboni, wenn sie abgeschlossen sind. \ No newline at end of file diff --git a/messages/uniworx/en-eu.msg b/messages/uniworx/en-eu.msg index e5d84055d..7a37a0cae 100644 --- a/messages/uniworx/en-eu.msg +++ b/messages/uniworx/en-eu.msg @@ -634,8 +634,8 @@ CorrectionTime: Correction time AssignSubmissionsRandomWarning: The assignment preview might be different from the actual assignment if multiple sheets are being distributed. This is due to the fact that only assigned submissions are considered when handling corrector-deficits. Due to this being a randomised process small differences are also possible for a single sheet. AssignSubmissionsAssignableSheets: Distribute corrections for: -CorrectionsUploaded num: Successfully saved #{num} #{pluralEN num "correction" "corrections"}: -NoCorrectionsUploaded: No corrections could be found within the uploaded file. +CorrectionsUploaded num: Successfully saved #{num} #{pluralEN num "correction" "corrections"} +NoCorrectionsUploaded: No corrections could be found within the uploaded files. RatingBy: Marked by HasCorrector: Corrector assigned @@ -2633,3 +2633,9 @@ RatingYAMLChangePassedComment: TODO: Set true or false instead of null (true mea RatingYAMLChangeDoneComment: TODO: Set to true instead of false, when correction is finished; otherwise correction will not be visible to students and won't be counted for exam bonus RatingYAMLChangeCommentComment: TODO: Enter correction comment after the separator below (...) RatingYAMLSubmissionIdComment: Submission id; will be compared to the filename during upload + +SubmissionDoneNever: Never +SubmissionDoneByFile: According to correction file +SubmissionDoneAlways: Always +CorrUploadSubmissionDoneMode: Rating finished +CorrUploadSubmissionDoneModeTip: Should uploaded corrections be marked as finished? The rating is only visible to the submittors and considered for any exam bonuses if it is finished. diff --git a/routes b/routes index 374d94282..81e11801b 100644 --- a/routes +++ b/routes @@ -60,7 +60,7 @@ /health HealthR GET !free /instance InstanceR GET !free /info InfoR GET !free -/info/lecturer InfoLecturerR GET !lecturer +/info/lecturer InfoLecturerR GET !free /info/legal LegalR GET !free /info/allocation InfoAllocationR GET !free /info/glossary GlossaryR GET !free diff --git a/src/Foundation.hs b/src/Foundation.hs index f463eed7b..91d6e4ccc 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -2881,7 +2881,7 @@ defaultLinks = fmap catMaybes . mapM runMaybeT $ -- Define the menu items of the , NavLink { navLabel = MsgInfoLecturerTitle , navRoute = InfoLecturerR - , navAccess' = return True + , navAccess' = hasWriteAccessTo CourseNewR , navType = NavTypeLink { navModal = False } , navQuick' = mempty , navForceActive = False @@ -3206,7 +3206,7 @@ pageActions InfoR = return { navLink = NavLink { navLabel = MsgInfoLecturerTitle , navRoute = InfoLecturerR - , navAccess' = return True + , navAccess' = hasWriteAccessTo CourseNewR , navType = NavTypeLink { navModal = False } , navQuick' = mempty , navForceActive = False @@ -3252,7 +3252,7 @@ pageActions VersionR = return { navLink = NavLink { navLabel = MsgInfoLecturerTitle , navRoute = InfoLecturerR - , navAccess' = return True + , navAccess' = hasWriteAccessTo CourseNewR , navType = NavTypeLink { navModal = False } , navQuick' = mempty , navForceActive = False @@ -3335,7 +3335,7 @@ pageActions HelpR = return { navLink = NavLink { navLabel = MsgInfoLecturerTitle , navRoute = InfoLecturerR - , navAccess' = return True + , navAccess' = hasWriteAccessTo CourseNewR , navType = NavTypeLink { navModal = False } , navQuick' = mempty , navForceActive = False diff --git a/src/Handler/Submission/Upload.hs b/src/Handler/Submission/Upload.hs index 6884d97ad..baddb6d17 100644 --- a/src/Handler/Submission/Upload.hs +++ b/src/Handler/Submission/Upload.hs @@ -16,27 +16,57 @@ import Data.List (genericLength) import qualified Data.Conduit.List as C +data SubmissionDoneMode + = SubmissionDoneNever + | SubmissionDoneByFile + | SubmissionDoneAlways + deriving (Eq, Ord, Read, Show, Enum, Bounded, Generic, Typeable) + deriving anyclass (Universe, Finite) +nullaryPathPiece ''SubmissionDoneMode $ camelToPathPiece' 2 +embedRenderMessage ''UniWorX ''SubmissionDoneMode id + + +explainSubmissionDoneMode :: SubmissionDoneMode -> MaybeT Handler Widget +explainSubmissionDoneMode SubmissionDoneNever = return $(i18nWidgetFile "submission-done-tip/never") +explainSubmissionDoneMode SubmissionDoneAlways = return $(i18nWidgetFile "submission-done-tip/always") +explainSubmissionDoneMode SubmissionDoneByFile = return $(i18nWidgetFile "submission-done-tip/by-file") + + getCorrectionsUploadR, postCorrectionsUploadR :: Handler Html getCorrectionsUploadR = postCorrectionsUploadR postCorrectionsUploadR = do - ((uploadRes, upload), uploadEncoding) <- runFormPost . identifyForm FIDcorrectionsUpload . renderAForm FormStandard $ - areq (zipFileField True Nothing) (fslI MsgCorrUploadField) Nothing + ((uploadRes, upload), uploadEncoding) <- runFormPost . identifyForm FIDcorrectionsUpload . renderAForm FormStandard $ (,) + <$> areq (zipFileField True Nothing) (fslI MsgCorrUploadField) Nothing + <*> apopt (explainedSelectionField Nothing $ explainOptionList optionsFinite explainSubmissionDoneMode) (fslI MsgCorrUploadSubmissionDoneMode & setTooltip MsgCorrUploadSubmissionDoneModeTip) (Just SubmissionDoneByFile) - case uploadRes of - FormMissing -> return () - FormFailure errs -> mapM_ (addMessage Error . toHtml) errs - FormSuccess files -> do - uid <- requireAuthId - mbSubs <- msgSubmissionErrors . runDBJobs . runConduit $ transPipe (lift . lift) files .| C.mapM (either get404 return) .| extractRatingsMsg .| sinkMultiSubmission uid True - case mbSubs of - Nothing -> return () - (Just subs) - | null subs -> addMessageI Warning MsgNoCorrectionsUploaded - | otherwise -> do - subs' <- traverse (\x -> (,) <$> encrypt x <*> encrypt x) $ Set.toList subs :: Handler [(CryptoFileNameSubmission, CryptoUUIDSubmission)] - let trigger = [whamlet|_{MsgCorrectionsUploaded (genericLength subs')}|] - content = Right $(widgetFile "messages/correctionsUploaded") - addMessageModal Success trigger content + formResult uploadRes $ \(files, doneMode) -> do + let + setDone (Right (subId, rating)) + = Right ( subId + , rating & _ratingDone %~ setDone' + ) + where setDone' = case doneMode of + SubmissionDoneNever -> const False + SubmissionDoneByFile -> id + SubmissionDoneAlways -> const True + setDone other = other + + uid <- requireAuthId + mbSubs <- msgSubmissionErrors . runDBJobs . runConduit $ + transPipe (lift . lift) files + .| C.mapM (either get404 return) + .| extractRatingsMsg + .| C.map setDone + .| sinkMultiSubmission uid True + + forM_ mbSubs $ \subs -> if + | null subs -> addMessageI Warning MsgNoCorrectionsUploaded + | otherwise -> do + subs' <- traverse (\x -> (,) <$> encrypt x <*> encrypt x) $ Set.toList subs :: Handler [(CryptoFileNameSubmission, CryptoUUIDSubmission)] + let trigger = [whamlet|_{MsgCorrectionsUploaded (genericLength subs')}|] + content = Right $(widgetFile "messages/correctionsUploaded") + addMessageModal Success trigger content + redirect CorrectionsR let uploadForm = wrapForm upload def { formAction = Just $ SomeRoute CorrectionsUploadR diff --git a/src/Utils/Lens.hs b/src/Utils/Lens.hs index 6fe3c61a5..449ad431b 100644 --- a/src/Utils/Lens.hs +++ b/src/Utils/Lens.hs @@ -6,6 +6,7 @@ module Utils.Lens ( module Utils.Lens ) where import Import.NoModel import Model +import Model.Rating import qualified ClassyPrelude.Yesod as Yesod (HasHttpManager(..)) import Control.Lens as Utils.Lens @@ -230,6 +231,8 @@ makeLenses_ ''ExternalExam makeLenses_ ''ExternalExamOfficeSchool makeLenses_ ''ExternalExamStaff makeLenses_ ''ExternalExamResult + +makeLenses_ ''Rating' -- makeClassy_ ''Load diff --git a/templates/i18n/changelog/de-de-formal.hamlet b/templates/i18n/changelog/de-de-formal.hamlet index d99a07eff..d079ca5fa 100644 --- a/templates/i18n/changelog/de-de-formal.hamlet +++ b/templates/i18n/changelog/de-de-formal.hamlet @@ -1,5 +1,12 @@ $newline never
+
+ ^{formatGregorianW 2020 06 17} +
+