From 7192cb527c7f66c320308a80de9906a6edc6e9ec Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Sat, 19 Jun 2021 12:31:14 +0200 Subject: [PATCH] fix(sheets): fixhance sheet authship form section --- .../categories/courses/sheet/de-de-formal.msg | 1 + .../categories/courses/sheet/en-eu.msg | 1 + src/Handler/Sheet/Form.hs | 49 +++++++++---------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/messages/uniworx/categories/courses/sheet/de-de-formal.msg b/messages/uniworx/categories/courses/sheet/de-de-formal.msg index e7a8b11a6..ff8357d8f 100644 --- a/messages/uniworx/categories/courses/sheet/de-de-formal.msg +++ b/messages/uniworx/categories/courses/sheet/de-de-formal.msg @@ -157,4 +157,5 @@ SheetAuthorshipStatementRequired: Eigenständigkeitserklärung für Übungsblatt SheetAuthorshipStatementRequiredTip: Sollen die Abgebenden (bei Abgabegruppen jedes Gruppenmitglied) aufgefordert werden, eine Eigenständigkeitserklärung zu akzeptieren? SheetAuthorshipStatementRequiredForcedTip: Für dieses Institut sind Eigenständigkeitserklärungen für nicht-prüfungszugehörige Übungsblätter vorgeschrieben. SheetAuthorshipStatementContent: Eigenständigkeitserklärung +SheetAuthorshipStatementContentForcedTip: Für dieses Institut ist die institutsweit vorgegebene Eigenständigkeitserklärung für nicht-prüfungszugehörige Übungsblätter zu verwenden. Benutzerdefinierte Erklärungen sind nicht gestattet. SheetAuthorshipStatementContentOverridesExamTip: Gehört dieses Übungsblatt zu einer Prüfung mit einer prüfungsweit eingestellten Eigenständigkeitserklärung, so können Sie hier eine für dieses Übungsblatt abweichende Eigenständigkeitserklärung angeben. diff --git a/messages/uniworx/categories/courses/sheet/en-eu.msg b/messages/uniworx/categories/courses/sheet/en-eu.msg index d72478c60..aec230fd4 100644 --- a/messages/uniworx/categories/courses/sheet/en-eu.msg +++ b/messages/uniworx/categories/courses/sheet/en-eu.msg @@ -156,4 +156,5 @@ SheetAuthorshipStatementRequired: Require Statement of Authorship for submission SheetAuthorshipStatementRequiredTip: Should submittors (each group member in case of submission groups) be required to accept a Statement of Authorship? SheetAuthorshipStatementRequiredForcedTip: This school enforces Statements of Authorship for all exam-unrelated exercise sheets. SheetAuthorshipStatementContent: Statement of Authorship +SheetAuthorshipStatementContentForcedTip: The settings of this school dictate that the school-wide Statement of Authorship for exam-unrelated sheets must be used. Custom statements are prohibited. SheetAuthorshipStatementContentOverridesExamTip: If this exercise sheet is related to an exam with an exam-wide Statement of Authorship set, a sheet-specific adaptation can be given here. diff --git a/src/Handler/Sheet/Form.hs b/src/Handler/Sheet/Form.hs index f5b94480e..28fac1d1f 100644 --- a/src/Handler/Sheet/Form.hs +++ b/src/Handler/Sheet/Form.hs @@ -66,7 +66,7 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS (Just sId) -> liftHandler $ runDB $ getFtIdMap sId MsgRenderer mr <- getMsgRenderer ctime <- ceilingQuarterHour <$> liftIO getCurrentTime - ((_school, _mSchoolAuthorshipStatement), _course) <- liftHandler . runDB $ do + ((School{..}, mSchoolAuthorshipStatement), _course) <- liftHandler . runDB $ do course@Course{courseSchool} <- get404 cId school@School{..} <- get404 courseSchool mSchoolAuthorshipStatement <- runMaybeT $ do @@ -105,31 +105,28 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS <*> aopt htmlField (fslI MsgSheetMarking) (sfMarkingText <$> template) <*> apopt checkBoxField (fslI MsgSheetAnonymousCorrection & setTooltip MsgSheetAnonymousCorrectionTip) (sfAnonymousCorrection <$> template) <*> correctorForm (maybe mempty sfCorrectors template) - <* aformSection MsgSheetAuthorshipStatementSection - -- TODO: add info: applies to exam-unrelated sheets and overrides exam definition if sheet is related to an exam and this exam has an authorship statement - -- TODO: compare versions: school > msId if school statement is newer than msId statement, msId > school otherwise (TODO: add lastEdited to model) - <*> pure Nothing -- TODO - -- <*> optionalActionA - -- ( areq htmlField - -- (fslI MsgSheetAuthorshipStatementContent) - -- ( - -- -- TODO: select correct school settings wrt. exam-related/exam-unrelated - -- -- TODO: if school enforces school-wide statement, take school-wide statement - -- -- TODO: otherwise, take value from template, or take exam-wide statement if there is any, or take the school default if there is any - -- (fromMaybe mempty $ sfAuthorshipStatement <$> template <|> (Just . authorshipStatementDefinitionContent . entityVal) <$> mSchoolAuthorshipStatement) - -- ) - -- ) - -- ( fslI MsgSheetAuthorshipStatementRequired - -- & setTooltip MsgSheetAuthorshipStatementRequiredTip - -- -- TODO: set disabled attr if school mode disables or enforces statements - -- -- TODO: select school mode wrt. exam-related/exam-unrelated: Is this sheet related to an exam? If yes, take school exam sheet mode, otherwise take school sheet mode - -- ) - -- ( - -- -- TODO: if school disables/enforces statements for this sheet (exam-related/exam-unrelated?), set value accordingly - -- -- TODO: if this sheet is related to an exam and this exam enforces statements, set value accordingly - -- -- TODO: otherwise, take value from template, or `Just True` if the school has a non-empty school-wide default - -- (is _Just . sfAuthorshipStatement <$> template) - -- ) + -- TODO: add info: define exam-unrelated/related, if exam-unrelated: applies to sheet, if exam-related: overrides exam-wide authship statement settings + -- TODO: compare versions of current school statement and template statement: school > template if school statement is newer than template statement, template > school otherwise (TODO: add lastEdited to models?) + <*> let + reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup + reqContentField ttip = areq htmlField + (fslI MsgSheetAuthorshipStatementContent & ttip) + ( (join $ sfAuthorshipStatement <$> template) + <|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement) + ) + forcedContentField = aforced htmlField + (fslI MsgSheetAuthorshipStatementContent & setTooltip MsgSheetAuthorshipStatementContentForcedTip) + (maybe mempty (authorshipStatementDefinitionContent . entityVal) mSchoolAuthorshipStatement) + contentField ttipReq = bool forcedContentField (reqContentField ttipReq) schoolSheetAuthorshipStatementAllowOther + in case schoolSheetAuthorshipStatementMode of + SchoolAuthorshipStatementModeNone -> pure Nothing -- suppress display of whole section incl. header + otherMode -> aformSection MsgSheetAuthorshipStatementSection + *> case otherMode of + SchoolAuthorshipStatementModeOptional -> optionalActionA (contentField id) + (fslI MsgSheetAuthorshipStatementRequired & setTooltip MsgSheetAuthorshipStatementRequiredTip) + (is _Just . sfAuthorshipStatement <$> template) + SchoolAuthorshipStatementModeRequired -> fmap Just . contentField $ setTooltip MsgSheetAuthorshipStatementRequiredForcedTip + _none -> pure Nothing where makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm) makeSheetPersonalisedFilesForm template' = do