-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathData.elm
executable file
·187 lines (151 loc) · 3.94 KB
/
Data.elm
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
module Data exposing
( ChartTuple
, Class
, ClassCourse
, Course
, CourseCode
, CourseName
, Semester
, availableCourses
, classToChartTupleArray
, classToString
, courseToString
, defaultCourse
, findClassByCode
, findCourse
, lastSemesterFromCourse
, placeholderClass
, semesterString
)
import List.Extra exposing (find)
import Utils exposing (semesterRangeList)
type alias Course =
{ code : String
, name : String
, availableSemesters : List String
}
courseToString : Course -> String
courseToString course =
course.code ++ " - " ++ course.name
defaultCourse : Course
defaultCourse =
{ code = "208"
, name = "CIÊNCIA DA COMPUTAÇÃO"
, availableSemesters = semesterRangeList 2009 2019
}
availableCourses : List Course
availableCourses =
[ defaultCourse
, { code = "238", name = "SISTEMAS DA INFORMAÇÃO", availableSemesters = semesterRangeList 2009 2019 }
]
type alias Semester =
( Int, Int )
semesterString : Semester -> String
semesterString s =
String.fromInt (Tuple.first s) ++ String.fromInt (Tuple.second s)
lastSemesterFromCourse : Course -> String
lastSemesterFromCourse course =
Maybe.withDefault "error" (List.head course.availableSemesters)
type alias CourseCode =
String
type alias ClassCourse =
String
type alias CourseName =
String
type alias Class =
-- SP - Sufficient Presence
-- IP - Insufficient Presence
{ semester : String
, center : String
, centerName : String
, department : String
, departmentName : String
, classCourse : ClassCourse
, courseCode : CourseCode
, courseName : CourseName
, credits : Int
, grades100 : Int
, grades95to90 : Int
, grades85to80 : Int
, grades75to70 : Int
, grades65to60 : Int
, grades55to50 : Int
, grades45to40 : Int
, grades35to30 : Int
, grades25to20 : Int
, grades15to05 : Int
, grades0SP : Int
, grades0IP : Int
, studentsWithGrades : Int
, mentionOne : Int
, approved : Int
, disapprovedSP : Int
, disapprovedIP : Int
}
classToString : Class -> String
classToString c =
c.courseName
findCourse : String -> List Course -> Maybe Course
findCourse courseCode list =
find (\course -> course.code == courseCode) list
findClassByCode : ClassCourse -> CourseCode -> List Class -> Maybe Class
findClassByCode classCourse classCourseCode list =
find (\class -> class.classCourse == classCourse && class.courseCode == classCourseCode) list
type alias ChartTuple =
-- Tuple of grade group (-1 to 10) and number of students in that group. (-1 being IP)
( Int, Int )
classToChartTupleArray : Maybe Class -> List ChartTuple
classToChartTupleArray class =
let
c =
Maybe.withDefault placeholderClass class
in
[ ( -1, c.grades0IP )
, ( 0, c.grades0SP )
, ( 1, c.grades15to05 )
, ( 2, c.grades25to20 )
, ( 3, c.grades35to30 )
, ( 4, c.grades45to40 )
, ( 5, c.grades55to50 )
, ( 6, c.grades65to60 )
, ( 7, c.grades75to70 )
, ( 8, c.grades85to80 )
, ( 9, c.grades95to90 )
, ( 10, c.grades100 )
]
placeholderClass : Class
placeholderClass =
-- Used during loading
let
pStr =
"---"
pInt =
0
in
{ semester = pStr
, center = pStr
, centerName = pStr
, department = pStr
, departmentName = pStr
, classCourse = pStr
, courseCode = pStr
, courseName = pStr
, credits = pInt
, grades100 = pInt
, grades95to90 = pInt
, grades85to80 = pInt
, grades75to70 = pInt
, grades65to60 = pInt
, grades55to50 = pInt
, grades45to40 = pInt
, grades35to30 = pInt
, grades25to20 = pInt
, grades15to05 = pInt
, grades0SP = pInt
, grades0IP = pInt
, studentsWithGrades = pInt
, mentionOne = pInt
, approved = pInt
, disapprovedSP = pInt
, disapprovedIP = pInt
}