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
CourseParticipants n@Int: Derzeit #{n} angemeldete Kursteilnehmer:innen
ParticipantsIntersectNotOne: Schnitt
AllUsersUnion: Vereinigung aller Teilnehmer:innen:
AllUsersIntersection: Schnitt aller Teilneher:innen:
AllUsersUnion: Vereinigung aller Teilnehmer: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
CourseParticipants n: Currently #{n} course #{pluralEN n "participant" "participants"}
ParticipantsIntersectNotOne: Intersection
AllUsersUnion: Union of all participants:
AllUsersIntersection: Intersection of all participants:
AllUsersUnion: Union 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
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

View File

@ -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 --

View File

@ -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

View File

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