feat(sheets): add required flag and definition
This commit is contained in:
parent
579371cffd
commit
541dd7688f
@ -152,4 +152,8 @@ SheetGradingPassPoints maxPoints@Points passingPoints@Points: Bestanden ab #{pas
|
|||||||
SheetGradingPassBinary: Bestanden/Nicht Bestanden
|
SheetGradingPassBinary: Bestanden/Nicht Bestanden
|
||||||
SheetGradingPassAlways: Automatisch bestanden, sobald korrigiert
|
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).
|
||||||
|
|||||||
@ -151,4 +151,8 @@ SheetGradingPassPoints maxPoints passingPoints: Pass with #{passingPoints} of #{
|
|||||||
SheetGradingPassBinary: Pass/Fail
|
SheetGradingPassBinary: Pass/Fail
|
||||||
SheetGradingPassAlways: Automatically passed when corrected
|
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).
|
||||||
|
|||||||
@ -15,8 +15,8 @@ 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
|
authorshipStatementRequired Bool default=false
|
||||||
-- authorshipStatementDefinition 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
|
||||||
|
|||||||
@ -22,14 +22,15 @@ import Handler.Sheet.PersonalisedFiles
|
|||||||
getSEditR, postSEditR :: TermId -> SchoolId -> CourseShorthand -> SheetName -> Handler Html
|
getSEditR, postSEditR :: TermId -> SchoolId -> CourseShorthand -> SheetName -> Handler Html
|
||||||
getSEditR = postSEditR
|
getSEditR = postSEditR
|
||||||
postSEditR tid ssh csh shn = do
|
postSEditR tid ssh csh shn = do
|
||||||
(Entity sid Sheet{..}, sheetFileIds, currentLoads, hasPersonalisedFiles) <- runDB $ do
|
(Entity sid Sheet{..}, sheetFileIds, currentLoads, hasPersonalisedFiles, mAuthorshipStatement) <- runDB $ do
|
||||||
ent@(Entity sid _) <- fetchSheet tid ssh csh shn
|
ent@(Entity sid Sheet{..}) <- fetchSheet tid ssh csh shn
|
||||||
fti <- getFtIdMap $ entityKey ent
|
fti <- getFtIdMap $ entityKey ent
|
||||||
cLoads <- Map.union
|
cLoads <- Map.union
|
||||||
<$> 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 ]
|
||||||
return (ent, fti, cLoads, hasPersonalisedFiles)
|
mAuthorshipStatement <- maybe (pure Nothing) get sheetAuthorshipStatementDefinition
|
||||||
|
return (ent, fti, cLoads, hasPersonalisedFiles, mAuthorshipStatement)
|
||||||
let template = Just $ SheetForm
|
let template = Just $ SheetForm
|
||||||
{ sfName = sheetName
|
{ sfName = sheetName
|
||||||
, sfDescription = sheetDescription
|
, sfDescription = sheetDescription
|
||||||
@ -55,6 +56,8 @@ postSEditR tid ssh csh shn = do
|
|||||||
, spffAllowNonPersonalisedSubmission = sheetAllowNonPersonalisedSubmission
|
, spffAllowNonPersonalisedSubmission = sheetAllowNonPersonalisedSubmission
|
||||||
, spffFiles = Nothing
|
, spffFiles = Nothing
|
||||||
}
|
}
|
||||||
|
, sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired
|
||||||
|
, 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
|
||||||
@ -70,6 +73,20 @@ handleSheetEdit tid ssh csh msId template dbAction = do
|
|||||||
(FormSuccess SheetForm{..}) -> do
|
(FormSuccess SheetForm{..}) -> do
|
||||||
saveOkay <- runDBJobs $ do
|
saveOkay <- runDBJobs $ do
|
||||||
actTime <- liftIO getCurrentTime
|
actTime <- liftIO getCurrentTime
|
||||||
|
|
||||||
|
let insertNewOrKeepStatement mNewStatement = do
|
||||||
|
mOldAuthorshipStatement <- runMaybeT $ do
|
||||||
|
sId <- MaybeT . return $ msId
|
||||||
|
Entity _ Sheet{..} <- MaybeT $ getEntity sId
|
||||||
|
statementId <- MaybeT . return $ sheetAuthorshipStatementDefinition
|
||||||
|
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
|
||||||
|
|
||||||
let newSheet = Sheet
|
let newSheet = Sheet
|
||||||
{ sheetCourse = cid
|
{ sheetCourse = cid
|
||||||
, sheetName = sfName
|
, sheetName = sfName
|
||||||
@ -87,6 +104,8 @@ 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
|
||||||
|
, sheetAuthorshipStatementDefinition = mNewAuthorshipStatementId
|
||||||
}
|
}
|
||||||
mbsid <- dbAction newSheet
|
mbsid <- dbAction newSheet
|
||||||
case mbsid of
|
case mbsid of
|
||||||
|
|||||||
@ -42,7 +42,8 @@ data SheetForm = SheetForm
|
|||||||
, sfMarkingText :: Maybe StoredMarkup
|
, sfMarkingText :: Maybe StoredMarkup
|
||||||
, sfAnonymousCorrection :: Bool
|
, sfAnonymousCorrection :: Bool
|
||||||
, sfCorrectors :: Loads
|
, sfCorrectors :: Loads
|
||||||
-- Keine SheetId im Formular!
|
, sfAuthorshipStatementRequired :: Bool
|
||||||
|
, sfAuthorshipStatementDefinition :: Maybe StoredMarkup
|
||||||
}
|
}
|
||||||
|
|
||||||
data SheetPersonalisedFilesForm = SheetPersonalisedFilesForm
|
data SheetPersonalisedFilesForm = SheetPersonalisedFilesForm
|
||||||
@ -98,6 +99,9 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
|
|||||||
<*> aopt htmlField (fslI MsgSheetMarking) (sfMarkingText <$> template)
|
<*> aopt htmlField (fslI MsgSheetMarking) (sfMarkingText <$> template)
|
||||||
<*> 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
|
||||||
|
<*> 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
|
||||||
where
|
where
|
||||||
makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm)
|
makeSheetPersonalisedFilesForm :: Maybe SheetPersonalisedFilesForm -> MForm Handler (AForm Handler SheetPersonalisedFilesForm)
|
||||||
makeSheetPersonalisedFilesForm template' = do
|
makeSheetPersonalisedFilesForm template' = do
|
||||||
@ -156,6 +160,10 @@ makeSheetForm cId msId template = identifyForm FIDsheet . validateForm validateS
|
|||||||
$ classifySubmissionMode sfSubmissionMode /= SubmissionModeNone
|
$ classifySubmissionMode sfSubmissionMode /= SubmissionModeNone
|
||||||
|| sfType == NotGraded
|
|| sfType == NotGraded
|
||||||
|
|
||||||
|
-- TODO: do authorship statement validation
|
||||||
|
-- TODO: if school mode is none or required for this sheet (exam-related/exam-umrelated?), statementRequired must be set accordingly
|
||||||
|
-- TODO: authorship statement definition must not be empty when statement is required
|
||||||
|
|
||||||
correctorForm :: Loads -> AForm Handler Loads
|
correctorForm :: Loads -> AForm Handler Loads
|
||||||
correctorForm loads' = wFormToAForm $ do
|
correctorForm loads' = wFormToAForm $ do
|
||||||
currentRoute <- fromMaybe (error "correctorForm called from 404-handler") <$> liftHandler getCurrentRoute
|
currentRoute <- fromMaybe (error "correctorForm called from 404-handler") <$> liftHandler getCurrentRoute
|
||||||
|
|||||||
@ -34,16 +34,20 @@ postSheetNewR tid ssh csh = do
|
|||||||
searchShn sheet
|
searchShn sheet
|
||||||
E.orderBy [E.desc (sheet E.^. SheetActiveFrom)]
|
E.orderBy [E.desc (sheet E.^. SheetActiveFrom)]
|
||||||
E.limit 1
|
E.limit 1
|
||||||
let firstEdit = E.subSelectMaybe . E.from $ \sheetEdit -> do
|
let
|
||||||
E.where_ $ sheetEdit E.^. SheetEditSheet E.==. sheet E.^. SheetId
|
firstEdit = E.subSelectMaybe . E.from $ \sheetEdit -> do
|
||||||
return . E.min_ $ sheetEdit E.^. SheetEditTime
|
E.where_ $ sheetEdit E.^. SheetEditSheet E.==. sheet E.^. SheetId
|
||||||
return (sheet, firstEdit)
|
return . E.min_ $ sheetEdit E.^. SheetEditTime
|
||||||
|
mAuthorshipStatement = E.subSelect . E.from $ \authorshipStatementDefinition -> do
|
||||||
|
E.where_ $ E.just (authorshipStatementDefinition E.^. AuthorshipStatementDefinitionId) E.==. sheet E.^. SheetAuthorshipStatementDefinition
|
||||||
|
return $ authorshipStatementDefinition E.^. AuthorshipStatementDefinitionContent
|
||||||
|
return (sheet, firstEdit, mAuthorshipStatement)
|
||||||
cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh
|
||||||
loads <- defaultLoads cid
|
loads <- defaultLoads cid
|
||||||
return (lSheets, loads)
|
return (lSheets, loads)
|
||||||
now <- liftIO getCurrentTime
|
now <- liftIO getCurrentTime
|
||||||
let template = case lastSheets of
|
let template = case lastSheets of
|
||||||
((Entity {entityVal=Sheet{..}}, E.Value fEdit):_) ->
|
((Entity {entityVal=Sheet{..}}, E.Value fEdit, E.Value mAuthorshipStatement):_) ->
|
||||||
let addTime = addWeeks $ max 1 $ weeksToAdd (fromMaybe (UTCTime systemEpochDay 0) $ sheetActiveTo <|> fEdit) now
|
let addTime = addWeeks $ max 1 $ weeksToAdd (fromMaybe (UTCTime systemEpochDay 0) $ sheetActiveTo <|> fEdit) now
|
||||||
in Just $ SheetForm
|
in Just $ SheetForm
|
||||||
{ sfName = stepTextCounterCI sheetName
|
{ sfName = stepTextCounterCI sheetName
|
||||||
@ -66,6 +70,8 @@ postSheetNewR tid ssh csh = do
|
|||||||
, sfAnonymousCorrection = sheetAnonymousCorrection
|
, sfAnonymousCorrection = sheetAnonymousCorrection
|
||||||
, sfRequireExamRegistration = Nothing
|
, sfRequireExamRegistration = Nothing
|
||||||
, sfPersonalF = Nothing
|
, sfPersonalF = Nothing
|
||||||
|
, sfAuthorshipStatementRequired = sheetAuthorshipStatementRequired
|
||||||
|
, 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
|
||||||
|
|||||||
Reference in New Issue
Block a user