From 0a3fd23e22a81b3636fb3ac224dce52df3f752f2 Mon Sep 17 00:00:00 2001 From: ros Date: Mon, 24 May 2021 11:45:28 +0200 Subject: [PATCH] feat(participants): first finished verson --- .../categories/courses/participants/de-de-formal.msg | 4 +++- .../categories/courses/participants/en-eu.msg | 2 ++ src/Application.hs | 1 - src/Handler/Participants.hs | 6 +++--- src/Utils/Set.hs | 5 ++++- templates/participants-intersect.hamlet | 12 ++++++++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/messages/uniworx/categories/courses/participants/de-de-formal.msg b/messages/uniworx/categories/courses/participants/de-de-formal.msg index ae957c977..98827240b 100644 --- a/messages/uniworx/categories/courses/participants/de-de-formal.msg +++ b/messages/uniworx/categories/courses/participants/de-de-formal.msg @@ -5,4 +5,6 @@ ParticipantsIntersectCourseOption tid@TermId ssh@SchoolId coursen@CourseName !id ParticipantsIntersectCourses: Kurse CourseParticipantsRegisteredWithoutField n@Int: #{n} #{pluralDE n "Teilnehmeri:in wurde ohne assoziiertes Studienfach" "Teilnehmer:innen wurden ohne assoziierte Studienfächer"} angemeldet, da #{pluralDE n "kein eindeutiges Hauptfach bestimmt werden konnte" "keine eindeutigen Hauptfächer bestimmt werden konnten"} ParticipantsCsvSheetName tid@TermId ssh@SchoolId: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Kursteilnehmer:innen -CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen \ No newline at end of file +CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen +ParticipantsIntersectNotOne: Schnitt +AllUsers: Vereinigung aller Teilnehmer:innen: \ No newline at end of file diff --git a/messages/uniworx/categories/courses/participants/en-eu.msg b/messages/uniworx/categories/courses/participants/en-eu.msg index 59ea336fb..3183e260e 100644 --- a/messages/uniworx/categories/courses/participants/en-eu.msg +++ b/messages/uniworx/categories/courses/participants/en-eu.msg @@ -6,3 +6,5 @@ ParticipantsIntersectCourses: Courses CourseParticipantsRegisteredWithoutField n: #{n} #{pluralEN n "participant was" "participants were"} registered without #{pluralEN n "an associated field of study" "associated fields of study"}, because #{pluralEN n "it" "they"} could not be determined uniquely. ParticipantsCsvSheetName tid ssh: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Participants CourseParticipants n: Currently #{n} course #{pluralEN n "participant" "participants"} +ParticipantsIntersectNotOne: Intersection +AllUsers: Union of all participants: \ No newline at end of file diff --git a/src/Application.hs b/src/Application.hs index 0da9b1248..bcaf1edda 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -708,4 +708,3 @@ addPWEntry User{ userAuthentication = _, ..} (Text.encodeUtf8 -> pw) = db' $ do PWHashConf{..} <- getsYesod $ view _appAuthPWHash (AuthPWHash . Text.decodeUtf8 -> userAuthentication) <- liftIO $ makePasswordWith pwHashAlgorithm pw pwHashStrength void $ insert User{..} - diff --git a/src/Handler/Participants.hs b/src/Handler/Participants.hs index 3271fd9d5..319c758cc 100644 --- a/src/Handler/Participants.hs +++ b/src/Handler/Participants.hs @@ -110,9 +110,9 @@ postParticipantsIntersectR = do -> Set.size $ Map.findWithDefault Set.empty lCid courseUsers `Set.intersection` Map.findWithDefault Set.empty uCid courseUsers selfIntersections = Map.mapKeysMonotonic (\cid -> (cid, cid)) $ Set.size <$> courseUsers intersections' = Map.union intersections selfIntersections - -- let allUsers = setUnionAll $ Map.elems courseUsers - -- let mapIntersect = mapIntersectNotOne courseUsers - return (courses, intersections') + let allUsers = setUnionAll $ Map.elems courseUsers + let mapIntersect = mapIntersectNotOne courseUsers + return (courses, intersections', mapIntersect, allUsers) let symmIntersection intersections lCid uCid = fromMaybe 0 $ intersections !? (lCid, uCid) <|> intersections !? (uCid, lCid) diff --git a/src/Utils/Set.hs b/src/Utils/Set.hs index 5a59be271..2697b183a 100644 --- a/src/Utils/Set.hs +++ b/src/Utils/Set.hs @@ -36,7 +36,10 @@ setUnionOthers [] = Set.empty setUnionOthers [x] = x setUnionOthers (x:y:z) = setUnionOthers (xy:z) where xy = Set.union x y --- Fkt für Tabelle +---------------------------------- +-- Functions fro Particiants.hs -- +---------------------------------- + -- | list of values of a Map with Sets as values getAllUserIdsSetList :: Map.Map a (Set b) -> [Set b] getAllUserIdsSetList m = loop (Map.toList m) [] where diff --git a/templates/participants-intersect.hamlet b/templates/participants-intersect.hamlet index 8519ba33b..a2586a7a2 100644 --- a/templates/participants-intersect.hamlet +++ b/templates/participants-intersect.hamlet @@ -1,7 +1,7 @@ $newline never
^{formWidget} -$maybe (courses, intersections) <- intersectionsRes +$maybe (courses, intersections, mapIntersect, allUsers) <- intersectionsRes
@@ -11,6 +11,8 @@ $maybe (courses, intersections) <- intersectionsRes $forall Entity _ Course{courseTerm, courseSchool, courseShorthand} <- courses $forall (l, Entity lCid Course{courseTerm, courseSchool, courseShorthand}) <- lIxed courses @@ -23,4 +25,10 @@ $maybe (courses, intersections) <- intersectionsRes $with n <- symmIntersection intersections lCid uCid
#{courseTerm}-#{courseSchool}-#{courseShorthand} + + _{MsgParticipantsIntersectNotOne}
$if showNumber n lCid uCid - #{n} \ No newline at end of file + #{n} + $maybe num <- Map.lookup lCid mapIntersect + + #{num} +

+ _{MsgAllUsers} + #{allUsers} \ No newline at end of file