-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph_constructor.hs
31 lines (26 loc) · 1.33 KB
/
graph_constructor.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module GraphConstructor where
import CSVReader
import Class
import TA
import WeeklyTimes
possiblePairings :: [Class] -> [TA] -> [PossiblePairing] -> [PossiblePairing]
possiblePairings classes tas existingPairs = concat $ map pairsWithClass classes
where
pairsWithClass c = map (pairWithClass c) (filter (taCanTeachClass existingPairs c) tas)
pairWithClass c ta = (c,ta)
taCanTeachClass :: [PossiblePairing] -> Class -> TA -> Bool
taCanTeachClass existingPairs c ta = alreadyTeachingSection && teachingQuotaWillBeObserved && (and $ map (taHasTimeOpenWithPairings ta existingPairs) $ meetingTimes c)
where
-- if no existing pairs, then TA is "already" teaching any section
alreadyTeachingSection = iter existingPairs
where
iter [] = True
iter ((c1,t1):rep) | (t1 == ta) && ((section c1) /= (section c)) = False
| otherwise = iter rep
teachingQuotaWillBeObserved = case (TA.classification ta) of x | x == HalfTime -> iter 2 existingPairs
| x == QuarterTime -> iter 1 existingPairs
where
iter 0 _ = False
iter _ [] = True
iter x ((c1,t1):ps) | (t1 == ta) && ((Class.classification c1) == (Class.classification c)) = iter (x-1) ps
| otherwise = iter x ps