From 880eb3b1ad2d5e4b12f767eb68d29eabfbd79e17 Mon Sep 17 00:00:00 2001 From: Luca Maio Date: Mon, 7 Feb 2022 17:40:03 +0100 Subject: [PATCH 1/4] feat(submissions): add option 'Set corrections as done' --- .../courses/submission/de-de-formal.msg | 5 +++- .../categories/courses/submission/en-eu.msg | 3 +++ src/Handler/Submission/List.hs | 27 +++++++++++++++++++ testdata/workflows | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/messages/uniworx/categories/courses/submission/de-de-formal.msg b/messages/uniworx/categories/courses/submission/de-de-formal.msg index f2eedb946..cfe78750e 100644 --- a/messages/uniworx/categories/courses/submission/de-de-formal.msg +++ b/messages/uniworx/categories/courses/submission/de-de-formal.msg @@ -159,6 +159,9 @@ SubmissionDownloadMatriculations: Mit Matrikelnummern SubmissionDownloadGroups: Mit festen Abgabegruppen CorrAutoSetCorrector: Korrekturen verteilen CorrDelete: Abgaben löschen +CorrSetCorrectionsDone: Korrekturen als abgeschlossen markieren +SetCorrectionsDoneTrue: Korrekturen als abgeschlossen markiert +SetCorrectionsDoneFalse: Korrekturen als nicht abgeschlossen markiert SubmissionCorrected: Korrigiert CorrectionSheets: Übersicht Korrekturen nach Blättern CorrectionCorrectors: Übersicht Korrekturen nach Korrektor:innen @@ -262,4 +265,4 @@ CorrectionTableCsvSheetNameCourseCorrections tid@TermId ssh@SchoolId csh@CourseS CorrectionTableCsvNameCorrections: abgaben CorrectionTableCsvSheetNameCorrections: Abgaben CorrectionTableCsvNameCourseUserCorrections tid@TermId ssh@SchoolId csh@CourseShorthand displayName@Text: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)}-#{foldedCase csh}-#{foldCase displayName}-abgaben -CorrectionTableCsvSheetNameCourseUserCorrections tid@TermId ssh@SchoolId csh@CourseShorthand displayName@Text: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)}-#{foldedCase csh}-#{foldCase displayName} Abgaben \ No newline at end of file +CorrectionTableCsvSheetNameCourseUserCorrections tid@TermId ssh@SchoolId csh@CourseShorthand displayName@Text: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)}-#{foldedCase csh}-#{foldCase displayName} Abgaben diff --git a/messages/uniworx/categories/courses/submission/en-eu.msg b/messages/uniworx/categories/courses/submission/en-eu.msg index 2d0ffb872..7326ed4af 100644 --- a/messages/uniworx/categories/courses/submission/en-eu.msg +++ b/messages/uniworx/categories/courses/submission/en-eu.msg @@ -159,6 +159,9 @@ SubmissionDownloadMatriculations: With matriculation numbers SubmissionDownloadGroups: With registered submission groups CorrAutoSetCorrector: Distribute corrections CorrDelete: Delete submissions +CorrSetCorrectionsDone: Set corrections as done +SetCorrectionsDoneTrue: Set corrections as done +SetCorrectionsDoneFalse: Set corrections as not done SubmissionCorrected: Marked CorrectionSheets: Corrections by sheet CorrectionCorrectors: Corrections by corrector diff --git a/src/Handler/Submission/List.hs b/src/Handler/Submission/List.hs index 66d1c11b0..533d534ca 100644 --- a/src/Handler/Submission/List.hs +++ b/src/Handler/Submission/List.hs @@ -781,6 +781,7 @@ makeCorrectionsTable whereClause dbtColonnade dbtFilterUI' mCSVSettings psValida data ActionCorrections = CorrDownload | CorrSetCorrector | CorrAutoSetCorrector + | CorrSetCorrectionsDone | CorrDelete deriving (Eq, Ord, Read, Show, Enum, Bounded) @@ -793,6 +794,7 @@ embedRenderMessage ''UniWorX ''ActionCorrections id data ActionCorrectionsData = CorrDownloadData SubmissionDownloadAnonymous SubmissionFileType | CorrSetCorrectorData (Maybe UserId) | CorrAutoSetCorrectorData SheetId + | CorrSetCorrectionsDoneData Bool | CorrDeleteData correctionsR :: CorrectionTableWhere -> _ -> _ -> Maybe CorrectionTableCsvSettings -> _ -> Map ActionCorrections (AForm (HandlerFor UniWorX) ActionCorrectionsData) -> Handler TypedContent @@ -927,6 +929,23 @@ correctionsR' whereClause displayColumns dbtFilterUI csvSettings psValidator act unassigned' <- forM (Set.toList stillUnassigned) $ \sid -> encrypt sid :: DB CryptoFileNameSubmission addMessage Warning =<< withUrlRenderer ($(ihamletFile "templates/messages/submissionsNotAssignedAuto.hamlet") mr) redirect currentRoute + (CorrSetCorrectionsDoneData True, subs') -> do + subs <- mapM decrypt $ Set.toList subs' + now <- liftIO getCurrentTime + runDB $ do + _ <- updateWhere [SubmissionId <-. subs] + [SubmissionRatingTime =. Just now] + addMessageI Success $ MsgSetCorrectionsDoneTrue + auditAllSubEdit subs + redirect currentRoute + (CorrSetCorrectionsDoneData False, subs') -> do + subs <- mapM decrypt $ Set.toList subs' + runDB $ do + _ <- updateWhere [SubmissionId <-. subs] + [SubmissionRatingTime =. Nothing] + addMessageI Success $ MsgSetCorrectionsDoneFalse + auditAllSubEdit subs + redirect currentRoute (CorrDeleteData, subs) -> do subs' <- Set.fromList <$> forM (Set.toList subs) decrypt -- Set is not traversable getDeleteR (submissionDeleteRoute subs') @@ -997,6 +1016,12 @@ assignAction selId = ( CorrSetCorrector fmap CorrSetCorrectorData <$> (traverse.traverse) decrypt cId ) +setCorrectionsDoneAction :: ActionCorrections' +setCorrectionsDoneAction = ( CorrSetCorrectionsDone + , CorrSetCorrectionsDoneData + <$> apopt checkBoxField (fslI MsgCorrSetCorrectionsDone) (Just True) + ) + autoAssignAction :: SheetId -> ActionCorrections' autoAssignAction shid = ( CorrAutoSetCorrector , pure $ CorrAutoSetCorrectorData shid @@ -1109,6 +1134,7 @@ postCCorrectionsR tid ssh csh = do correctionsR whereClause colonnade filterUI csvSettings psValidator $ Map.fromList [ downloadAction , assignAction (Left cid) + , setCorrectionsDoneAction , deleteAction ] @@ -1157,5 +1183,6 @@ postSSubsR tid ssh csh shn = do [ downloadAction , assignAction (Right shid) , autoAssignAction shid + , setCorrectionsDoneAction , deleteAction ] diff --git a/testdata/workflows b/testdata/workflows index d567d2957..1a788c67f 160000 --- a/testdata/workflows +++ b/testdata/workflows @@ -1 +1 @@ -Subproject commit d567d2957cd2a53fb79d2b60e650236509ffe726 +Subproject commit 1a788c67fe98cadf1e29b0e328072437955fd660 From 2f1ecd397936f4e4ac018eb4f9aaf49da37e1e81 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Mon, 7 Feb 2022 20:26:21 +0100 Subject: [PATCH 2/4] feat(submissions): Apply suggestions to reduce lines of code --- .../categories/courses/submission/de-de-formal.msg | 3 +-- .../categories/courses/submission/en-eu.msg | 3 +-- src/Handler/Submission/List.hs | 14 +++----------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/messages/uniworx/categories/courses/submission/de-de-formal.msg b/messages/uniworx/categories/courses/submission/de-de-formal.msg index cfe78750e..7a08fde97 100644 --- a/messages/uniworx/categories/courses/submission/de-de-formal.msg +++ b/messages/uniworx/categories/courses/submission/de-de-formal.msg @@ -160,8 +160,7 @@ SubmissionDownloadGroups: Mit festen Abgabegruppen CorrAutoSetCorrector: Korrekturen verteilen CorrDelete: Abgaben löschen CorrSetCorrectionsDone: Korrekturen als abgeschlossen markieren -SetCorrectionsDoneTrue: Korrekturen als abgeschlossen markiert -SetCorrectionsDoneFalse: Korrekturen als nicht abgeschlossen markiert +SetCorrectionsDone b@Bool: Korrekturen als #{bool "nicht" "" b} abgeschlossen markiert SubmissionCorrected: Korrigiert CorrectionSheets: Übersicht Korrekturen nach Blättern CorrectionCorrectors: Übersicht Korrekturen nach Korrektor:innen diff --git a/messages/uniworx/categories/courses/submission/en-eu.msg b/messages/uniworx/categories/courses/submission/en-eu.msg index 7326ed4af..bc0585cf8 100644 --- a/messages/uniworx/categories/courses/submission/en-eu.msg +++ b/messages/uniworx/categories/courses/submission/en-eu.msg @@ -160,8 +160,7 @@ SubmissionDownloadGroups: With registered submission groups CorrAutoSetCorrector: Distribute corrections CorrDelete: Delete submissions CorrSetCorrectionsDone: Set corrections as done -SetCorrectionsDoneTrue: Set corrections as done -SetCorrectionsDoneFalse: Set corrections as not done +SetCorrectionsDone b: Set corrections as #{bool "not" "" b} done SubmissionCorrected: Marked CorrectionSheets: Corrections by sheet CorrectionCorrectors: Corrections by corrector diff --git a/src/Handler/Submission/List.hs b/src/Handler/Submission/List.hs index 533d534ca..403564d01 100644 --- a/src/Handler/Submission/List.hs +++ b/src/Handler/Submission/List.hs @@ -929,21 +929,13 @@ correctionsR' whereClause displayColumns dbtFilterUI csvSettings psValidator act unassigned' <- forM (Set.toList stillUnassigned) $ \sid -> encrypt sid :: DB CryptoFileNameSubmission addMessage Warning =<< withUrlRenderer ($(ihamletFile "templates/messages/submissionsNotAssignedAuto.hamlet") mr) redirect currentRoute - (CorrSetCorrectionsDoneData True, subs') -> do - subs <- mapM decrypt $ Set.toList subs' + (CorrSetCorrectionsDoneData isDone, subs') -> do now <- liftIO getCurrentTime - runDB $ do - _ <- updateWhere [SubmissionId <-. subs] - [SubmissionRatingTime =. Just now] - addMessageI Success $ MsgSetCorrectionsDoneTrue - auditAllSubEdit subs - redirect currentRoute - (CorrSetCorrectionsDoneData False, subs') -> do subs <- mapM decrypt $ Set.toList subs' runDB $ do _ <- updateWhere [SubmissionId <-. subs] - [SubmissionRatingTime =. Nothing] - addMessageI Success $ MsgSetCorrectionsDoneFalse + [SubmissionRatingTime =. bool Nothing (Just now) isDone] + addMessageI Success $ MsgSetCorrectionsDone isDone auditAllSubEdit subs redirect currentRoute (CorrDeleteData, subs) -> do From d02e203f91d39ae1564794f5980cb5e588917608 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Mon, 7 Feb 2022 20:33:38 +0100 Subject: [PATCH 3/4] chore: update contributors --- templates/i18n/implementation/de-de-formal.hamlet | 1 + templates/i18n/implementation/en-eu.hamlet | 1 + 2 files changed, 2 insertions(+) diff --git a/templates/i18n/implementation/de-de-formal.hamlet b/templates/i18n/implementation/de-de-formal.hamlet index 7aa374f83..e2430d142 100644 --- a/templates/i18n/implementation/de-de-formal.hamlet +++ b/templates/i18n/implementation/de-de-formal.hamlet @@ -30,6 +30,7 @@ $newline never
  • Felix Hamann (Frontend)
  • Steffen Jost
  • Gregor Kleen +
  • Luca Maio
  • Winnie Ros
  • Sarah Vaupel
  • Wolfgang Witt diff --git a/templates/i18n/implementation/en-eu.hamlet b/templates/i18n/implementation/en-eu.hamlet index 44645e86b..e88ef7168 100644 --- a/templates/i18n/implementation/en-eu.hamlet +++ b/templates/i18n/implementation/en-eu.hamlet @@ -29,6 +29,7 @@ $newline never
  • Felix Hamann (Frontend)
  • Steffen Jost
  • Gregor Kleen +
  • Luca Maio
  • Winnie Ros
  • Sarah Vaupel
  • Wolfgang Witt From ae66fdfb8aa51cd7f6e6ad4e263e52cd7043abcb Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Mon, 7 Feb 2022 23:03:19 +0100 Subject: [PATCH 4/4] fix(submissions): notDE, notEN for unambiguous negation --- .../uniworx/categories/courses/submission/de-de-formal.msg | 2 +- messages/uniworx/categories/courses/submission/en-eu.msg | 2 +- src/Foundation/I18n.hs | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/messages/uniworx/categories/courses/submission/de-de-formal.msg b/messages/uniworx/categories/courses/submission/de-de-formal.msg index 7a08fde97..a9a224b43 100644 --- a/messages/uniworx/categories/courses/submission/de-de-formal.msg +++ b/messages/uniworx/categories/courses/submission/de-de-formal.msg @@ -160,7 +160,7 @@ SubmissionDownloadGroups: Mit festen Abgabegruppen CorrAutoSetCorrector: Korrekturen verteilen CorrDelete: Abgaben löschen CorrSetCorrectionsDone: Korrekturen als abgeschlossen markieren -SetCorrectionsDone b@Bool: Korrekturen als #{bool "nicht" "" b} abgeschlossen markiert +SetCorrectionsDone b@Bool: Korrekturen als #{notDE b} abgeschlossen markiert SubmissionCorrected: Korrigiert CorrectionSheets: Übersicht Korrekturen nach Blättern CorrectionCorrectors: Übersicht Korrekturen nach Korrektor:innen diff --git a/messages/uniworx/categories/courses/submission/en-eu.msg b/messages/uniworx/categories/courses/submission/en-eu.msg index bc0585cf8..11164c7b0 100644 --- a/messages/uniworx/categories/courses/submission/en-eu.msg +++ b/messages/uniworx/categories/courses/submission/en-eu.msg @@ -160,7 +160,7 @@ SubmissionDownloadGroups: With registered submission groups CorrAutoSetCorrector: Distribute corrections CorrDelete: Delete submissions CorrSetCorrectionsDone: Set corrections as done -SetCorrectionsDone b: Set corrections as #{bool "not" "" b} done +SetCorrectionsDone b: Set corrections as #{notEN b} done SubmissionCorrected: Marked CorrectionSheets: Corrections by sheet CorrectionCorrectors: Corrections by corrector diff --git a/src/Foundation/I18n.hs b/src/Foundation/I18n.hs index fa357c6f8..8faf5a2bd 100644 --- a/src/Foundation/I18n.hs +++ b/src/Foundation/I18n.hs @@ -142,6 +142,11 @@ ordinalEN (toMessage -> numStr) = case lastChar of where lastChar = last <$> fromNullable numStr +notDE :: Bool -> Text +notDE = bool "nicht" "" + +notEN :: Bool -> Text +notEN = bool "not" "" -- | Convenience function for i18n messages definitions maybeToMessage :: ToMessage m => Text -> Maybe m -> Text -> Text