diff --git a/messages/uniworx/categories/courses/participants/de-de-formal.msg b/messages/uniworx/categories/courses/participants/de-de-formal.msg index 0a169d688..023280fb6 100644 --- a/messages/uniworx/categories/courses/participants/de-de-formal.msg +++ b/messages/uniworx/categories/courses/participants/de-de-formal.msg @@ -7,5 +7,5 @@ CourseParticipantsRegisteredWithoutField n@Int: #{n} #{pluralDE n "Teilnehmeri:i ParticipantsCsvSheetName tid@TermId ssh@SchoolId: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Kursteilnehmer:innen CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen ParticipantsIntersectNotOne: Schnitt -AllUsersUnion: Vereinigung aller Teilnehmer:innen: -AllUsersIntersection: Schnitt aller Teilneher:innen: \ No newline at end of file +AllUsersUnion: Vereinigung aller Teilnehmer:innen +AllUsersIntersection: Schnitt aller Teilneher: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 3d110bd7e..e67ae634c 100644 --- a/messages/uniworx/categories/courses/participants/en-eu.msg +++ b/messages/uniworx/categories/courses/participants/en-eu.msg @@ -7,5 +7,5 @@ CourseParticipantsRegisteredWithoutField n: #{n} #{pluralEN n "participant was" ParticipantsCsvSheetName tid ssh: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Participants CourseParticipants n: Currently #{n} course #{pluralEN n "participant" "participants"} ParticipantsIntersectNotOne: Intersection -AllUsersUnion: Union of all participants: -AllUsersIntersection: Intersection of all participants: \ No newline at end of file +AllUsersUnion: Union of all participants +AllUsersIntersection: Intersection of all participants \ No newline at end of file diff --git a/src/Handler/Participants.hs b/src/Handler/Participants.hs index 8b8ac1c65..cbeb69ab2 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 allUsersUnion = Set.size.Set.unions $ Map.elems courseUsers + let allUsersUnion = Set.size . Set.unions $ Map.elems courseUsers let mapIntersect = mapIntersectNotOne courseUsers - let allUsersIntersection = Set.size.setIntersections $ Map.elems courseUsers + let allUsersIntersection = Set.size . setIntersections $ Map.elems courseUsers return (courses, intersections', mapIntersect, allUsersUnion, allUsersIntersection) let diff --git a/src/Utils.hs b/src/Utils.hs index e87607e96..0ba53c9fc 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -566,7 +566,7 @@ withoutSubsequenceBy cmp = go [] ---------- -- Sets -- ---------- --- all functions that used to be here are now in Utils/Set.hs +-- all functions that used to be here are now in Utils.Set ---------- -- Maps -- diff --git a/src/Utils/Set.hs b/src/Utils/Set.hs index a74a1db58..01794701e 100644 --- a/src/Utils/Set.hs +++ b/src/Utils/Set.hs @@ -19,27 +19,27 @@ import Control.Lens -- | cardinal number of an intersection of a set and a list of sets -setIntersectNotOne :: Ord a => Set.Set a -> [Set.Set a] -> Int +setIntersectNotOne :: Ord a => Set a -> [Set a] -> Int setIntersectNotOne _ [] = 0 setIntersectNotOne k r = Set.size $ Set.intersection k others where others = Set.unions r ----------------------------------- --- Functions for Particiants.hs -- ----------------------------------- +---------------------------------------- +-- Functions for Handler.Participants -- +---------------------------------------- -- | extracts from a map a list of values (sets) without one specific entry (a) -getAllElemsWithoutOne :: (Ord a) => Map.Map a (Set b) -> a -> [Set b] +getAllElemsWithoutOne :: (Ord a) => Map a (Set b) -> a -> [Set b] getAllElemsWithoutOne m cid = Map.elems $ Map.delete cid m -- | transforms values (sets) of a map to integers. The number gives information about how many entreis are not only in this one -mapIntersectNotOne :: (Ord a, Ord b) => Map.Map a (Set b) -> Map.Map a Int -mapIntersectNotOne m = loop (Map.toList m) Map.empty where - loop [] ino = ino - loop ((k,_):xs) ino = loop xs $ Map.insert k (setIntersectNotOne (Map.findWithDefault Set.empty k m) (getAllElemsWithoutOne m k)) ino - ------------------------------ --- Functions from Utils.hs -- ------------------------------ +mapIntersectNotOne :: forall a b. (Ord a, Ord b) => Map a (Set b) -> Map a Int +mapIntersectNotOne m = Map.mapWithKey f m where + f :: a -> Set b -> Int + f k _ = setIntersectNotOne (Map.findWithDefault Set.empty k m) (getAllElemsWithoutOne m k) + +-------------------------- +-- Functions from Utils -- +-------------------------- -- | Intersection of multiple sets. Returns empty set for empty input list setIntersections :: Ord a => [Set a] -> Set a diff --git a/templates/participants-intersect.hamlet b/templates/participants-intersect.hamlet index 573c8726f..eeaa544a0 100644 --- a/templates/participants-intersect.hamlet +++ b/templates/participants-intersect.hamlet @@ -30,8 +30,8 @@ $maybe (courses, intersections, mapIntersect, allUsersUnion, allUsersIntersectio
- _{MsgAllUsersUnion} + _{MsgAllUsersUnion}: # #{allUsersUnion}
- _{MsgAllUsersIntersection} + _{MsgAllUsersIntersection}: # #{allUsersIntersection} \ No newline at end of file