feat(sheets): eliminate authship statement required Bool

This commit is contained in:
Sarah Vaupel 2021-06-03 14:52:34 +02:00 committed by Gregor Kleen
parent 996262c327
commit 0735c05a74
7 changed files with 17 additions and 32 deletions

View File

@ -154,6 +154,4 @@ SheetGradingPassAlways: Automatisch bestanden, sobald korrigiert
SheetAuthorshipStatement: Eigenständigkeitserklärung SheetAuthorshipStatement: Eigenständigkeitserklärung
SheetAuthorshipStatementRequired: Eigenständigkeitserklärung einfordern? 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? SheetAuthorshipStatementRequiredTip: Soll jeder Abgebende (bei Abgabegruppen jedes Mitglied der Abgabegruppe) 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).

View File

@ -153,6 +153,4 @@ SheetGradingPassAlways: Automatically passed when corrected
SheetAuthorshipStatement: Statement of Authorship SheetAuthorshipStatement: Statement of Authorship
SheetAuthorshipStatementRequired: Require Statement of Authorship for submissions? 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? SheetAuthorshipStatementRequiredTip: Should each submittor (in case of submission groups each group member) be required to accept a Statement of Authorship?
SheetAuthorshipStatementDefinition: Statement of Authorship
SheetAuthorshipStatementDefinitionTip: If a Statement of Authorship is required, submittors are required to accept this statement (by ticking a checkbox).

View File

@ -15,8 +15,7 @@ Sheet -- exercise sheet for a given course
anonymousCorrection Bool default=true anonymousCorrection Bool default=true
requireExamRegistration ExamId Maybe -- Students may only submit if they are registered for the given exam requireExamRegistration ExamId Maybe -- Students may only submit if they are registered for the given exam
allowNonPersonalisedSubmission Bool default=true allowNonPersonalisedSubmission Bool default=true
authorshipStatementRequired Bool default=false authorshipStatement AuthorshipStatementDefinitionId Maybe
authorshipStatementDefinition AuthorshipStatementDefinitionId Maybe
CourseSheet course name CourseSheet course name
deriving Generic deriving Generic
SheetEdit -- who edited when a row in table "Course", kept indefinitely SheetEdit -- who edited when a row in table "Course", kept indefinitely

View File

