From cb7c9ac6dad5e248e9cf0748a871947369cd39af Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 8 Jan 2020 16:38:16 +0100 Subject: [PATCH] feat(exam-correct): add basic interface stub --- messages/uniworx/de-de-formal.msg | 10 +++++++++ messages/uniworx/en-eu.msg | 10 +++++++++ src/Handler/Exam/Correct.hs | 28 ++++++++++++++++++++++++- src/Model/Types/Exam.hs | 2 ++ src/Utils/Tooltip.hs | 6 ++++++ templates/widgets/exam-correct.hamlet | 30 +++++++++++++++++++++++++++ templates/widgets/text-tooltip.hamlet | 6 ++++++ 7 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/Utils/Tooltip.hs create mode 100644 templates/widgets/exam-correct.hamlet create mode 100644 templates/widgets/text-tooltip.hamlet diff --git a/messages/uniworx/de-de-formal.msg b/messages/uniworx/de-de-formal.msg index a82909d18..8b963d3f1 100644 --- a/messages/uniworx/de-de-formal.msg +++ b/messages/uniworx/de-de-formal.msg @@ -1359,6 +1359,16 @@ ExamRegistrationInvitationDeclined examn@ExamName: Sie haben die Einladung, Teil ExamRegistrationInviteHeading examn@ExamName: Einladung zum Teilnehmer für #{examn} ExamRegistrationInviteExplanation: Sie wurden eingeladen, Prüfungsteilnehmer zu sein. +ExamCorrectHeading examname@Text: Prüfungsergebnisse für #{examname} eintragen + +ExamCorrectHeadParticipant: Teilnehmer +ExamCorrectHeadParticipantTooltip: Geben Sie hier einen beliebigen eindeutigen Identifikator des Teilnehmers an. Definitiv eindeutig ist die Matrikelnummer des Teilnehmers, aber auch der Name oder ein Teil der Matrikelnummer können unter Umständen (je nach Liste aller Prüfungsteilnehmer) bereits eindeutig sein. +ExamCorrectHeadPart exampartnum@ExamPartNumber: #{exampartnum} +ExamCorrectHeadPartName exampartname@ExamPartName: #{exampartname} +ExamCorrectHeadStatus: Status + +ExamCorrectButtonSend: Senden + SubmissionUserInvitationAccepted shn@SheetName: Sie wurden als Mitabgebende(r) für eine Abgabe zu #{shn} eingetragen SubmissionUserInvitationDeclined shn@SheetName: Sie haben die Einladung, Mitabgebende(r) für #{shn} zu werden, abgelehnt SubmissionUserInviteHeading shn@SheetName: Einladung zu einer Abgabe für #{shn} diff --git a/messages/uniworx/en-eu.msg b/messages/uniworx/en-eu.msg index 6dc28491a..b6bf6aa6d 100644 --- a/messages/uniworx/en-eu.msg +++ b/messages/uniworx/en-eu.msg @@ -1357,6 +1357,16 @@ ExamRegistrationInvitationDeclined examn: You have declined the invitation to pa ExamRegistrationInviteHeading examn: Invitation to participate in #{examn} ExamRegistrationInviteExplanation: You were invited to register for an exam. +ExamCorrectHeading examname: Submit corrections for #{examname} + +ExamCorrectHeadParticipant: Participant +ExamCorrectHeadParticipantTooltip: Enter any string that uniquely identifies the participant. Their matriculation number is definitely unique, but also their name or a part of their matriculation number may already be unique for this participant (depending on the list of all participants). +ExamCorrectHeadPart exampartnum: #{exampartnum} +ExamCorrectHeadPartName exampartname: #{exampartname} +ExamCorrectHeadStatus: Status + +ExamCorrectButtonSend: Submit + SubmissionUserInvitationAccepted shn: You now participate in a submission for #{shn} SubmissionUserInvitationDeclined shn: You have declined the invitation to participate in a submission for #{shn} SubmissionUserInviteHeading shn: Invitation to participate in a submission for #{shn} diff --git a/src/Handler/Exam/Correct.hs b/src/Handler/Exam/Correct.hs index 39d433d23..0c4aa044c 100644 --- a/src/Handler/Exam/Correct.hs +++ b/src/Handler/Exam/Correct.hs @@ -4,6 +4,12 @@ module Handler.Exam.Correct import Import +import qualified Data.CaseInsensitive as CI (original) + +import Handler.Utils +import Handler.Utils.Exam (fetchExam) + + data CorrectInterfaceResponse = CorrectInterfaceSuccess CryptoUUIDUser Text (Maybe Text) (Map ExamPartNumber (Maybe Points)) -- { ciUserIdent :: CryptoUUIDUser @@ -34,7 +40,27 @@ deriveJSON defaultOptions getECorrectR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Html -getECorrectR = error "ECorrectR not implemented" +getECorrectR tid ssh csh examn = do + MsgRenderer mr <- getMsgRenderer + + (Entity _ Exam{..}, examParts) <- runDB $ do + exam@(Entity eId Exam{..}) <- fetchExam tid ssh csh examn + examParts <- sortOn (view $ _entityVal . _examPartNumber) <$> selectList [ ExamPartExam ==. eId ] [ Asc ExamPartName ] + return (exam, entityVal <$> examParts) + + let + heading = prependCourseTitle tid ssh csh $ (mr . MsgExamCorrectHeading . CI.original) examName + + ptsInput :: ExamPartNumber -> Widget + ptsInput n = do + name <- newIdent + fieldView (pointsField :: Field Handler Points) ("exam-correct__"<>(toPathPiece n)) name [("class","exam-correct__pts-input")] (Left "") False + + participantHeadTooltip = [whamlet| _{MsgExamCorrectHeadParticipantTooltip} |] + + siteLayoutMsg heading $ do + setTitleI heading + $(widgetFile "widgets/exam-correct") postECorrectR :: TermId -> SchoolId -> CourseShorthand -> ExamName -> Handler Value postECorrectR = error "ECorrectR not implemented" -- use returnJson & requireCheckJsonBody diff --git a/src/Model/Types/Exam.hs b/src/Model/Types/Exam.hs index afd09396e..282b13931 100644 --- a/src/Model/Types/Exam.hs +++ b/src/Model/Types/Exam.hs @@ -317,6 +317,8 @@ instance PathPiece ExamPartNumber where instance ToMarkup ExamPartNumber where toMarkup = toMarkup . view _ExamPartNumber +instance ToMessage ExamPartNumber where + toMessage = toMessage . view _ExamPartNumber pathPieceCsv ''ExamPartNumber pathPieceJSON ''ExamPartNumber diff --git a/src/Utils/Tooltip.hs b/src/Utils/Tooltip.hs new file mode 100644 index 000000000..5332868b6 --- /dev/null +++ b/src/Utils/Tooltip.hs @@ -0,0 +1,6 @@ +module Utils.Tooltip where + +import ClassyPrelude.Yesod hiding (Proxy) + +textTooltip :: forall site. WidgetFor site () -> WidgetFor site () -> WidgetFor site () +textTooltip ttHandle ttContent = $(whamletFile "templates/widgets/text-tooltip.hamlet") diff --git a/templates/widgets/exam-correct.hamlet b/templates/widgets/exam-correct.hamlet new file mode 100644 index 000000000..2e177884d --- /dev/null +++ b/templates/widgets/exam-correct.hamlet @@ -0,0 +1,30 @@ +$newline never + +
+ + + + + +
+ _{MsgExamCorrectHeadParticipant} + ^{iconTooltip participantHeadTooltip Nothing True} + $forall ExamPart{examPartNumber,examPartName} <- examParts + + $maybe name <- examPartName + + + _{MsgExamCorrectHeadPart examPartNumber} + + _{MsgExamCorrectHeadPartName name} + $nothing + _{MsgExamCorrectHeadPart examPartNumber} + _{MsgExamCorrectHeadStatus} +
+ + $forall ExamPart{examPartNumber} <- examParts + + ^{ptsInput examPartNumber} + +