chore(tutorial): add covenience button to full exam editing
This commit is contained in:
parent
6cc929e377
commit
f04a40c0a3
@ -40,7 +40,7 @@ import Handler.Course.Users
|
|||||||
|
|
||||||
|
|
||||||
-- | Generate multiForm with one entry for each course exam showing only day-relevant exam occurrences
|
-- | Generate multiForm with one entry for each course exam showing only day-relevant exam occurrences
|
||||||
mkExamOccurrenceForm :: [(Entity Exam, CryptoUUIDExam)] -> ExamOccurrenceMap -> Form (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm)
|
mkExamOccurrenceForm :: [(Entity Exam, CryptoUUIDExam, Widget)] -> ExamOccurrenceMap -> Form (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm)
|
||||||
mkExamOccurrenceForm exs eom = renderAForm FormStandard maa
|
mkExamOccurrenceForm exs eom = renderAForm FormStandard maa
|
||||||
where
|
where
|
||||||
maa = multiActionA acts (fslI MsgCourseExam) Nothing
|
maa = multiActionA acts (fslI MsgCourseExam) Nothing
|
||||||
@ -49,13 +49,14 @@ mkExamOccurrenceForm exs eom = renderAForm FormStandard maa
|
|||||||
acts :: Map Text (AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm))
|
acts :: Map Text (AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm))
|
||||||
acts = Map.fromList $ map mkAct exs
|
acts = Map.fromList $ map mkAct exs
|
||||||
|
|
||||||
mkAct :: (Entity Exam, CryptoUUIDExam) -> (Text, AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm))
|
mkAct :: (Entity Exam, CryptoUUIDExam, Widget) -> (Text, AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm))
|
||||||
mkAct (Entity{entityKey=eId, entityVal=Exam{examName=eName, examDescription=eDescr}}, cueId) = (ciOriginal eName,
|
mkAct (Entity{entityKey=eId, entityVal=Exam{examName=eName, examDescription=eDescr}}, cueId, ewgt) = (ciOriginal eName,
|
||||||
let (cuEoIds, eos) = munzip $ Map.lookup eId eid2eos
|
let (cuEoIds, eos) = munzip $ Map.lookup eId eid2eos
|
||||||
in (,,)
|
in (,,)
|
||||||
<$ for_ eDescr (aformInfoWidget . toWgt)
|
<$ for_ eDescr (aformInfoWidget . toWgt)
|
||||||
<*> apreq hiddenField "" (Just cueId)
|
<*> apreq hiddenField "" (Just cueId)
|
||||||
<*> apreq (mkSetField hiddenField) "" cuEoIds
|
<*> apreq (mkSetField hiddenField) "" cuEoIds
|
||||||
|
<* aformInfoWidget ewgt
|
||||||
<*> examOccurrenceMultiForm eos
|
<*> examOccurrenceMultiForm eos
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -231,12 +232,12 @@ postTUsersR tid ssh csh tutn = do
|
|||||||
return user
|
return user
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let mkExamCreateBtn = linkButton mempty (msg2widget MsgMenuExamNew) [BCIsButton, BCPrimary] $ SomeRoute $ CourseR tid ssh csh CExamNewR
|
||||||
|
mkExamEditBtn ename = linkButton mempty (msg2widget MsgMenuExamEdit) [BCIsButton, BCDefault] $ SomeRoute $ CourseR tid ssh csh $ ExamR ename EEditR
|
||||||
examOccWgt <- if null openExams
|
examOccWgt <- if null openExams
|
||||||
then
|
then return $(i18nWidgetFile "exam-missing")
|
||||||
let mkCreateExamBtn = linkButton mempty (msg2widget MsgMenuExamNew) [BCIsButton, BCPrimary] $ SomeRoute $ CourseR tid ssh csh CExamNewR
|
|
||||||
in return $(i18nWidgetFile "exam-missing")
|
|
||||||
else do
|
else do
|
||||||
openExamsUUIDs <- forM openExams $ \ent@Entity{entityKey=k} -> (ent,) <$> encrypt k
|
openExamsUUIDs <- forM openExams $ \ent@Entity{entityKey=k, entityVal=Exam{examName}} -> (ent,,) <$> encrypt k <*> pure (mkExamEditBtn examName)
|
||||||
((gtaRes, gtaWgt), gtaEnctype) <- runFormPost . identifyForm FIDGeneralTutorialAction $ mkExamOccurrenceForm openExamsUUIDs exOccs -- TODO also TODO: occurrence name auto generation
|
((gtaRes, gtaWgt), gtaEnctype) <- runFormPost . identifyForm FIDGeneralTutorialAction $ mkExamOccurrenceForm openExamsUUIDs exOccs -- TODO also TODO: occurrence name auto generation
|
||||||
let gtaAnchor = "general-tutorial-action-form" :: Text
|
let gtaAnchor = "general-tutorial-action-form" :: Text
|
||||||
gtaRoute = croute :#: gtaAnchor
|
gtaRoute = croute :#: gtaAnchor
|
||||||
|
|||||||
@ -8,4 +8,4 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
<p>
|
<p>
|
||||||
Keine momentan offene Prüfung gefunden für _{MsgTableCourse} #{csh}.
|
Keine momentan offene Prüfung gefunden für _{MsgTableCourse} #{csh}.
|
||||||
<p>
|
<p>
|
||||||
^{mkCreateExamBtn}
|
^{mkExamCreateBtn}
|
||||||
|
|||||||
@ -8,4 +8,4 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
<p>
|
<p>
|
||||||
No currently open exam found for _{MsgTableCourse} #{csh}.
|
No currently open exam found for _{MsgTableCourse} #{csh}.
|
||||||
<p>
|
<p>
|
||||||
^{mkCreateExamBtn}
|
^{mkExamCreateBtn}
|
||||||
|
|||||||
Reference in New Issue
Block a user