@ -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 (foldMap $ \(Entity _ SheetCorrector{..}) -> Map.singleton (Right sheetCorrectorUser) (InvDBDataSheetCorrector sheetCorrectorLoad sheetCorrectorState, InvTokenDataSheetCorrector)) (selectList [ SheetCorrectorSheet ==. sid ] [])
<*> fmap (fmap (, InvTokenDataSheetCorrector) . Map.mapKeysMonotonic Left) (sourceInvitationsF sid) <*> fmap (fmap (, InvTokenDataSheetCorrector) . Map.mapKeysMonotonic Left) (sourceInvitationsF sid)
hasPersonalisedFiles <- exists [ PersonalisedSheetFileSheet ==. sid ] hasPersonalisedFiles <- exists [ PersonalisedSheetFileSheet ==. sid ]
mAuthorshipStatement <- maybe (pure Nothing) get sheetAuthorshipStatementDefinition mAuthorshipStatement <- maybe (pure Nothing) get sheetAuthorshipStatement
return (ent, fti, cLoads, hasPersonalisedFiles, mAuthorshipStatement) return (ent, fti, cLoads, hasPersonalisedFiles, mAuthorshipStatement)
let template = Just $ SheetForm let template = Just $ SheetForm
{ sfName = sheetName { sfName = sheetName
@ -56,8 +56,7 @@ postSEditR tid ssh csh shn = do
, spffAllowNonPersonalisedSubmission = sheetAllowNonPersonalisedSubmission , spffAllowNonPersonalisedSubmission = sheetAllowNonPersonalisedSubmission
, spffFiles = Nothing , spffFiles = Nothing
} }
, sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired , sfAuthorshipStatement = authorshipStatementDefinitionContent <$> mAuthorshipStatement
, sfAuthorshipStatementDefinition = authorshipStatementDefinitionContent <$> mAuthorshipStatement
} }
let action = uniqueReplace sid -- More specific error message for edit old sheet could go here by using myReplaceUnique instead 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 mOldAuthorshipStatement <- runMaybeT $ do
sId <- MaybeT . return $ msId sId <- MaybeT . return $ msId
Entity _ Sheet{..} <- MaybeT $ getEntity sId Entity _ Sheet{..} <- MaybeT $ getEntity sId
statementId <- MaybeT . return $ sheetAuthorshipStatementDefinition statementId <- MaybeT . return $ sheetAuthorshipStatement
MaybeT $ getEntity statementId MaybeT $ getEntity statementId
if if
| Just newDef@(AuthorshipStatementDefinition newContent) <- mNewStatement | Just newDef@(AuthorshipStatementDefinition newContent) <- mNewStatement
, maybe True ((/=) newContent . authorshipStatementDefinitionContent . entityVal) mOldAuthorshipStatement , maybe True ((/=) newContent . authorshipStatementDefinitionContent . entityVal) mOldAuthorshipStatement
-> Just <$> (insert newDef) -> Just <$> (insert newDef)
| otherwise -> return $ entityKey <$> mOldAuthorshipStatement | otherwise -> return $ entityKey <$> mOldAuthorshipStatement
mNewAuthorshipStatementId <- insertNewOrKeepStatement $ bool Nothing (AuthorshipStatementDefinition <$> sfAuthorshipStatementDefinition) sfAuthorshipStatementRequired mNewAuthorshipStatementId <- insertNewOrKeepStatement $ AuthorshipStatementDefinition <$> sfAuthorshipStatement
let newSheet = Sheet let newSheet = Sheet
{ sheetCourse = cid { sheetCourse = cid
@ -104,8 +103,7 @@ handleSheetEdit tid ssh csh msId template dbAction = do
, sheetAnonymousCorrection = sfAnonymousCorrection , sheetAnonymousCorrection = sfAnonymousCorrection
, sheetRequireExamRegistration = sfRequireExamRegistration , sheetRequireExamRegistration = sfRequireExamRegistration
, sheetAllowNonPersonalisedSubmission = maybe True spffAllowNonPersonalisedSubmission sfPersonalF , sheetAllowNonPersonalisedSubmission = maybe True spffAllowNonPersonalisedSubmission sfPersonalF
, sheetAuthorshipStatementRequired = sfAuthorshipStatementRequired , sheetAuthorshipStatement = mNewAuthorshipStatementId
, sheetAuthorshipStatementDefinition = mNewAuthorshipStatementId
} }
mbsid <- dbAction newSheet mbsid <- dbAction newSheet
case mbsid of case mbsid of

View File

@ -42,8 +42,7 @@ data SheetForm = SheetForm
, sfMarkingText :: Maybe StoredMarkup , sfMarkingText :: Maybe StoredMarkup
, sfAnonymousCorrection :: Bool , sfAnonymousCorrection :: Bool
, sfCorrectors :: Loads , sfCorrectors :: Loads
, sfAuthorshipStatementRequired :: Bool , sfAuthorshipStatement :: Maybe StoredMarkup
, sfAuthorshipStatementDefinition :: Maybe StoredMarkup
} }
data SheetPersonalisedFilesForm = SheetPersonalisedFilesForm data SheetPersonalisedFilesForm = SheetPersonalisedFilesForm
@ -100,8 +99,7 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
<*> apopt checkBoxField (fslI MsgSheetAnonymousCorrection & setTooltip MsgSheetAnonymousCorrectionTip) (sfAnonymousCorrection <$> template) <*> apopt checkBoxField (fslI MsgSheetAnonymousCorrection & setTooltip MsgSheetAnonymousCorrectionTip) (sfAnonymousCorrection <$> template)
<*> correctorForm (maybe mempty sfCorrectors template) <*> correctorForm (maybe mempty sfCorrectors template)
<* aformSection MsgSheetAuthorshipStatement <* 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 <*> 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
<*> aopt htmlField (fslI MsgSheetAuthorshipStatementDefinition & setTooltip MsgSheetAuthorshipStatementDefinitionTip) (sfAuthorshipStatementDefinition <$> template) -- TODO: use school definition
where where
makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm) makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm)
makeSheetPersonalisedFilesForm template' = do makeSheetPersonalisedFilesForm template' = do

View File

