fix(exams): fixhance exam authship form section
This commit is contained in:
parent
c5b3ac65c8
commit
4109db6f81
@ -148,29 +148,26 @@ examForm (Entity _ Course{..}) template csrf = hoist liftHandler $ do
|
|||||||
<* aformSection MsgExamFormParts
|
<* aformSection MsgExamFormParts
|
||||||
<*> examPartsForm (efExamParts <$> template)
|
<*> examPartsForm (efExamParts <$> template)
|
||||||
-- TODO: refactor messages to be used across scopes, then define this form section separately (to be used for exams and sheets)
|
-- TODO: refactor messages to be used across scopes, then define this form section separately (to be used for exams and sheets)
|
||||||
<* aformSection MsgExamAuthorshipStatementSection
|
<*> let
|
||||||
<*> optionalActionA
|
reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup
|
||||||
( areq htmlField
|
reqContentField ttip = areq htmlField
|
||||||
( if schoolSheetExamAuthorshipStatementAllowOther
|
(fslI MsgExamAuthorshipStatementContent & ttip)
|
||||||
then fslI MsgExamAuthorshipStatementContent
|
( join $ (efAuthorshipStatement <$> template)
|
||||||
else fslI MsgExamAuthorshipStatementContent
|
<|> (pure . authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
|
||||||
& addAttr "disabled" "disabled"
|
)
|
||||||
& setTooltip MsgExamAuthorshipStatementAllowOtherFalseTip
|
forcedContentField = aforced htmlField
|
||||||
)
|
(fslI MsgExamAuthorshipStatementContent & setTooltip MsgExamAuthorshipStatementAllowOtherFalseTip)
|
||||||
( (bool Nothing (join $ efAuthorshipStatement <$> template) schoolSheetExamAuthorshipStatementAllowOther) -- TODO: allow reverting from template to school definition (e.g. show school definition somewhere else, implement some kind of reset button, at least explain workaround (create new exam -> copy from there)...)
|
(maybe mempty (authorshipStatementDefinitionContent . entityVal) mSchoolAuthorshipStatement)
|
||||||
<|> (authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
|
contentField ttipReq = bool forcedContentField (reqContentField ttipReq) schoolSheetExamAuthorshipStatementAllowOther
|
||||||
)
|
in case schoolSheetExamAuthorshipStatementMode of
|
||||||
)
|
SchoolAuthorshipStatementModeNone -> pure Nothing
|
||||||
( case schoolSheetExamAuthorshipStatementMode of
|
SchoolAuthorshipStatementModeOptional -> aformSection MsgExamAuthorshipStatementSection
|
||||||
SchoolAuthorshipStatementModeNone -> fslI MsgExamAuthorshipStatementRequired & addAttr "disabled" "disabled" & setTooltip MsgExamAuthorshipStatementRequiredDisabledOffTip
|
*> optionalActionA
|
||||||
SchoolAuthorshipStatementModeOptional -> fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip
|
(contentField id)
|
||||||
SchoolAuthorshipStatementModeRequired -> fslI MsgExamAuthorshipStatementRequired & addAttr "disabled" "disabled" & setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip
|
(fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip)
|
||||||
)
|
((is _Just . efAuthorshipStatement <$> template) <|> (pure $ is _Just schoolSheetExamAuthorshipStatementDefinition))
|
||||||
( case schoolSheetExamAuthorshipStatementMode of
|
SchoolAuthorshipStatementModeRequired -> aformSection MsgExamAuthorshipStatementSection
|
||||||
SchoolAuthorshipStatementModeNone -> Just False
|
*> (fmap Just $ contentField (setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip))
|
||||||
SchoolAuthorshipStatementModeOptional -> (is _Just . efAuthorshipStatement <$> template) <|> (pure $ is _Just schoolSheetExamAuthorshipStatementDefinition)
|
|
||||||
SchoolAuthorshipStatementModeRequired -> Just True -- FIXME: checkbox is unticked after form submit with school defaults (e.g. required, school definition given and unchanged)
|
|
||||||
)
|
|
||||||
|
|
||||||
officeSchoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId)
|
officeSchoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId)
|
||||||
officeSchoolsForm mPrev = wFormToAForm $ do
|
officeSchoolsForm mPrev = wFormToAForm $ do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user