feat(exams): do form validation

This commit is contained in:
Sarah Vaupel 2021-06-11 11:59:02 +02:00 committed by Gregor Kleen
parent fe5111c25f
commit bf7b25ca9e
3 changed files with 18 additions and 6 deletions

View File

@ -324,4 +324,8 @@ ExamAuthorshipStatementUseCustomDefinitionTip: Soll anstatt der institutsweit vo
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
ExamAuthorshipStatementContent: Eigenständigkeitserklärung
ExamAuthorshipStatementAllowOtherFalseTip: Für dieses Institut ist die institutsweit vorgegebene Eigenständigkeitserklärung für prüfungsrelevante Übungsblätter zu verwenden. Benutzerdefinierte Erklärungen sind nicht gestattet.
ExamAuthorshipStatementAllowOtherFalseTip: Für dieses Institut ist die institutsweit vorgegebene Eigenständigkeitserklärung für prüfungsrelevante Übungsblätter zu verwenden. Benutzerdefinierte Erklärungen sind nicht gestattet.
ExamAuthorshipStatementMustBeEmpty: Es darf keine Eigenständigkeitserklärung für prüfungsrelevante Übungsblätter angegeben werden.
ExamAuthorshipStatementMustBeNonEmpty: Es muss eine nicht-leere Eigenständigkeitserklärung für prüfungsrelevante Übungsblätter angegeben werden.
ExamAuthorshipStatementMustMatchSchoolDefinition: Die angegebene Eigenständigkeitserklärung für prüfungsrelevante Übungsblätter muss der Vorgabe des Instituts entsprechen.

View File

@ -322,4 +322,8 @@ ExamAuthorshipStatementUseCustomDefinitionTip: Should a custom Statement of Auth
ExamAuthorshipStatementUseCustomDefinitionDisabledTip: This school dictates that the school-wide Statement of Authorship must be used. Custom statements are prohibited.
ExamAuthorshipStatementCustom: Custom Statement of Authorship
ExamAuthorshipStatementContent: Statement of Authorship
ExamAuthorshipStatementAllowOtherFalseTip: The settings of this school dictate that the school-wide Statement of Authorship for exam-related sheets must be used. Custom statements are prohibited.
ExamAuthorshipStatementAllowOtherFalseTip: The settings of this school dictate that the school-wide Statement of Authorship for exam-related sheets must be used. Custom statements are prohibited.
ExamAuthorshipStatementMustBeEmpty: No Statement of Authorship for exam-related sheets may be given.
ExamAuthorshipStatementMustBeNonEmpty: A non-empty Statement of Authorship for exam-related sheets must be given.
ExamAuthorshipStatementMustMatchSchoolDefinition: The given Statement of Authorship for exam-related sheets must match the school-wide Statement of Authorship.

View File

@ -558,10 +558,14 @@ 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
case schoolSheetExamAuthorshipStatementMode of
SchoolAuthorshipStatementModeNone -> guardValidation MsgExamAuthorshipStatementMustBeEmpty $ is _Nothing efAuthorshipStatement
SchoolAuthorshipStatementModeRequired -> guardValidation MsgExamAuthorshipStatementMustBeNonEmpty $ is _Just efAuthorshipStatement
_otherwise -> return ()
whenIsJust efAuthorshipStatement $ \statementContent -> do
mSchoolAuthorshipStatement <- lift $ maybe (pure Nothing) getEntity schoolSheetExamAuthorshipStatementDefinition
guardValidation MsgExamAuthorshipStatementMustBeNonEmpty $ schoolSheetExamAuthorshipStatementMode == SchoolAuthorshipStatementModeRequired && statementContent /= mempty
guardValidation MsgExamAuthorshipStatementMustMatchSchoolDefinition $ not schoolSheetExamAuthorshipStatementAllowOther && Just statementContent == (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
unless (has (_Just . _entityVal . _examStaff . _Nothing) oldExam) $
guardValidation MsgExamStaffRequired $ isn't _Nothing efStaff