@ -39,7 +39,7 @@ postSheetNewR tid ssh csh = do
E.where_ $ sheetEdit E.^. SheetEditSheet E.==. sheet E.^. SheetId E.where_ $ sheetEdit E.^. SheetEditSheet E.==. sheet E.^. SheetId
return . E.min_ $ sheetEdit E.^. SheetEditTime return . E.min_ $ sheetEdit E.^. SheetEditTime
mAuthorshipStatement = E.subSelect . E.from $ \authorshipStatementDefinition -> do 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 $ authorshipStatementDefinition E.^. AuthorshipStatementDefinitionContent
return (sheet, firstEdit, mAuthorshipStatement) return (sheet, firstEdit, mAuthorshipStatement)
cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
@ -70,8 +70,7 @@ postSheetNewR tid ssh csh = do
, sfAnonymousCorrection = sheetAnonymousCorrection , sfAnonymousCorrection = sheetAnonymousCorrection
, sfRequireExamRegistration = Nothing , sfRequireExamRegistration = Nothing
, sfPersonalF = Nothing , sfPersonalF = Nothing
, sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired , sfAuthorshipStatement = mAuthorshipStatement
, sfAuthorshipStatementDefinition = mAuthorshipStatement
} }
_other -> Nothing _other -> Nothing
let action = -- More specific error message for new sheet could go here, if insertUnique returns Nothing let action = -- More specific error message for new sheet could go here, if insertUnique returns Nothing

View File

@ -657,8 +657,7 @@ fillDb = do
, sheetAnonymousCorrection = True , sheetAnonymousCorrection = True
, sheetRequireExamRegistration = Nothing , sheetRequireExamRegistration = Nothing
, sheetAllowNonPersonalisedSubmission = True , sheetAllowNonPersonalisedSubmission = True
, sheetAuthorshipStatementRequired = False , sheetAuthorshipStatement = Nothing
, sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement
} }
insert_ $ SheetEdit gkleen now adhoc insert_ $ SheetEdit gkleen now adhoc
feste <- insert Sheet feste <- insert Sheet
@ -678,8 +677,7 @@ fillDb = do
, sheetAnonymousCorrection = True , sheetAnonymousCorrection = True
, sheetRequireExamRegistration = Nothing , sheetRequireExamRegistration = Nothing
, sheetAllowNonPersonalisedSubmission = True , sheetAllowNonPersonalisedSubmission = True
, sheetAuthorshipStatementRequired = False , sheetAuthorshipStatement = Nothing
, sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement
} }
insert_ $ SheetEdit gkleen now feste insert_ $ SheetEdit gkleen now feste
keine <- insert Sheet keine <- insert Sheet
@ -699,8 +697,7 @@ fillDb = do
, sheetAnonymousCorrection = True , sheetAnonymousCorrection = True
, sheetRequireExamRegistration = Nothing , sheetRequireExamRegistration = Nothing
, sheetAllowNonPersonalisedSubmission = True , sheetAllowNonPersonalisedSubmission = True
, sheetAuthorshipStatementRequired = False , sheetAuthorshipStatement = Nothing
, sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement
} }
insert_ $ SheetEdit gkleen now keine insert_ $ SheetEdit gkleen now keine
void . insertMany $ map (\u -> CourseParticipant ffp u now Nothing CourseParticipantActive) void . insertMany $ map (\u -> CourseParticipant ffp u now Nothing CourseParticipantActive)
@ -945,8 +942,7 @@ fillDb = do
, sheetAnonymousCorrection = True , sheetAnonymousCorrection = True
, sheetRequireExamRegistration = Nothing , sheetRequireExamRegistration = Nothing
, sheetAllowNonPersonalisedSubmission = True , sheetAllowNonPersonalisedSubmission = True
, sheetAuthorshipStatementRequired = False , sheetAuthorshipStatement = Nothing
, sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement
} }
void . insert $ SheetEdit jost now shId void . insert $ SheetEdit jost now shId
when (submissionModeCorrector sheetSubmissionMode) $ when (submissionModeCorrector sheetSubmissionMode) $
@ -1190,8 +1186,7 @@ fillDb = do
, sheetAnonymousCorrection = True , sheetAnonymousCorrection = True
, sheetRequireExamRegistration = Nothing , sheetRequireExamRegistration = Nothing
, sheetAllowNonPersonalisedSubmission = True , sheetAllowNonPersonalisedSubmission = True
, sheetAuthorshipStatementRequired = shNr == 14 , sheetAuthorshipStatement = if shNr == 14 then Just ifiAuthorshipStatement else Nothing
, sheetAuthorshipStatementDefinition = Just ifiAuthorshipStatement
} }
manyUsers' <- shuffleM $ take 1024 manyUsers manyUsers' <- shuffleM $ take 1024 manyUsers
groupSizes <- getRandomRs (1, 3) groupSizes <- getRandomRs (1, 3)