feat(participants): corrections 2

This commit is contained in:
ros 2021-05-26 17:16:47 +02:00
parent fd11121544
commit d6ce0c47d9
6 changed files with 22 additions and 22 deletions

View File

@ -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 ParticipantsCsvSheetName tid@TermId ssh@SchoolId: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Kursteilnehmer:innen
CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen
ParticipantsIntersectNotOne: Schnitt ParticipantsIntersectNotOne: Schnitt
AllUsersUnion: Vereinigung aller Teilnehmer:innen: AllUsersUnion: Vereinigung aller Teilnehmer:innen
AllUsersIntersection: Schnitt aller Teilneher:innen: AllUsersIntersection: Schnitt aller Teilneher:innen

View File

@ -7,5 +7,5 @@ CourseParticipantsRegisteredWithoutField n: #{n} #{pluralEN n "participant was"
ParticipantsCsvSheetName tid ssh: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Participants ParticipantsCsvSheetName tid ssh: #{foldCase (termToText (unTermKey tid))}-#{foldedCase (unSchoolKey ssh)} Participants
CourseParticipants n: Currently #{n} course #{pluralEN n "participant" "participants"} CourseParticipants n: Currently #{n} course #{pluralEN n "participant" "participants"}
ParticipantsIntersectNotOne: Intersection ParticipantsIntersectNotOne: Intersection
AllUsersUnion: Union of all participants: AllUsersUnion: Union of all participants
AllUsersIntersection: Intersection of all participants: AllUsersIntersection: Intersection of all participants

View File

@ -110,9 +110,9 @@ postParticipantsIntersectR = do
-> Set.size $ Map.findWithDefault Set.empty lCid courseUsers `Set.intersection` Map.findWithDefault Set.empty uCid courseUsers -> 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 selfIntersections = Map.mapKeysMonotonic (\cid -> (cid, cid)) $ Set.size <$> courseUsers
intersections' = Map.union intersections selfIntersections 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 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) return (courses, intersections', mapIntersect, allUsersUnion, allUsersIntersection)
let let

View File

@ -566,7 +566,7 @@ withoutSubsequenceBy cmp = go []
---------- ----------
-- Sets -- -- 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 -- -- Maps --

View File

@ -19,27 +19,27 @@ import Control.Lens
-- | cardinal number of an intersection of a set and a list of sets -- | 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 _ [] = 0
setIntersectNotOne k r = Set.size $ Set.intersection k others where others = Set.unions r 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) -- | 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 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 -- | 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 :: forall a b. (Ord a, Ord b) => Map a (Set b) -> Map a Int
mapIntersectNotOne m = loop (Map.toList m) Map.empty where mapIntersectNotOne m = Map.mapWithKey f m where
loop [] ino = ino f :: a -> Set b -> Int
loop ((k,_):xs) ino = loop xs $ Map.insert k (setIntersectNotOne (Map.findWithDefault Set.empty k m) (getAllElemsWithoutOne m k)) ino f k _ = setIntersectNotOne (Map.findWithDefault Set.empty k m) (getAllElemsWithoutOne m k)
----------------------------- --------------------------
-- Functions from Utils.hs -- -- Functions from Utils --
----------------------------- --------------------------
-- | Intersection of multiple sets. Returns empty set for empty input list -- | Intersection of multiple sets. Returns empty set for empty input list
setIntersections :: Ord a => [Set a] -> Set a setIntersections :: Ord a => [Set a] -> Set a

View File

@ -30,8 +30,8 @@ $maybe (courses, intersections, mapIntersect, allUsersUnion, allUsersIntersectio
<td .table__td .text--center .table__td--automatic> <td .table__td .text--center .table__td--automatic>
#{num} #{num}
<p> <p>
_{MsgAllUsersUnion} _{MsgAllUsersUnion}: #
#{allUsersUnion} #{allUsersUnion}
<p> <p>
_{MsgAllUsersIntersection} _{MsgAllUsersIntersection}: #
#{allUsersIntersection} #{allUsersIntersection}