feat(participants): second version, Intersection added

This commit is contained in:
ros 2021-05-24 12:20:26 +02:00
parent 0a3fd23e22
commit 02354f0998
6 changed files with 21 additions and 8 deletions

View File

@ -7,4 +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
AllUsers: Vereinigung aller Teilnehmer:innen: AllUsersUnion: Vereinigung aller Teilnehmer:innen:
AllUsersIntersection: Schnitt aller Teilneher:innen:

View File

@ -7,4 +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
AllUsers: Union of all participants: AllUsersUnion: Union of all participants:
AllUsersIntersection: Intersection of all participants:

View File

@ -110,9 +110,10 @@ 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 allUsers = setUnionAll $ Map.elems courseUsers let allUsersUnion = setUnionAll $ Map.elems courseUsers
let mapIntersect = mapIntersectNotOne courseUsers let mapIntersect = mapIntersectNotOne courseUsers
return (courses, intersections', mapIntersect, allUsers) let allUsersIntersection = setIntersectionAll $ Map.elems courseUsers
return (courses, intersections', mapIntersect, allUsersUnion, allUsersIntersection)
let let
symmIntersection intersections lCid uCid = fromMaybe 0 $ intersections !? (lCid, uCid) <|> intersections !? (uCid, lCid) symmIntersection intersections lCid uCid = fromMaybe 0 $ intersections !? (lCid, uCid) <|> intersections !? (uCid, lCid)

View File

@ -1,5 +1,6 @@
module Utils.Set module Utils.Set
( setUnionAll ( setUnionAll
, setIntersectionAll
, setIntersectNotOne , setIntersectNotOne
, setIntersections , setIntersections
, setMapMaybe , setMapMaybe
@ -36,6 +37,12 @@ setUnionOthers [] = Set.empty
setUnionOthers [x] = x setUnionOthers [x] = x
setUnionOthers (x:y:z) = setUnionOthers (xy:z) where xy = Set.union x y setUnionOthers (x:y:z) = setUnionOthers (xy:z) where xy = Set.union x y
-- | cardinal number of a Set
setIntersectionAll :: Ord a => [Set.Set a] -> Int
setIntersectionAll [] = 0
setIntersectionAll [x] = Set.size x
setIntersectionAll (x:y:z) = setIntersectionAll (xy:z) where xy = Set.intersection x y
---------------------------------- ----------------------------------
-- Functions fro Particiants.hs -- -- Functions fro Particiants.hs --
---------------------------------- ----------------------------------

View File

@ -1,7 +1,7 @@
$newline never $newline never
<section> <section>
^{formWidget} ^{formWidget}
$maybe (courses, intersections, mapIntersect, allUsers) <- intersectionsRes $maybe (courses, intersections, mapIntersect, allUsersUnion, allUsersIntersection) <- intersectionsRes
<section> <section>
<div .scrolltable .scrolltable--bordered> <div .scrolltable .scrolltable--bordered>
<table .table .table--hover .table--condensed> <table .table .table--hover .table--condensed>
@ -30,5 +30,8 @@ $maybe (courses, intersections, mapIntersect, allUsers) <- intersectionsRes
<td .table__td .text--center .table__td--automatic> <td .table__td .text--center .table__td--automatic>
#{num} #{num}
<p> <p>
_{MsgAllUsers} _{MsgAllUsersUnion}
#{allUsers} #{allUsersUnion}
<p>
_{MsgAllUsersIntersection}
#{allUsersIntersection}