diff --git a/src/Handler/Tutorial/Users.hs b/src/Handler/Tutorial/Users.hs index c9b6c22fc..ffddc9fa9 100644 --- a/src/Handler/Tutorial/Users.hs +++ b/src/Handler/Tutorial/Users.hs @@ -40,7 +40,7 @@ import Handler.Course.Users -- | 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 where 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.fromList $ map mkAct exs - mkAct :: (Entity Exam, CryptoUUIDExam) -> (Text, AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm)) - mkAct (Entity{entityKey=eId, entityVal=Exam{examName=eName, examDescription=eDescr}}, cueId) = (ciOriginal eName, + mkAct :: (Entity Exam, CryptoUUIDExam, Widget) -> (Text, AForm Handler (CryptoUUIDExam, Set CryptoUUIDExamOccurrence, Set ExamOccurrenceForm)) + mkAct (Entity{entityKey=eId, entityVal=Exam{examName=eName, examDescription=eDescr}}, cueId, ewgt) = (ciOriginal eName, let (cuEoIds, eos) = munzip $ Map.lookup eId eid2eos in (,,) <$ for_ eDescr (aformInfoWidget . toWgt) <*> apreq hiddenField "" (Just cueId) <*> apreq (mkSetField hiddenField) "" cuEoIds + <* aformInfoWidget ewgt <*> examOccurrenceMultiForm eos ) @@ -231,12 +232,12 @@ postTUsersR tid ssh csh tutn = do 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 - then - let mkCreateExamBtn = linkButton mempty (msg2widget MsgMenuExamNew) [BCIsButton, BCPrimary] $ SomeRoute $ CourseR tid ssh csh CExamNewR - in return $(i18nWidgetFile "exam-missing") + then return $(i18nWidgetFile "exam-missing") 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 let gtaAnchor = "general-tutorial-action-form" :: Text gtaRoute = croute :#: gtaAnchor diff --git a/templates/i18n/exam-missing/de-de-formal.hamlet b/templates/i18n/exam-missing/de-de-formal.hamlet index e0416ccd4..4c0cd39e4 100644 --- a/templates/i18n/exam-missing/de-de-formal.hamlet +++ b/templates/i18n/exam-missing/de-de-formal.hamlet @@ -8,4 +8,4 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
Keine momentan offene Prüfung gefunden für _{MsgTableCourse} #{csh}.
- ^{mkCreateExamBtn} + ^{mkExamCreateBtn} diff --git a/templates/i18n/exam-missing/en-eu.hamlet b/templates/i18n/exam-missing/en-eu.hamlet index d1e5bee1d..6ac85071b 100644 --- a/templates/i18n/exam-missing/en-eu.hamlet +++ b/templates/i18n/exam-missing/en-eu.hamlet @@ -8,4 +8,4 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
No currently open exam found for _{MsgTableCourse} #{csh}.
- ^{mkCreateExamBtn} + ^{mkExamCreateBtn}