diff --git a/messages/uniworx/categories/courses/courses/de-de-formal.msg b/messages/uniworx/categories/courses/courses/de-de-formal.msg index 85acabc35..764150b5a 100644 --- a/messages/uniworx/categories/courses/courses/de-de-formal.msg +++ b/messages/uniworx/categories/courses/courses/de-de-formal.msg @@ -114,9 +114,9 @@ CourseParticipantsRegisterTutorialOption: Kursteilnehmer:innen zu Übungsgruppe CourseParticipantsRegisterTutorialField: Übungsgruppe CourseParticipantsRegisterTutorialFieldTip: Ist aktuell keine Übungsgruppe mit diesem Namen vorhanden, wird eine neue erstellt. Ist bereits eine Übungsgruppe mit diesem Namen vorhanden, werden die Kursteilnehmenden dieser hinzugefügt. CourseParticipantsRegisterNoneGiven: Es wurden keine anzumeldenden Personen angegeben! +CourseParticipantsRegisterNotFoundInAvs n@Int: #{n} #{pluralDE n "Person" "Personen"} konnten nicht im AVS gefunden werden CourseParticipantsInvited n@Int: #{n} #{pluralDE n "Einladung" "Einladungen"} per E-Mail verschickt -CourseParticipantsAddedByAvs n@Int: #{n} AVS-Nutzer erfolgreich angemeldet (TODO) CourseParticipantsAlreadyRegistered n@Int: #{n} #{pluralDE n "Teinehmer:in" "Teilnehmer:innen"} #{pluralDE n "ist" "sind"} bereits angemeldet CourseParticipantsAlreadyTutorialMember n@Int: #{n} #{pluralDE n "Teinehmer:in" "Teilnehmer:innen"} #{pluralDE n "ist" "sind"} bereits in dieser Übungsgruppe angemeldet CourseParticipantsRegistered n@Int: #{n} #{pluralDE n "Teinehmer:in" "Teilnehmer:innen"} erfolgreich angemeldet diff --git a/messages/uniworx/categories/courses/courses/en-eu.msg b/messages/uniworx/categories/courses/courses/en-eu.msg index 2fbddbd73..81d678c44 100644 --- a/messages/uniworx/categories/courses/courses/en-eu.msg +++ b/messages/uniworx/categories/courses/courses/en-eu.msg @@ -114,9 +114,9 @@ CourseParticipantsRegisterTutorialOption: Register course participants for tutor CourseParticipantsRegisterTutorialField: Tutorial CourseParticipantsRegisterTutorialFieldTip: If there is no tutorial with this name, a new one will be created. If there is a tutorial with this name, the course participants will be registered for it. CourseParticipantsRegisterNoneGiven: No persons given to register! +CourseParticipantsRegisterNotFoundInAvs n: #{n} #{pluralEN n "person" "persons"} could not be found in AVS CourseParticipantsInvited n: #{n} #{pluralEN n "invitation" "invitations"} sent via email -CourseParticipantsAddedByAvs n: #{n} AVS users successfully registered (TODO) CourseParticipantsAlreadyRegistered n: #{n} #{pluralEN n "participant is" "participants are"} already enrolled CourseParticipantsAlreadyTutorialMember n: #{n} #{pluralEN n "participant is" "participants are"} already registered for this tutorial CourseParticipantsRegistered n: Successfully registered #{n} #{pluralEN n "participant" "participants"} diff --git a/src/Handler/Course/ParticipantInvite.hs b/src/Handler/Course/ParticipantInvite.hs index b2c0ece45..8190b0905 100644 --- a/src/Handler/Course/ParticipantInvite.hs +++ b/src/Handler/Course/ParticipantInvite.hs @@ -27,7 +27,8 @@ import Generics.Deriving.Monoid (memptydefault, mappenddefault) data AddParticipantsResult = AddParticipantsResult - { aurAlreadyRegistered + { aurNotFound :: Set Text + , aurAlreadyRegistered , aurAlreadyTutorialMember , aurRegisterSuccess , aurTutorialSuccess :: Set UserId @@ -83,13 +84,18 @@ registerUsers cid usersToRegister = do -> tell . pure =<< messageI Error MsgCourseParticipantsRegisterNoneGiven | otherwise -- register retrieved users - -> tell <=< lift . addParticipantsResultMessages <=< lift . execWriterT $ mapM_ (registerUser cid) (catMaybes $ Map.elems avsUsers) + -> tell <=< lift . addParticipantsResultMessages <=< lift . execWriterT . mapM_ (registerUser cid) $ Map.toList avsUsers addParticipantsResultMessages :: (MonadHandler m, HandlerSite m ~ UniWorX) => AddParticipantsResult -> ReaderT (YesodPersistBackend UniWorX) m [Message] addParticipantsResultMessages AddParticipantsResult{..} = execWriterT $ do + unless (null aurNotFound) $ do + let modalTrigger = [whamlet|_{MsgCourseParticipantsRegisterNotFoundInAvs (length aurNotFound)}|] + modalContent = $(widgetFile "messages/courseInvitationNotFoundInAvs") + tell . pure <=< messageWidget Error $ msgModal modalTrigger (Right modalContent) + aurAlreadyRegistered' <- fmap sort (lift . mapM getJust $ Set.toList aurAlreadyRegistered) aurAlreadyTutorialMember' <- fmap sort (lift . mapM getJust $ Set.toList aurAlreadyTutorialMember) @@ -109,9 +115,10 @@ addParticipantsResultMessages AddParticipantsResult{..} = execWriterT $ do registerUser :: CourseId - -> UserId + -> (Text, Maybe UserId) -> WriterT AddParticipantsResult (YesodJobDB UniWorX) () -registerUser cid uid = exceptT tell tell $ do +registerUser _cid ( avsIdent, Nothing ) = tell $ mempty { aurNotFound = Set.singleton avsIdent } +registerUser cid (_avsIdent, Just uid) = exceptT tell tell $ do whenM (lift . lift $ exists [CourseParticipantCourse ==. cid, CourseParticipantUser ==. uid, CourseParticipantState ==. CourseParticipantActive]) $ throwError $ mempty { aurAlreadyRegistered = Set.singleton uid } diff --git a/templates/messages/courseInvitationNotFoundInAvs.hamlet b/templates/messages/courseInvitationNotFoundInAvs.hamlet new file mode 100644 index 000000000..558b8469a --- /dev/null +++ b/templates/messages/courseInvitationNotFoundInAvs.hamlet @@ -0,0 +1,12 @@ +$newline never + +$# SPDX-FileCopyrightText: 2022 Sarah Vaupel +$# +$# SPDX-License-Identifier: AGPL-3.0-or-later + +

+ _{MsgCourseParticipantsRegisterNotFoundInAvs (length aurNotFound)} +