From 0735c05a7489957ed500bac1c006f4ecfdab74f3 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 3 Jun 2021 14:52:34 +0200 Subject: [PATCH] feat(sheets): eliminate authship statement required Bool --- .../categories/courses/sheet/de-de-formal.msg | 4 +--- .../uniworx/categories/courses/sheet/en-eu.msg | 4 +--- models/sheets.model | 3 +-- src/Handler/Sheet/Edit.hs | 12 +++++------- src/Handler/Sheet/Form.hs | 6 ++---- src/Handler/Sheet/New.hs | 5 ++--- test/Database/Fill.hs | 15 +++++---------- 7 files changed, 17 insertions(+), 32 deletions(-) diff --git a/messages/uniworx/categories/courses/sheet/de-de-formal.msg b/messages/uniworx/categories/courses/sheet/de-de-formal.msg index 26940c441..c10f81e0c 100644 --- a/messages/uniworx/categories/courses/sheet/de-de-formal.msg +++ b/messages/uniworx/categories/courses/sheet/de-de-formal.msg @@ -154,6 +154,4 @@ SheetGradingPassAlways: Automatisch bestanden, sobald korrigiert SheetAuthorshipStatement: Eigenständigkeitserklärung SheetAuthorshipStatementRequired: Eigenständigkeitserklärung einfordern? -SheetAuthorshipStatementRequiredTip: Soll jeder Abgebender (bei Gruppenabgaben jedes Gruppenmitglied der Abgabegruppe) vor dem Anlegen einer Abgabe dazu aufgefordert werden, eine Eigenständigkeitserklärung zu akzeptieren? -SheetAuthorshipStatementDefinition: Eigenständigkeitserklärung -SheetAuthorshipStatementDefinitionTip: Wird eine Eigenständigkeitserklärung eingefordert, so müssen Abgebende diesen Text akzeptieren (durch Setzen eines Hakens). +SheetAuthorshipStatementRequiredTip: Soll jeder Abgebende (bei Abgabegruppen jedes Mitglied der Abgabegruppe) aufgefordert werden, eine Eigenständigkeitserklärung zu akzeptieren? diff --git a/messages/uniworx/categories/courses/sheet/en-eu.msg b/messages/uniworx/categories/courses/sheet/en-eu.msg index 45bb059c4..4b04a2380 100644 --- a/messages/uniworx/categories/courses/sheet/en-eu.msg +++ b/messages/uniworx/categories/courses/sheet/en-eu.msg @@ -153,6 +153,4 @@ SheetGradingPassAlways: Automatically passed when corrected SheetAuthorshipStatement: Statement of Authorship SheetAuthorshipStatementRequired: Require Statement of Authorship for submissions? -SheetAuthorshipStatementRequiredTip: Should submittors (in case of group submissions every submission group member) be required to accept a Statement of Authorship upon creating a submission? -SheetAuthorshipStatementDefinition: Statement of Authorship -SheetAuthorshipStatementDefinitionTip: If a Statement of Authorship is required, submittors are required to accept this statement (by ticking a checkbox). +SheetAuthorshipStatementRequiredTip: Should each submittor (in case of submission groups each group member) be required to accept a Statement of Authorship? diff --git a/models/sheets.model b/models/sheets.model index 20e3d8912..6b78c7d36 100644 --- a/models/sheets.model +++ b/models/sheets.model @@ -15,8 +15,7 @@ Sheet -- exercise sheet for a given course anonymousCorrection Bool default=true requireExamRegistration ExamId Maybe -- Students may only submit if they are registered for the given exam allowNonPersonalisedSubmission Bool default=true - authorshipStatementRequired Bool default=false - authorshipStatementDefinition AuthorshipStatementDefinitionId Maybe + authorshipStatement AuthorshipStatementDefinitionId Maybe CourseSheet course name deriving Generic SheetEdit -- who edited when a row in table "Course", kept indefinitely diff --git a/src/Handler/Sheet/Edit.hs b/src/Handler/Sheet/Edit.hs index 3f4df896d..bf6e031c8 100644 --- a/src/Handler/Sheet/Edit.hs +++ b/src/Handler/Sheet/Edit.hs @@ -29,7 +29,7 @@ postSEditR tid ssh csh shn = do <$> fmap (foldMap $ \(Entity _ SheetCorrector{..}) -> Map.singleton (Right sheetCorrectorUser) (InvDBDataSheetCorrector sheetCorrectorLoad sheetCorrectorState, InvTokenDataSheetCorrector)) (selectList [ SheetCorrectorSheet ==. sid ] []) <*> fmap (fmap (, InvTokenDataSheetCorrector) . Map.mapKeysMonotonic Left) (sourceInvitationsF sid) hasPersonalisedFiles <- exists [ PersonalisedSheetFileSheet ==. sid ] - mAuthorshipStatement <- maybe (pure Nothing) get sheetAuthorshipStatementDefinition + mAuthorshipStatement <- maybe (pure Nothing) get sheetAuthorshipStatement return (ent, fti, cLoads, hasPersonalisedFiles, mAuthorshipStatement) let template = Just $ SheetForm { sfName = sheetName @@ -56,8 +56,7 @@ postSEditR tid ssh csh shn = do , spffAllowNonPersonalisedSubmission = sheetAllowNonPersonalisedSubmission , spffFiles = Nothing } - , sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired - , sfAuthorshipStatementDefinition = authorshipStatementDefinitionContent <$> mAuthorshipStatement + , sfAuthorshipStatement = authorshipStatementDefinitionContent <$> mAuthorshipStatement } let action = uniqueReplace sid -- More specific error message for edit old sheet could go here by using myReplaceUnique instead @@ -78,14 +77,14 @@ handleSheetEdit tid ssh csh msId template dbAction = do mOldAuthorshipStatement <- runMaybeT $ do sId <- MaybeT . return $ msId Entity _ Sheet{..} <- MaybeT $ getEntity sId - statementId <- MaybeT . return $ sheetAuthorshipStatementDefinition + statementId <- MaybeT . return $ sheetAuthorshipStatement MaybeT $ getEntity statementId if | Just newDef@(AuthorshipStatementDefinition newContent) <- mNewStatement , maybe True ((/=) newContent . authorshipStatementDefinitionContent . entityVal) mOldAuthorshipStatement -> Just <$> (insert newDef) | otherwise -> return $ entityKey <$> mOldAuthorshipStatement - mNewAuthorshipStatementId <- insertNewOrKeepStatement $ bool Nothing (AuthorshipStatementDefinition <$> sfAuthorshipStatementDefinition) sfAuthorshipStatementRequired + mNewAuthorshipStatementId <- insertNewOrKeepStatement $ AuthorshipStatementDefinition <$> sfAuthorshipStatement let newSheet = Sheet { sheetCourse = cid @@ -104,8 +103,7 @@ handleSheetEdit tid ssh csh msId template dbAction = do , sheetAnonymousCorrection = sfAnonymousCorrection , sheetRequireExamRegistration = sfRequireExamRegistration , sheetAllowNonPersonalisedSubmission = maybe True spffAllowNonPersonalisedSubmission sfPersonalF - , sheetAuthorshipStatementRequired = sfAuthorshipStatementRequired - , sheetAuthorshipStatementDefinition = mNewAuthorshipStatementId + , sheetAuthorshipStatement = mNewAuthorshipStatementId } mbsid <- dbAction newSheet case mbsid of diff --git a/src/Handler/Sheet/Form.hs b/src/Handler/Sheet/Form.hs index b7ddf1fa4..64155bdad 100644 --- a/src/Handler/Sheet/Form.hs +++ b/src/Handler/Sheet/Form.hs @@ -42,8 +42,7 @@ data SheetForm = SheetForm , sfMarkingText :: Maybe StoredMarkup , sfAnonymousCorrection :: Bool , sfCorrectors :: Loads - , sfAuthorshipStatementRequired :: Bool - , sfAuthorshipStatementDefinition :: Maybe StoredMarkup + , sfAuthorshipStatement :: Maybe StoredMarkup } data SheetPersonalisedFilesForm = SheetPersonalisedFilesForm @@ -100,8 +99,7 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS <*> apopt checkBoxField (fslI MsgSheetAnonymousCorrection & setTooltip MsgSheetAnonymousCorrectionTip) (sfAnonymousCorrection <$> template) <*> correctorForm (maybe mempty sfCorrectors template) <* aformSection MsgSheetAuthorshipStatement - <*> apopt checkBoxField (fslI MsgSheetAuthorshipStatementRequired & setTooltip MsgSheetAuthorshipStatementRequiredTip) (sfAuthorshipStatementRequired <$> template) -- TODO: this checkBoxField needs to be disabled and set accordingly if the school settings do not allow other statements - <*> aopt htmlField (fslI MsgSheetAuthorshipStatementDefinition & setTooltip MsgSheetAuthorshipStatementDefinitionTip) (sfAuthorshipStatementDefinition <$> template) -- TODO: use school definition + <*> optionalActionA (apreq htmlField (fslI MsgSheetAuthorshipStatement) (join $ sfAuthorshipStatement <$> template)) (fslI MsgSheetAuthorshipStatementRequired & setTooltip MsgSheetAuthorshipStatementRequiredTip) (is _Just . sfAuthorshipStatement <$> template) -- TODO: if template is empty, use school definition as default -- TODO: disable option and set accordingly if school mode prevents edits where makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm) makeSheetPersonalisedFilesForm template' = do diff --git a/src/Handler/Sheet/New.hs b/src/Handler/Sheet/New.hs index c61f90204..3b2dc8ea1 100644 --- a/src/Handler/Sheet/New.hs +++ b/src/Handler/Sheet/New.hs @@ -39,7 +39,7 @@ postSheetNewR tid ssh csh = do E.where_ $ sheetEdit E.^. SheetEditSheet E.==. sheet E.^. SheetId return . E.min_ $ sheetEdit E.^. SheetEditTime mAuthorshipStatement = E.subSelect . E.from $ \authorshipStatementDefinition -> do - E.where_ $ E.just (authorshipStatementDefinition E.^. AuthorshipStatementDefinitionId) E.==. sheet E.^. SheetAuthorshipStatementDefinition + E.where_ $ E.just (authorshipStatementDefinition E.^. AuthorshipStatementDefinitionId) E.==. sheet E.^. SheetAuthorshipStatement return $ authorshipStatementDefinition E.^. AuthorshipStatementDefinitionContent return (sheet, firstEdit, mAuthorshipStatement) cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh @@ -70,8 +70,7 @@ postSheetNewR tid ssh csh = do , sfAnonymousCorrection = sheetAnonymousCorrection , sfRequireExamRegistration = Nothing , sfPersonalF = Nothing - , sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired - , sfAuthorshipStatementDefinition = mAuthorshipStatement + , sfAuthorshipStatement = mAuthorshipStatement } _other -> Nothing let action = -- More specific error message for new sheet could go here, if insertUnique returns Nothing diff --git a/test/Database/Fill.hs b/test/Database/Fill.hs index 216c915a4..2539f2c4b 100644 --- a/test/Database/Fill.hs +++ b/test/Database/Fill.hs @@ -657,8 +657,7 @@ fillDb = do , sheetAnonymousCorrection = True , sheetRequireExamRegistration = Nothing , sheetAllowNonPersonalisedSubmission = True - , sheetAuthorshipStatementRequired = False - , sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement + , sheetAuthorshipStatement = Nothing } insert_ $ SheetEdit gkleen now adhoc feste <- insert Sheet @@ -678,8 +677,7 @@ fillDb = do , sheetAnonymousCorrection = True , sheetRequireExamRegistration = Nothing , sheetAllowNonPersonalisedSubmission = True - , sheetAuthorshipStatementRequired = False - , sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement + , sheetAuthorshipStatement = Nothing } insert_ $ SheetEdit gkleen now feste keine <- insert Sheet @@ -699,8 +697,7 @@ fillDb = do , sheetAnonymousCorrection = True , sheetRequireExamRegistration = Nothing , sheetAllowNonPersonalisedSubmission = True - , sheetAuthorshipStatementRequired = False - , sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement + , sheetAuthorshipStatement = Nothing } insert_ $ SheetEdit gkleen now keine void . insertMany $ map (\u -> CourseParticipant ffp u now Nothing CourseParticipantActive) @@ -945,8 +942,7 @@ fillDb = do , sheetAnonymousCorrection = True , sheetRequireExamRegistration = Nothing , sheetAllowNonPersonalisedSubmission = True - , sheetAuthorshipStatementRequired = False - , sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement + , sheetAuthorshipStatement = Nothing } void . insert $ SheetEdit jost now shId when (submissionModeCorrector sheetSubmissionMode) $ @@ -1190,8 +1186,7 @@ fillDb = do , sheetAnonymousCorrection = True , sheetRequireExamRegistration = Nothing , sheetAllowNonPersonalisedSubmission = True - , sheetAuthorshipStatementRequired = shNr == 14 - , sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement + , sheetAuthorshipStatement = if shNr == 14 then Just ifiAuthorshipStatement else Nothing } manyUsers' <- shuffleM $ take 1024 manyUsers groupSizes <- getRandomRs (1, 3)