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
|
||||
<*> 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
|
||||
( areq htmlField
|
||||
( if schoolSheetExamAuthorshipStatementAllowOther
|
||||
then fslI MsgExamAuthorshipStatementContent
|
||||
else fslI MsgExamAuthorshipStatementContent
|
||||
& addAttr "disabled" "disabled"
|
||||
& 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)...)
|
||||
<|> (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 -> (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)
|
||||
)
|
||||
<*> let
|
||||
reqContentField :: (FieldSettings UniWorX -> FieldSettings UniWorX) -> AForm Handler StoredMarkup
|
||||
reqContentField ttip = areq htmlField
|
||||
(fslI MsgExamAuthorshipStatementContent & ttip)
|
||||
( join $ (efAuthorshipStatement <$> template)
|
||||
<|> (pure . authorshipStatementDefinitionContent . entityVal <$> mSchoolAuthorshipStatement)
|
||||
)
|
||||
forcedContentField = aforced htmlField
|
||||
(fslI MsgExamAuthorshipStatementContent & setTooltip MsgExamAuthorshipStatementAllowOtherFalseTip)
|
||||
(maybe mempty (authorshipStatementDefinitionContent . entityVal) mSchoolAuthorshipStatement)
|
||||
contentField ttipReq = bool forcedContentField (reqContentField ttipReq) schoolSheetExamAuthorshipStatementAllowOther
|
||||
in case schoolSheetExamAuthorshipStatementMode of
|
||||
SchoolAuthorshipStatementModeNone -> pure Nothing
|
||||
SchoolAuthorshipStatementModeOptional -> aformSection MsgExamAuthorshipStatementSection
|
||||
*> optionalActionA
|
||||
(contentField id)
|
||||
(fslI MsgExamAuthorshipStatementRequired & setTooltip MsgExamAuthorshipStatementRequiredTip)
|
||||
((is _Just . efAuthorshipStatement <$> template) <|> (pure $ is _Just schoolSheetExamAuthorshipStatementDefinition))
|
||||
SchoolAuthorshipStatementModeRequired -> aformSection MsgExamAuthorshipStatementSection
|
||||
*> (fmap Just $ contentField (setTooltip MsgExamAuthorshipStatementRequiredDisabledOnTip))
|
||||
|
||||
officeSchoolsForm :: Maybe (Set SchoolId) -> AForm Handler (Set SchoolId)
|
||||
officeSchoolsForm mPrev = wFormToAForm $ do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user