diff --git a/messages/uniworx/categories/courses/exam/exam_office/de-de-formal.msg b/messages/uniworx/categories/courses/exam/exam_office/de-de-formal.msg index ee5a84a00..39d033ade 100644 --- a/messages/uniworx/categories/courses/exam/exam_office/de-de-formal.msg +++ b/messages/uniworx/categories/courses/exam/exam_office/de-de-formal.msg @@ -55,3 +55,6 @@ ExamOfficeFieldSubscribed: Abboniert UtilExamClosed: Noten gemeldet ExamFinishedOffice: Noten bekannt gegeben ExamOfficeFieldForced: Forcierte Einsicht + +ExamOfficeGetSynced: Synchronisiert-Status in Prüfungsliste anzeigen +ExamOfficeGetSyncedTip: Soll unter „Prüfungen“ der Synchronisiert-Status zu jeder Prüfung angezeigt werden? (Ein Deaktivieren dieser Option kann zu kürzeren Ladezeiten der Prüfungsliste führen.) diff --git a/messages/uniworx/categories/courses/exam/exam_office/en-eu.msg b/messages/uniworx/categories/courses/exam/exam_office/en-eu.msg index 99ccc888c..b8cd4743e 100644 --- a/messages/uniworx/categories/courses/exam/exam_office/en-eu.msg +++ b/messages/uniworx/categories/courses/exam/exam_office/en-eu.msg @@ -53,3 +53,6 @@ ExamOfficeFieldSubscribed: subscribed UtilExamClosed: Exam achievements registered ExamFinishedOffice: Exam achievements published ExamOfficeFieldForced: Forced access + +ExamOfficeGetSynced: Show synchronised status in exam list +ExamOfficeGetSyncedTip: Should the synchronised status be displayed in “Exams”? (Disabling this option may lead to shorter loading times of the exam list.) diff --git a/messages/uniworx/categories/settings/de-de-formal.msg b/messages/uniworx/categories/settings/de-de-formal.msg index 1c92b705e..9f45045b0 100644 --- a/messages/uniworx/categories/settings/de-de-formal.msg +++ b/messages/uniworx/categories/settings/de-de-formal.msg @@ -112,3 +112,5 @@ AllocNotifyNewCourseDefault: Systemweite Einstellung AllocNotifyNewCourseForceOff: Nein AllocNotifyNewCourseForceOn: Ja Settings: Individuelle Benutzereinstellungen + +FormExamOffice: Prüfungsverwaltung diff --git a/messages/uniworx/categories/settings/en-eu.msg b/messages/uniworx/categories/settings/en-eu.msg index fe8374754..d94b9b7cc 100644 --- a/messages/uniworx/categories/settings/en-eu.msg +++ b/messages/uniworx/categories/settings/en-eu.msg @@ -112,4 +112,6 @@ LanguageChanged: Language changed successfully AllocNotifyNewCourseDefault: System-wide setting AllocNotifyNewCourseForceOff: No AllocNotifyNewCourseForceOn: Yes -Settings: Settings \ No newline at end of file +Settings: Settings + +FormExamOffice: Exam Office \ No newline at end of file diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index 9b7dc1ee0..4a9e12dea 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -43,6 +43,7 @@ data SettingsForm = SettingsForm , stgDownloadFiles :: Bool , stgWarningDays :: NominalDiffTime , stgShowSex :: Bool + , stgExamOfficeSettings :: ExamOfficeSettings , stgSchools :: Set SchoolId , stgNotificationSettings :: NotificationSettings , stgAllocationNotificationSettings :: Map AllocationId (Maybe Bool) @@ -115,6 +116,7 @@ makeSettingForm template html = do & setTooltip MsgWarningDaysTip ) (stgWarningDays <$> template) <*> apopt checkBoxField (fslI MsgShowSex & setTooltip MsgShowSexTip) (stgShowSex <$> template) + <*> examOfficeForm (stgExamOfficeSettings <$> template) <* aformSection MsgFormNotifications <*> schoolsForm (stgSchools <$> template) <*> notificationForm (stgNotificationSettings <$> template) @@ -310,6 +312,16 @@ allocationNotificationForm = maybe (pure mempty) allocationNotificationForm' . ( fmap (review _AllocNotify) <$> wpopt (radioGroupField Nothing optionsFinite) (fsl allocDesc & addName [st|alloc-notify__#{toPathPiece cID}|]) (Just $ mPrev ^. _AllocNotify) where funcForm' forms = funcForm forms (fslI MsgFormAllocationNotifications & setTooltip MsgFormAllocationNotificationsTip) False +examOfficeForm :: Maybe ExamOfficeSettings -> AForm Handler ExamOfficeSettings +examOfficeForm template = wFormToAForm $ do + (_uid, User{userExamOfficeGetSynced}) <- requireAuthPair + userIsExamOffice <- liftHandler . hasReadAccessTo $ ExamOfficeR EOExamsR + if userIsExamOffice + then aFormToWForm . fmap ExamOfficeSettings $ + aformSection MsgFormExamOffice + *> apopt checkBoxField (fslI MsgExamOfficeGetSynced & setTooltip MsgExamOfficeGetSyncedTip) (eosettingsGetSynced <$> template) + else return . pure . fromMaybe (ExamOfficeSettings userExamOfficeGetSynced) $ template + validateSettings :: User -> FormValidator SettingsForm Handler () validateSettings User{..} = do @@ -363,6 +375,9 @@ postProfileR = do , stgNotificationSettings = userNotificationSettings , stgWarningDays = userWarningDays , stgShowSex = userShowSex + , stgExamOfficeSettings = ExamOfficeSettings + { eosettingsGetSynced = userExamOfficeGetSynced + } , stgAllocationNotificationSettings = allocs } ((res,formWidget), formEnctype) <- runFormPost . validateForm (validateSettings user) . identifyForm ProfileSettings $ makeSettingForm settingsTemplate @@ -381,6 +396,7 @@ postProfileR = do , UserWarningDays =. stgWarningDays , UserNotificationSettings =. stgNotificationSettings , UserShowSex =. stgShowSex + , UserExamOfficeGetSynced =. (stgExamOfficeSettings & eosettingsGetSynced) ] ++ [ UserDisplayEmail =. stgDisplayEmail | userDisplayEmail == stgDisplayEmail ] setAllocationNotifications uid stgAllocationNotificationSettings updateFavourites Nothing diff --git a/src/Handler/Utils/Profile.hs b/src/Handler/Utils/Profile.hs index ca272d6b8..95fe228cb 100644 --- a/src/Handler/Utils/Profile.hs +++ b/src/Handler/Utils/Profile.hs @@ -1,5 +1,6 @@ module Handler.Utils.Profile ( validDisplayName + , ExamOfficeSettings(..) ) where import Import.NoFoundation @@ -33,3 +34,9 @@ validDisplayName (fmap Text.strip -> mTitle) (Text.strip -> fName) (Text.strip - sNameLetters = Set.fromList $ unpack sName dNameLetters = Set.fromList $ unpack dName addLetters = Set.fromList [' '] + + +newtype ExamOfficeSettings + = ExamOfficeSettings + { eosettingsGetSynced :: Bool + }