From 0392297ddbfccbb9a08e678696a9cedd1098121a Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Thu, 10 Jun 2021 13:46:27 +0200 Subject: [PATCH] feat(exams): first do-nothing stub for exam-wide authorship statements --- .../courses/exam/exam/de-de-formal.msg | 5 +- .../categories/courses/exam/exam/en-eu.msg | 5 +- src/Handler/Exam/Form.hs | 73 ++++++++++++++----- 3 files changed, 61 insertions(+), 22 deletions(-) diff --git a/messages/uniworx/categories/courses/exam/exam/de-de-formal.msg b/messages/uniworx/categories/courses/exam/exam/de-de-formal.msg index 1205a5cd2..3c08b0f05 100644 --- a/messages/uniworx/categories/courses/exam/exam/de-de-formal.msg +++ b/messages/uniworx/categories/courses/exam/exam/de-de-formal.msg @@ -322,4 +322,7 @@ ExamAuthorshipStatementSchoolDefinition: Institutsweit vorgegebene Eigenständig ExamAuthorshipStatementUseCustomDefinition: Benutzerdefinierte Eigenständigkeitserklärung verwenden? ExamAuthorshipStatementUseCustomDefinitionTip: Soll anstatt der institutsweit vorgegebenen Eigenständigkeitserklärung eine benuzterdefinierte Erklärung für diese Prüfung genutzt werden? (Hinweis: Um konsistente Erklärungen für alle Abgaben der Prüfung zu gewährleisten, dient die institutsweite Erklärung hier nur als Vorlage und wird ab dann getrennt (als Kopie) gespeichert. Ändert sich die institutsweite Erklärung, so muss die Änderung für diese Prüfung manuell übernommen werden, falls erwünscht.) ExamAuthorshipStatementUseCustomDefinitionDisabledTip: Für dieses Institut ist die institutsweite Vorgabe als Erklärung zu verwenden. Benutzerdefinierte Erklärungen sind nicht gestattet. -ExamAuthorshipStatementCustom: Benutzerdefinierte Eigenständigkeitserklärung \ No newline at end of file +ExamAuthorshipStatementCustom: Benutzerdefinierte Eigenständigkeitserklärung + +ExamAuthorshipStatementContent: Eigenständigkeitserklärung +ExamAuthorshipStatementAllowOtherFalseTip: Für dieses Institut muss die institutsweit vorgegebene Eigenständigkeitserklärung verwendet werden. Benutzerdefinierte Erklärungen sind nicht gestattet. \ No newline at end of file diff --git a/messages/uniworx/categories/courses/exam/exam/en-eu.msg b/messages/uniworx/categories/courses/exam/exam/en-eu.msg index 0f80e4dc5..83cb8cad8 100644 --- a/messages/uniworx/categories/courses/exam/exam/en-eu.msg +++ b/messages/uniworx/categories/courses/exam/exam/en-eu.msg @@ -320,4 +320,7 @@ ExamAuthorshipStatementSchoolDefinition: School-wide default Statement of Author ExamAuthorshipStatementUseCustomDefinition: Use custom Statement of Authorship? ExamAuthorshipStatementUseCustomDefinitionTip: Should a custom Statement of Authorship be used for this exam instead of the school-wide default statement? (Hint: To ensure consistent statements for all submissions related to this exam, the school-wide default statement will be used as a template here and will then be stored separately (as a copy). If the school-wide default statement changes, this change must be applied manually for this exam if desired.) ExamAuthorshipStatementUseCustomDefinitionDisabledTip: This school dictates that the school-wide Statement of Authorship must be used. Custom statements are prohibited. -ExamAuthorshipStatementCustom: Custom Statement of Authorship \ No newline at end of file +ExamAuthorshipStatementCustom: Custom Statement of Authorship + +ExamAuthorshipStatementContent: Statement of Authorship +ExamAuthorshipStatementAllowOtherFalseTip: The settings of this school dictate that the school-wide Statement of Authorship must be used. Custom statements are prohibited. \ No newline at end of file diff --git a/src/Handler/Exam/Form.hs b/src/Handler/Exam/Form.hs index ee42effa5..640f8799f 100644 --- a/src/Handler/Exam/Form.hs +++ b/src/Handler/Exam/Form.hs @@ -52,6 +52,7 @@ data ExamForm = ExamForm , efStaff :: Maybe Text , efCorrectors :: Set (Either UserEmail UserId) , efExamParts :: Set ExamPartForm + , efAuthorshipStatement :: Maybe StoredMarkup } data ExamOccurrenceForm = ExamOccurrenceForm @@ -148,29 +149,16 @@ examForm (Entity _ Course{..}) template csrf = hoist liftHandler $ do <*> examPartsForm (efExamParts <$> template) -- TODO: refactor messages to be used across scopes, then define this form section separately (to be used for exams and sheets) <* aformSection MsgExamAuthorshipStatementSection - <* optionalActionA - ( aopt htmlField - (fslI MsgExamAuthorshipStatementSchoolDefinition & addAttr "disabled" "disabled") - ((Just . authorshipStatementDefinitionContent . entityVal) <$> mSchoolAuthorshipStatement) - <* optionalActionA - ( apreq htmlField - (fslI MsgExamAuthorshipStatementCustom) - ( - -- TODO: load custom statement from template - -- (loading school definition as default is not necessary if it is displayed in form) - Nothing - ) - ) + <*> optionalActionA + ( areq htmlField ( if schoolSheetExamAuthorshipStatementAllowOther - then fslI MsgExamAuthorshipStatementUseCustomDefinition - & setTooltip MsgExamAuthorshipStatementUseCustomDefinitionTip - else fslI MsgExamAuthorshipStatementUseCustomDefinition + then fslI MsgExamAuthorshipStatementContent + else fslI MsgExamAuthorshipStatementContent & addAttr "disabled" "disabled" - & setTooltip MsgExamAuthorshipStatementUseCustomDefinitionDisabledTip + & setTooltip MsgExamAuthorshipStatementAllowOtherFalseTip ) - ( bool (Just False) - (Just True) -- TODO: set according to template, if template is empty `Just True` - schoolSheetExamAuthorshipStatementAllowOther + ( Nothing -- TODO: take value from template + <|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement) ) ) ( case schoolSheetExamAuthorshipStatementMode of @@ -183,6 +171,44 @@ examForm (Entity _ Course{..}) template csrf = hoist liftHandler $ do SchoolAuthorshipStatementModeOptional -> Nothing -- TODO: set value according to template SchoolAuthorshipStatementModeRequired -> Just True ) + -- <*> optionalActionA + -- ( ( optionalActionA + -- ( areq htmlField + -- (fslI MsgExamAuthorshipStatementCustom) + -- ( + -- -- TODO: load custom statement from template + -- -- (loading school definition as default is not necessary if it is displayed in form) + -- mempty + -- ) + -- ) + -- ( if schoolSheetExamAuthorshipStatementAllowOther + -- then fslI MsgExamAuthorshipStatementUseCustomDefinition + -- & setTooltip MsgExamAuthorshipStatementUseCustomDefinitionTip + -- else fslI MsgExamAuthorshipStatementUseCustomDefinition + -- & addAttr "disabled" "disabled" + -- & setTooltip MsgExamAuthorshipStatementUseCustomDefinitionDisabledTip + -- ) + -- ( bool (Just False) + -- (Just True) -- TODO: set according to template, if template is empty `Just True` + -- schoolSheetExamAuthorshipStatementAllowOther + -- ) + -- ) + -- <*> ( aopt htmlField + -- (fslI MsgExamAuthorshipStatementSchoolDefinition & addAttr "disabled" "disabled") + -- ((Just . authorshipStatementDefinitionContent . entityVal) <$> mSchoolAuthorshipStatement) + -- ) + -- ) + -- ( case schoolSheetExamAuthorshipStatementMode of + -- SchoolAuthorshipStatementModeNone -> fslI MsgExamAuthorshipStatementRequired & addAttr "disabled" "disabled" & setTooltip MsgExamAuthorshipStatementRequiredDisabledOffTip + -- SchoolAuthorshipStatementModeOptional -> fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip + -- SchoolAuthorshipStatementModeRequired -> fslI MsgExamAuthorshipStatementRequired & addAttr "disabled" "disabled" & setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip + -- ) + -- ( case schoolSheetExamAuthorshipStatementMode of + -- SchoolAuthorshipStatementModeNone -> Just False + -- SchoolAuthorshipStatementModeOptional -> Nothing -- TODO: set value according to template + -- SchoolAuthorshipStatementModeRequired -> Just True + -- ) + -- ) officeSchoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId) officeSchoolsForm mPrev = wFormToAForm $ do @@ -403,6 +429,7 @@ examFormTemplate (Entity eId Exam{..}) = do , efExamMode = examExamMode , efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools , efStaff = examStaff + , efAuthorshipStatement = Nothing -- TODO } examTemplate :: MonadHandler m @@ -455,6 +482,7 @@ examTemplate cid = runMaybeT $ do , efExamMode = examExamMode oldExam , efStaff = examStaff oldExam , efOfficeSchools = Set.fromList $ examOfficeSchoolSchool . entityVal <$> extraSchools + , efAuthorshipStatement = Nothing -- TODO } @@ -565,5 +593,10 @@ validateExam cId oldExam = do warnValidation MsgExamModeSchoolDiscouraged . not $ evalExamModeDNF schoolExamDiscouragedModes efExamMode + -- TODO: form validation of examAuthorshipStatement wrt school settings + -- - if mode is none, the statement must be `Nothing` + -- - if mode is required, the statement must be `Just x` + -- - if the school has a definition and disallows other, the statement must match the school definition + unless (has (_Just . _entityVal . _examStaff . _Nothing) oldExam) $ guardValidation MsgExamStaffRequired $ isn't _Nothing efStaff