diff --git a/src/Handler/Exam/AddUser.hs b/src/Handler/Exam/AddUser.hs index b34b52288..dc6e80202 100644 --- a/src/Handler/Exam/AddUser.hs +++ b/src/Handler/Exam/AddUser.hs @@ -27,7 +27,8 @@ data AddRecipientsResult = AddRecipientsResult { aurAlreadyRegistered , aurNoUniquePrimaryField , aurNoCourseRegistration - , aurSuccess :: [UserEmail] + , aurSuccess + , aurSuccessCourse :: [UserEmail] } deriving (Read, Show, Generic, Typeable) instance Monoid AddRecipientsResult where @@ -87,7 +88,7 @@ postEAddUserR tid ssh csh examn = do processUsers :: Entity Exam -> (UTCTime, Bool, Maybe ExamOccurrenceId, Set (Either UserEmail UserId)) -> WriterT [Message] Handler () processUsers (Entity eid Exam{..}) (deadline, registerCourse, occId, users) = do let (emails,uids) = partitionEithers $ Set.toList users - AddRecipientsResult alreadyRegistered registeredNoField noCourseRegistration registeredOneField <- lift . runDBJobs $ do + AddRecipientsResult{..} <- lift . runDBJobs $ do -- send Invitation eMails to unkown users sinkInvitationsF examRegistrationInvitationConfig [(mail,eid,(InvDBDataExamRegistration occId deadline registerCourse, InvTokenDataExamRegistration)) | mail <- emails] -- register known users @@ -96,21 +97,21 @@ postEAddUserR tid ssh csh examn = do unless (null emails) $ tell . pure <=< messageI Success . MsgExamParticipantsInvited $ length emails - unless (null alreadyRegistered) $ - tell . pure <=< messageI Success . MsgExamRegistrationParticipantsRegistered $ length registeredOneField + unless (null aurSuccess) $ + tell . pure <=< messageI Success . MsgExamRegistrationParticipantsRegistered $ length aurSuccess - unless (null registeredNoField) $ do - let modalTrigger = [whamlet|_{MsgExamRegistrationRegisteredWithoutField (length registeredNoField)}|] + unless (null aurNoUniquePrimaryField) $ do + let modalTrigger = [whamlet|_{MsgExamRegistrationRegisteredWithoutField (length aurNoUniquePrimaryField)}|] modalContent = $(widgetFile "messages/examRegistrationInvitationRegisteredWithoutField") tell . pure <=< messageWidget Warning $ msgModal modalTrigger (Right modalContent) - unless (null noCourseRegistration) $ do - let modalTrigger = [whamlet|_{MsgExamRegistrationNotRegisteredWithoutCourse (length noCourseRegistration)}|] + unless (null aurNoCourseRegistration) $ do + let modalTrigger = [whamlet|_{MsgExamRegistrationNotRegisteredWithoutCourse (length aurNoCourseRegistration)}|] modalContent = $(widgetFile "messages/examRegistrationInvitationNotRegisteredWithoutCourse") tell . pure <=< messageWidget Error $ msgModal modalTrigger (Right modalContent) - unless (null registeredOneField) $ - tell . pure <=< messageI Success . MsgExamRegistrationAndCourseParticipantsRegistered $ length registeredOneField + unless (null aurSuccessCourse) $ + tell . pure <=< messageI Success . MsgExamRegistrationAndCourseParticipantsRegistered $ length aurSuccessCourse registerUser :: CourseId -> ExamId -> Bool -> Maybe ExamOccurrenceId -> UserId -> WriterT AddRecipientsResult (YesodJobDB UniWorX) () registerUser cid eid registerCourse occId uid = exceptT tell tell $ do @@ -149,6 +150,6 @@ postEAddUserR tid ssh csh examn = do return $ case courseParticipantField of Nothing -> mempty { aurNoUniquePrimaryField = pure userEmail } - Just _ -> mempty { aurSuccess = pure userEmail } + Just _ -> mempty { aurSuccessCourse = pure userEmail } diff --git a/templates/messages/examRegistrationInvitationNotRegisteredWithoutCourse.hamlet b/templates/messages/examRegistrationInvitationNotRegisteredWithoutCourse.hamlet index 197c4e906..b67450643 100644 --- a/templates/messages/examRegistrationInvitationNotRegisteredWithoutCourse.hamlet +++ b/templates/messages/examRegistrationInvitationNotRegisteredWithoutCourse.hamlet @@ -1,5 +1,5 @@

- _{MsgExamRegistrationNotRegisteredWithoutCourse (length registeredNoField)} + _{MsgExamRegistrationNotRegisteredWithoutCourse (length aurNoCourseRegistration)}