garizz commited on
Commit
1987ae5
·
1 Parent(s): d95ac12

Upload 12 files

Browse files
Files changed (12) hide show
  1. ConsoleApp.py +23 -0
  2. GaSchedule.json +29 -0
  3. GaSchedule1.json +317 -0
  4. HtmlOutput.py +181 -0
  5. LICENSE +21 -0
  6. ctdt_ds.csv +58 -0
  7. data_stu.csv +0 -0
  8. logo-vector-IU-01.png +0 -0
  9. processing.py +271 -0
  10. reprocessing.ipynb +589 -0
  11. requirements.txt +5 -0
  12. session_state.py +105 -0
ConsoleApp.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pathlib
2
+ import time
3
+ from model.Configuration import Configuration
4
+ from algorithm.NsgaII import NsgaII
5
+ import streamlit as st
6
+
7
+ from HtmlOutput import HtmlOutput
8
+
9
+
10
+ def main(file_name):
11
+ start_time = int(round(time.time() * 1000))
12
+ configuration = Configuration()
13
+ target_file = str(pathlib.Path().absolute()) + file_name
14
+ configuration.parseFile(target_file)
15
+ alg = NsgaII(configuration)
16
+ # alg = Hgasso(configuration)
17
+ alg.run()
18
+ html_result = HtmlOutput.getResult(alg.result)
19
+ # st.markdown(html_result, unsafe_allow_html=True)
20
+ seconds = (int(round(time.time() * 1000)) - start_time) / 1000.0
21
+ st.write("\nCompleted in {} secs.\n".format(seconds))
22
+ return html_result
23
+
GaSchedule.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "prof": {
4
+ "id": 84,
5
+ "name": "Le Hai Duong"
6
+ }
7
+ },
8
+ {
9
+ "course": {
10
+ "id": 1,
11
+ "name": "Operating Systems"
12
+ }
13
+ },
14
+ {
15
+ "group": {
16
+ "id": 1,
17
+ "size": 80
18
+ }
19
+ },
20
+ {
21
+ "class": {
22
+ "professor": 84,
23
+ "course": 1,
24
+ "duration": 3,
25
+ "group": 1,
26
+ "lab": false
27
+ }
28
+ }
29
+ ]
GaSchedule1.json ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "prof": {
4
+ "id": 174,
5
+ "name": "Dao Tran Hoang Chau"
6
+ }
7
+ },
8
+ {
9
+ "course": {
10
+ "id": 1,
11
+ "name": "Functional Programming"
12
+ }
13
+ },
14
+ {
15
+ "group": {
16
+ "id": 1,
17
+ "size": 10
18
+ }
19
+ },
20
+ {
21
+ "class": {
22
+ "professor": 174,
23
+ "course": 1,
24
+ "duration": 3,
25
+ "group": 1,
26
+ "lab": false
27
+ }
28
+ },
29
+ {
30
+ "prof": {
31
+ "id": 119,
32
+ "name": "Tran Manh Ha"
33
+ }
34
+ },
35
+ {
36
+ "course": {
37
+ "id": 2,
38
+ "name": "Operating Systems"
39
+ }
40
+ },
41
+ {
42
+ "group": {
43
+ "id": 2,
44
+ "size": 90
45
+ }
46
+ },
47
+ {
48
+ "class": {
49
+ "professor": 119,
50
+ "course": 2,
51
+ "duration": 3,
52
+ "group": 2,
53
+ "lab": false
54
+ }
55
+ },
56
+ {
57
+ "group": {
58
+ "id": 3,
59
+ "size": 30
60
+ }
61
+ },
62
+ {
63
+ "class": {
64
+ "professor": 119,
65
+ "course": 2,
66
+ "duration": 4,
67
+ "group": 3,
68
+ "lab": true
69
+ }
70
+ },
71
+ {
72
+ "prof": {
73
+ "id": 213,
74
+ "name": "Nguyen Tien Dung"
75
+ }
76
+ },
77
+ {
78
+ "group": {
79
+ "id": 4,
80
+ "size": 30
81
+ }
82
+ },
83
+ {
84
+ "class": {
85
+ "professor": 213,
86
+ "course": 2,
87
+ "duration": 4,
88
+ "group": 4,
89
+ "lab": true
90
+ }
91
+ },
92
+ {
93
+ "group": {
94
+ "id": 5,
95
+ "size": 30
96
+ }
97
+ },
98
+ {
99
+ "class": {
100
+ "professor": 213,
101
+ "course": 2,
102
+ "duration": 4,
103
+ "group": 5,
104
+ "lab": true
105
+ }
106
+ },
107
+ {
108
+ "prof": {
109
+ "id": 74,
110
+ "name": "Nguyen Van Sinh"
111
+ }
112
+ },
113
+ {
114
+ "course": {
115
+ "id": 3,
116
+ "name": "IT Project Management"
117
+ }
118
+ },
119
+ {
120
+ "group": {
121
+ "id": 6,
122
+ "size": 35
123
+ }
124
+ },
125
+ {
126
+ "class": {
127
+ "professor": 74,
128
+ "course": 3,
129
+ "duration": 3,
130
+ "group": 6,
131
+ "lab": false
132
+ }
133
+ },
134
+ {
135
+ "group": {
136
+ "id": 7,
137
+ "size": 35
138
+ }
139
+ },
140
+ {
141
+ "class": {
142
+ "professor": 74,
143
+ "course": 3,
144
+ "duration": 4,
145
+ "group": 7,
146
+ "lab": true
147
+ }
148
+ },
149
+ {
150
+ "prof": {
151
+ "id": 84,
152
+ "name": "Le Hai Duong"
153
+ }
154
+ },
155
+ {
156
+ "course": {
157
+ "id": 4,
158
+ "name": "Introduction to Computing"
159
+ }
160
+ },
161
+ {
162
+ "group": {
163
+ "id": 8,
164
+ "size": 35
165
+ }
166
+ },
167
+ {
168
+ "class": {
169
+ "professor": 84,
170
+ "course": 4,
171
+ "duration": 3,
172
+ "group": 8,
173
+ "lab": false
174
+ }
175
+ },
176
+ {
177
+ "prof": {
178
+ "id": 19,
179
+ "name": "Huynh Kha Tu"
180
+ }
181
+ },
182
+ {
183
+ "course": {
184
+ "id": 5,
185
+ "name": "Digital Logic Design"
186
+ }
187
+ },
188
+ {
189
+ "group": {
190
+ "id": 9,
191
+ "size": 90
192
+ }
193
+ },
194
+ {
195
+ "class": {
196
+ "professor": 19,
197
+ "course": 5,
198
+ "duration": 3,
199
+ "group": 9,
200
+ "lab": false
201
+ }
202
+ },
203
+ {
204
+ "prof": {
205
+ "id": 182,
206
+ "name": "Tran Thanh Tung"
207
+ }
208
+ },
209
+ {
210
+ "course": {
211
+ "id": 6,
212
+ "name": "Object-Oriented Programming"
213
+ }
214
+ },
215
+ {
216
+ "group": {
217
+ "id": 10,
218
+ "size": 90
219
+ }
220
+ },
221
+ {
222
+ "class": {
223
+ "professor": 182,
224
+ "course": 6,
225
+ "duration": 3,
226
+ "group": 10,
227
+ "lab": false
228
+ }
229
+ },
230
+ {
231
+ "group": {
232
+ "id": 11,
233
+ "size": 30
234
+ }
235
+ },
236
+ {
237
+ "class": {
238
+ "professor": 213,
239
+ "course": 6,
240
+ "duration": 4,
241
+ "group": 11,
242
+ "lab": true
243
+ }
244
+ },
245
+ {
246
+ "group": {
247
+ "id": 12,
248
+ "size": 30
249
+ }
250
+ },
251
+ {
252
+ "class": {
253
+ "professor": 213,
254
+ "course": 6,
255
+ "duration": 4,
256
+ "group": 12,
257
+ "lab": true
258
+ }
259
+ },
260
+ {
261
+ "group": {
262
+ "id": 13,
263
+ "size": 30
264
+ }
265
+ },
266
+ {
267
+ "class": {
268
+ "professor": 213,
269
+ "course": 6,
270
+ "duration": 4,
271
+ "group": 13,
272
+ "lab": true
273
+ }
274
+ },
275
+ {
276
+ "room": {
277
+ "name": "A1.309",
278
+ "lab": false,
279
+ "size": "90"
280
+ }
281
+ },
282
+ {
283
+ "room": {
284
+ "name": "L107",
285
+ "lab": false,
286
+ "size": 40
287
+ }
288
+ },
289
+ {
290
+ "room": {
291
+ "name": "A2.401",
292
+ "lab": false,
293
+ "size": 40
294
+ }
295
+ },
296
+ {
297
+ "room": {
298
+ "name": "LA1.605",
299
+ "lab": true,
300
+ "size": 35
301
+ }
302
+ },
303
+ {
304
+ "room": {
305
+ "name": "LA1.607",
306
+ "lab": true,
307
+ "size": 35
308
+ }
309
+ },
310
+ {
311
+ "room": {
312
+ "name": "La1.606",
313
+ "lab": true,
314
+ "size": 35
315
+ }
316
+ }
317
+ ]
HtmlOutput.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from model.Constant import Constant
2
+ from model.Reservation import Reservation
3
+ from collections import defaultdict
4
+ import streamlit as st
5
+ import json
6
+ class HtmlOutput:
7
+ ROOM_COLUMN_NUMBER = Constant.DAYS_NUM + 1
8
+ ROOM_ROW_NUMBER = Constant.DAY_HOURS + 1
9
+ # COLOR1 = "#319378"
10
+ # COLOR2 = "#CE0000"
11
+ CRITERIAS = ('R', 'S', 'L', 'P', 'G')
12
+ # CRITERIAS_DESCR = ("Current room has {any}overlapping", "Current room has {any}enough seats",
13
+ # "Current room with {any}enough computers if they are required",
14
+ # "Professors have {any}overlapping classes", "Student groups has {any}overlapping classes")
15
+ PERIODS = (
16
+ "","8 - 8h50", "8h50 - 9h40", "9h40 - 10h30", "10h35 - 11h25", "11h25 - 12h15", "12h15 - 13h05", "13h15 - 14h05", "14h05 - 14h55", "14h55 - 15h45", "15h50 - 16h40", "16h40 - 17h30")
17
+ WEEK_DAYS = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
18
+
19
+ @staticmethod
20
+ def getCourseClass(cc, criterias, ci):
21
+
22
+
23
+
24
+
25
+ sb = []
26
+ sb.append(" <span style='color:#00FFFF' title=''> <b>MH: <b/> </span>")
27
+ sb.append(cc.Course.Name)
28
+ sb.append("<br /> <span style='color:#00FFFF' title=''> <b>GV: <b/> </span>")
29
+ sb.append(cc.Professor.Name)
30
+ sb.append("<br /> <span style='color:#00FFFF' title=''> <b>Room: <b/> </span>")
31
+ # sb.append(room.Name)
32
+ # sb.append("/".join(map(lambda grp: grp.Name, cc.Groups)),)
33
+
34
+ if cc.LabRequired:
35
+ sb.append(" <br /><span style='color:#00FFFF' title=''> <b>Lab <b/> </span>")
36
+
37
+
38
+ return sb
39
+
40
+ @staticmethod
41
+ def generateTimeTable(solution, slot_table):
42
+ ci = 0
43
+
44
+ time_table = defaultdict(list)
45
+ items = solution.classes.items
46
+ ROOM_COLUMN_NUMBER = HtmlOutput.ROOM_COLUMN_NUMBER
47
+ getCourseClass = HtmlOutput.getCourseClass
48
+
49
+ for cc, reservation_index in items():
50
+ reservation = Reservation.parse(reservation_index)
51
+ # coordinate of time-space slot
52
+ dayId = reservation.Day + 1
53
+ dur = cc.Duration
54
+ periodId = reservation.Time + 1
55
+ if dur == 3:
56
+ if 3 < periodId <= 6:
57
+ periodId = 4
58
+ elif 1 <= periodId <= 3:
59
+ periodId = 1
60
+ else:
61
+ periodId = 7
62
+ elif dur == 4 or dur == 5:
63
+ if periodId <= 6:
64
+ periodId = 1
65
+ else:
66
+ periodId = 7
67
+ else:
68
+ periodId = 1
69
+ roomId = reservation.Room
70
+ key = (periodId, roomId)
71
+
72
+ if key in slot_table:
73
+ room_duration = slot_table[key]
74
+ else:
75
+ room_duration = ROOM_COLUMN_NUMBER * [0]
76
+ slot_table[key] = room_duration
77
+ room_duration[dayId] = dur
78
+
79
+ for m in range(1, dur):
80
+ next_key = (periodId + m, roomId)
81
+ if next_key not in slot_table:
82
+ slot_table[next_key] = ROOM_COLUMN_NUMBER * [0]
83
+ if slot_table[next_key][dayId] < 1:
84
+ slot_table[next_key][dayId] = -1
85
+
86
+ if key in time_table:
87
+ room_schedule = time_table[key]
88
+ else:
89
+ room_schedule = ROOM_COLUMN_NUMBER * [None]
90
+ time_table[key] = room_schedule
91
+
92
+ room_schedule[dayId] = "".join(getCourseClass(cc, solution.criteria, ci))
93
+ ci += len(HtmlOutput.CRITERIAS)
94
+ return time_table
95
+
96
+ @staticmethod
97
+ def getHtmlCell(content, rowspan):
98
+ if rowspan == 0:
99
+ return "<td></td>"
100
+
101
+ if content is None:
102
+ return ""
103
+ sb = []
104
+ if rowspan > 1:
105
+ sb.append("<td style='border: .25em solid white; padding: .25em' rowspan='")
106
+ sb.append(rowspan)
107
+ sb.append("'>")
108
+ else:
109
+ sb.append("<td style='border: .25em solid white; padding: .25em'>")
110
+ sb.append(content)
111
+ sb.append("</td>")
112
+ return "".join(str(v) for v in sb)
113
+
114
+ @staticmethod
115
+ def getResult(solution):
116
+ configuration = solution.configuration
117
+ nr = configuration.numberOfRooms
118
+ getRoomById = configuration.getRoomById
119
+
120
+ slot_table = defaultdict(list)
121
+ time_table = HtmlOutput.generateTimeTable(solution, slot_table) # Tuple[0] = time, Tuple[1] = roomId
122
+ # st.markdown(slot_table)
123
+ if not slot_table or not time_table:
124
+ return ""
125
+
126
+ sb = []
127
+ for roomId in range(nr):
128
+ temp = []
129
+ room = getRoomById(roomId)
130
+ for periodId in range(HtmlOutput.ROOM_ROW_NUMBER):
131
+ if periodId == 0:
132
+ temp.append("<div id='room_")
133
+ temp.append(room.Name)
134
+ temp.append("' style='padding: 0.5em'>\n")
135
+ temp.append("<table style=' border: .25em solid white; text-align: center; width: 100%'>\n")
136
+ temp.append(HtmlOutput.getTableHeader(room))
137
+ else:
138
+ key = (periodId, roomId)
139
+ room_duration = slot_table[key] if key in slot_table.keys() else None
140
+ room_schedule = time_table[key] if key in time_table.keys() else None
141
+ temp.append("<tr>")
142
+ for dayId in range(HtmlOutput.ROOM_COLUMN_NUMBER):
143
+ if dayId == 0:
144
+ temp.append("<th style='color: #00FFFF; border: .25em solid white; text-align: center; padding: .25em' scope='row' colspan='2'>")
145
+ temp.append(HtmlOutput.PERIODS[periodId])
146
+ temp.append("</th>\n")
147
+ continue
148
+
149
+ if room_schedule is None and room_duration is None:
150
+ continue
151
+
152
+ content = room_schedule[dayId] if room_schedule is not None else None
153
+ temp.append(HtmlOutput.getHtmlCell(content, room_duration[dayId]))
154
+ temp.append("</tr>\n")
155
+
156
+ if periodId == HtmlOutput.ROOM_ROW_NUMBER - 1:
157
+ temp.append("</table>\n</div>\n")
158
+ temp = json.dumps(temp).replace(" <b>Room: <b/> </span>", "<b> <b>Room: <b/> </span>{}".format(room.Name))
159
+ temp = json.loads(temp)
160
+ sb = sb + temp
161
+ return "".join(str(v) for v in sb)
162
+
163
+
164
+
165
+ @staticmethod
166
+ def getTableHeader(room):
167
+ sb = ["<tr><th style='color:#00FFFF; border: .25em solid white' scope='col' colspan='2'>Room: ", room.Name, "</th>\n"]
168
+ for weekDay in HtmlOutput.WEEK_DAYS:
169
+ sb.append("<th style='color: #00FFFF; border: .25em solid white; padding: .25em; width: 15%; text-align: center' scope='col' rowspan='2'>")
170
+ sb.append(weekDay)
171
+ sb.append("</th>\n")
172
+ sb.append("</tr>\n")
173
+ sb.append("<tr>\n")
174
+ sb.append("<th style='color:#00FFFF; border: .25em solid white; padding: .25em'>Lab: ")
175
+ sb.append("Yes" if room.Lab else "No")
176
+ sb.append("</th>\n")
177
+ sb.append("<th style='color:#00FFFF; border: .25em solid white; padding: .25em'>Seats: ")
178
+ sb.append(room.NumberOfSeats)
179
+ sb.append("</th>\n")
180
+ sb.append("</tr>\n")
181
+ return "".join(str(v) for v in sb)
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Miller Cy Chan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ctdt_ds.csv ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ STT,MaMH,Course Name,Credits,Số TCHP,Expect Year,Sem,Elective,Đã học
2
+ 1,EN072IU,Reading & Writing IE1,11,11,2019,1,FALSE,X
3
+ 2,EN073IU,Listening & Speaking IE1,11,11,2019,1,FALSE,X
4
+ 3,PT001IU,Physical Training 1,3,3,2019,1,FALSE,X
5
+ 4,EN074IU,Reading & Writing IE2,8,8,2019,2,FALSE,X
6
+ 5,EN075IU,Listening & Speaking IE2,8,8,2019,2,FALSE,X
7
+ 6,PT002IU,Physical Training 2,3,3,2019,2,FALSE,X
8
+ 7,IT149IU,Fundamentals of Programming,4,4,2019,2,FALSE,IT116IU
9
+ 8,MA001IU,Calculus 1,4,4,2019,3,FALSE,X
10
+ 9,IT135IU,Introduction to Data Science,3,3,2019,3,FALSE,X
11
+ 10,PE015IU,Philosophy of Marxism and Leninism,3,3,2019,3,FALSE,X
12
+ 11,PE016IU,Political economics of Marxism and Leninism,2,2,2019,3,FALSE,X
13
+ 12,CH011IU,Chemistry for Engineers,3,3,2020,1,FALSE,X
14
+ 13,IT069IU,Object-Oriented Programming,4,4,2020,1,FALSE,X
15
+ 14,PE017IU,Scientific socialism,2,2,2020,1,FALSE,X
16
+ 15,CH012IU,Chemistry Laboratory,1,1,2020,1,FALSE,X
17
+ 16,PH013IU,Physics 1,2,2,2020,1,FALSE,X
18
+ 17,MA003IU,Calculus 2,4,4,2020,1,FALSE,X
19
+ 18,IT137IU,Data Analysis,4,4,2020,1,FALSE,X
20
+ 19,IT013IU,Algorithms & Data Structures,4,4,2020,2,FALSE,X
21
+ 20,IT090IU,Object-Oriented Analysis and Design,4,4,2020,2,FALSE,X
22
+ 21,IT079IU,Principles of Database Management,4,4,2020,2,FALSE,X
23
+ 22,IT136IU,Regression Analysis,4,4,2020,2,FALSE,X
24
+ 23,IT138IU,Data Science and Data Visualization,4,4,2020,2,FALSE,X
25
+ 24,IT151IU,Statistical Methods,3,3,2020,2,FALSE,X
26
+ 25,EN008IU,Listening AE1,2,2,2020,3,FALSE,X
27
+ 26,PH014IU,Physics 2,2,2,2020,3,FALSE,X
28
+ 27,PE018IU,History of Vietnamese Communist Party,2,2,2020,3,FALSE,X
29
+ 28,EN007IU,Writing AE1,2,2,2020,3,FALSE,X
30
+ 29,EN012IU,Speaking AE2,2,2,2021,1,FALSE,X
31
+ 30,EN011IU,Writing AE2,2,2,2021,1,FALSE,X
32
+ 31,IT139IU,Scalable and Distributed Computing,4,4,2021,1,FALSE,X
33
+ 32,IT140IU,Fundamental Concepts of Data Security,4,4,2021,1,FALSE,X
34
+ 33,MA026IU,"Probability, Statistic & Random Process",3,3,2021,1,FALSE,X
35
+ 34,PE008IU,Critical Thinking,3,3,2021,1,FALSE,X
36
+ 35,PE019IU,Ho Chi Minh's Thoughts,2,2,2021,1,FALSE,X
37
+ 36,IT154IU,Linear Algebra,3,3,2021,1,FALSE,X
38
+ 37,IT097IU,Introduction to Artificial Intelligence,4,4,2021,2,FALSE,X
39
+ 38,IT142IU,Analytics for Observational Data,4,4,2021,2,FALSE,X
40
+ 39,IT132IU,Introduction to Data Mining,4,4,2021,2,FALSE,X
41
+ 40,IT082IU,Internship,3,3,2021,3,FALSE,X
42
+ 41,PE014IU,Environmental Science,3,3,2022,1,FALSE,X
43
+ 42,IS021IU,Deterministic models in Operations Research,3,3,2022,1,TRUE,
44
+ 43,IT145IU,Decision Support System,4,4,2022,1,TRUE,X
45
+ 44,IT083IU,Special Study of the Field,3,3,2022,1,FALSE,X
46
+ 45,IT144IU,Business Process Analysis,4,4,2022,1,TRUE,
47
+ 46,IT146IU,Theory of Networks,4,4,2022,1,TRUE,
48
+ 47,IT143IU,Fundamentals of Big Data Technology,4,4,2022,1,FALSE,X
49
+ 48,IT148IU,Experimental Design,4,4,2022,2,TRUE,
50
+ 49,IT150IU,Blockchain,4,4,2022,2,TRUE,
51
+ 50,ISME105IU,Optimization,3,3,2022,2,TRUE,
52
+ 51,IT058IU,Thesis,10,10,2022,2,FALSE,X
53
+ 52,IT094IU,Information System Management,4,4,2022,2,TRUE,X
54
+ 53,IT120IU,Entrepreneurship,3,3,2022,2,TRUE,X
55
+ 54,IT141IU,Big Data Applications: Machine Learning at Scale,4,4,2022,2,TRUE,
56
+ 55,IT056IU,IT Project Management,4,4,2022,2,TRUE,
57
+ 56,IT152IU,Data Mining for IoT,4,4,2022,2,TRUE,
58
+ 57,IT147IU,Mobile Cloud Computing,4,4,2022,2,TRUE,
data_stu.csv ADDED
The diff for this file is too large to render. See raw diff
 
logo-vector-IU-01.png ADDED
processing.py ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import json
4
+ import streamlit as st
5
+ from ConsoleApp import main
6
+ # from ConsoleApp import main_filter
7
+
8
+ # from ConsoleApp import get_filter
9
+ import sys
10
+ import hashlib
11
+ import json
12
+ import ast
13
+ import traceback
14
+ import hashlib
15
+ from PIL import Image
16
+ from itertools import chain
17
+ from bs4 import BeautifulSoup
18
+ # from session_state import SessionState
19
+
20
+
21
+
22
+ def load_file(df2, df_room):
23
+
24
+ list_course = []
25
+ index_count_course_id = 0
26
+ list_prof = []
27
+ index_count_prof_id = 0
28
+ for index1, row1 in df2.iterrows():
29
+ if row1['Course_Name'] not in list_course:
30
+ df2.at[index1, 'Course_id'] = index_count_course_id + 1
31
+ index_count_course_id += 1
32
+ list_course.append(row1['Course_Name'])
33
+ else:
34
+ df2.at[index1, 'Course_id'] = index_count_course_id
35
+
36
+ if row1['Prof_Name'] not in list_prof:
37
+ df2.at[index1, 'Prof_id'] = index_count_prof_id + 1
38
+ index_count_prof_id += 1
39
+ list_prof.append(row1['Prof_Name'])
40
+ else:
41
+ df2.at[index1, 'Prof_id'] = index_count_prof_id
42
+
43
+ # create list of dictionaries representing each object in the JSON file
44
+ objects = []
45
+ for index, row in df2.iterrows():
46
+ if row['Prof_id'] != '':
47
+ # create professor object
48
+ prof = {
49
+ "prof": {
50
+ "id": row['Prof_id'],
51
+ "name": row['Prof_Name']
52
+ }
53
+ }
54
+ if prof not in objects:
55
+ objects.append(prof)
56
+ if row['Course_id'] != '':
57
+ # create course object
58
+ course = {
59
+ "course": {
60
+ "id": row['Course_id'],
61
+ "name": row['Course_Name']
62
+ }
63
+ }
64
+ if course not in objects:
65
+ objects.append(course)
66
+ if row['Group_id'] != '':
67
+ # create group object
68
+ group = {
69
+ "group": {
70
+ "id": row['Group_id'],
71
+ "size": row['Size_Course']
72
+ }
73
+ }
74
+ # if group not in objects:
75
+ objects.append(group)
76
+ if row['Prof_id'] != '' and row['Course_id'] != '':
77
+ # create class object
78
+ class_ = {
79
+ "class": {
80
+ "professor": row['Prof_id'],
81
+ "course": row['Course_id'],
82
+ "duration": row['Duration'],
83
+ "group": row['Group_id'],
84
+ "lab": row['Lab']
85
+ }
86
+ }
87
+ if class_ not in objects:
88
+ objects.append(class_)
89
+
90
+ for index, row in df_room.iterrows():
91
+ if row['Room'] != '':
92
+ # create room object
93
+ room = {
94
+ "room": {
95
+ "name": row['Room'],
96
+ "lab": row['Lab'],
97
+ "size": row['Size_Room']
98
+ }
99
+ }
100
+ objects.append(room)
101
+
102
+ # create JSON object with list of objects
103
+ json_data = json.dumps(objects, sort_keys=False)
104
+ # write JSON object to file
105
+ with open('GaSchedule1.json', 'w') as f:
106
+ f.write(json_data)
107
+ file_name = "/GaSchedule1.json"
108
+ return file_name
109
+
110
+
111
+
112
+
113
+ def for_stu():
114
+ df_stu = pd.read_csv("time-scheduling/data_stu.csv")
115
+ df_ctdt = pd.read_csv("time-scheduling/ctdt_ds.csv")
116
+
117
+ df_ctdt = df_ctdt[['MaMH', 'Course Name', 'Sem', 'Expect Year', 'Credits', 'Elective']]
118
+
119
+ df_stu = df_stu[['MaSV', 'NHHK', 'HK', 'MaMH', 'TenMH', 'SoTinChi', 'DiemHP']]
120
+ df_stu = df_stu.dropna()
121
+ df_stu['NHHK'] = df_stu['NHHK'].astype(str).str[:-1]
122
+ input = st.text_input("Type Student ID", value="")
123
+
124
+
125
+
126
+
127
+ col1, col2, col3 = st.columns(3)
128
+ with col1:
129
+ if input:
130
+
131
+ # Convert 'DiemHP' column to numeric type, ignoring non-numeric values
132
+ df_stu['DiemHP'] = pd.to_numeric(df_stu['DiemHP'], errors='coerce')
133
+
134
+ list_subject_have_done = df_stu.loc[(df_stu['MaSV'].str.lower() == input.lower()) & (df_stu['DiemHP'].gt(50))]
135
+ list_subject_have_done[''] = np.arange(1, len(list_subject_have_done) + 1)
136
+ list_subject_have_done = list_subject_have_done.reindex(columns=['', 'MaMH', 'TenMH','HK', 'NHHK', 'SoTinChi'])
137
+ list_subject_have_done = list_subject_have_done.rename(columns={'NHHK': 'Actual Year', 'HK': 'Sem', 'TenMH': 'Course Name', 'SoTinChi': 'Credits'})
138
+
139
+ with st.expander("List of subjects have done"):
140
+ st.dataframe(list_subject_have_done.set_index(''))
141
+ with col2:
142
+ if input:
143
+ list_subject_havent_done_yet = df_ctdt[~df_ctdt['MaMH'].isin(list_subject_have_done['MaMH'])]
144
+ list_subject_havent_done_yet['Expect Year'] = list_subject_havent_done_yet['Expect Year'].astype(str)
145
+ list_subject_havent_done_yet['Elective'] = list_subject_havent_done_yet['Elective'].astype(bool)
146
+ list_subject_havent_done_yet[''] = np.arange(1, len(list_subject_havent_done_yet) + 1)
147
+ list_subject_havent_done_yet = list_subject_havent_done_yet.reindex(columns=['', 'MaMH', 'Course Name', 'Credits', 'Elective', 'Expect Year', 'Sem'])
148
+
149
+ with st.expander("List of subjects haven't done yet"):
150
+ st.dataframe(list_subject_havent_done_yet.set_index(''))
151
+
152
+ with col3:
153
+ if input:
154
+ df_unique = df2[df2['Group_Lab'] == 1.0]
155
+ df_unique = df_unique[['MaMH', 'Course_Name', 'Prof_Name', 'Duration', 'Group_Lab', 'Size_Course']]
156
+ list_recommend_subjects = df_unique[df_unique['MaMH'].isin(list_subject_havent_done_yet['MaMH'])]
157
+ list_recommend_subjects[''] = np.arange(1, len(list_recommend_subjects) + 1)
158
+ list_recommend_subjects = list_recommend_subjects.reindex(columns=['', 'MaMH', 'Course_Name', 'Prof_Name', 'Duration', 'Group_Lab', 'Size_Course'])
159
+ with st.expander("List of recommend subjects in this semester"):
160
+ st.dataframe(list_recommend_subjects.set_index(''))
161
+
162
+ def get_filter(html, list_filter):
163
+ # Parse the HTML
164
+ soup = BeautifulSoup(html, 'html.parser')
165
+
166
+ # Find all div elements with id starting with 'room_'
167
+ div_elements = soup.find_all('div', id=lambda x: x and x.startswith('room_'))
168
+ # Filter and display the schedule for specific rooms
169
+ filtered = ""
170
+ for div in div_elements:
171
+ room_id = div['id'].replace('room_', '') # Extract the room ID from the div's id attribute
172
+ if room_id in list_filter:
173
+ filtered += str(div)
174
+ return filtered
175
+
176
+ def data_display():
177
+
178
+ uploaded_file = st.file_uploader('')
179
+ if uploaded_file is not None:
180
+ df = pd.read_csv(uploaded_file)
181
+
182
+ else:
183
+ df = [['Data Mining', 1, 35, 4, 'Nguyen Thi Thanh Sang', 'IT132IU'],
184
+ ['Analytics for Observational Data', 2, 35, 4, 'Nguyen Thi Thanh Sang', 'IT142IU'],
185
+ ['Fundamentals of Programming', 0, 90, 3, 'Dao Tran Hoang Chau', 'IT149IU'],
186
+ ['Object-Oriented Analysis and Design', 0, 90, 4, 'Ha Viet Uyen Synh', 'IT090IU']]
187
+ room_columns = ['TenMH', 'ToTH', 'TongSoSV', 'SoTiet', 'TenDayDuNV', 'MaMH']
188
+ df = pd.DataFrame(df, columns=room_columns)
189
+
190
+ df1 = df[['TenMH', 'ToTH', 'TongSoSV', 'SoTiet', 'TenDayDuNV', 'MaMH']]
191
+ df1 = df1.rename(columns={'TenMH': 'Course_Name', 'ToTH': 'Group_Lab', 'TongSoSV': 'Size_Course', 'SoTiet': 'Duration', 'TenDayDuNV': 'Prof_Name', 'MaMH': 'MaMH'})
192
+ df1['Lab'] = df1['Group_Lab']
193
+ # df1['Lab'] = df1['Lab'].astype(str)
194
+ for index, row in df1.iterrows():
195
+ if row['Lab'] == 1 or row['Lab'] == 2 or row['Lab'] == 3 or row['Lab'] == 4:
196
+ df1.at[index, 'Lab'] = 'True'
197
+ else:
198
+ df1.at[index, 'Lab'] = ''
199
+ df1['Lab'] = df1['Lab'].astype(bool)
200
+
201
+
202
+ ## create default room
203
+ room_default = [['A1.309', 90, 0],
204
+ ['L107', 90, 0],
205
+ ['LA1.605', 60, 1],
206
+ ['La1.607', 60, 1]
207
+ ]
208
+ room_columns = ['Room', 'Size_Room', 'Lab']
209
+ df_room = pd.DataFrame(room_default, columns=room_columns)
210
+ df_room['Lab'] = df_room['Lab'].astype(str)
211
+ for index, row in df_room.iterrows():
212
+ if row['Lab'] == '1':
213
+ df_room.at[index, 'Lab'] = 'True'
214
+ else:
215
+ df_room.at[index, 'Lab'] = ''
216
+ df_room['Lab'] = df_room['Lab'].astype(bool)
217
+
218
+
219
+ col1, col2, col3, col4 = st.columns([0.5,7,2.4,0.5])
220
+
221
+ with col2:
222
+ df2 = st.experimental_data_editor(df1, num_rows="dynamic")
223
+ df2['Size_Course'] = df2['Size_Course'].astype(int)
224
+ df2['Duration'] = df2['Duration'].astype(int)
225
+ df2['Group_id'] = np.arange(1, len(df2) + 1)
226
+ df_prof_filter = df2['Prof_Name'].drop_duplicates().tolist()
227
+
228
+ with col3:
229
+ df_room = st.experimental_data_editor(df_room, num_rows="dynamic")
230
+ df_room['Size_Room'] = df_room['Size_Room'].astype(int)
231
+ filter = df_room['Room'].to_list()
232
+ # df_room_filter = df_room[df_room['Room'].isin(list_filter)]
233
+
234
+ return df2, df_room, filter, df_prof_filter
235
+
236
+ st.set_page_config(layout="wide")
237
+ if __name__ == "__main__":
238
+
239
+ st.markdown("<h1 style='text-align: center; color: white;'>Time Scheduling Engine</h1>", unsafe_allow_html=True)
240
+ image = Image.open('time-scheduling/logo-vector-IU-01.png')
241
+ st.sidebar.image(image, width=240)
242
+ tab1, tab2 = st.tabs(["Schedule", "Student"])
243
+ with tab1:
244
+ df2, df_room, filter, df_prof_filter = data_display()
245
+ file_name = load_file(df2, df_room)
246
+ # html_result_filter = main_filter(file_name)
247
+ html_result = main(file_name)
248
+ if 'html_result' not in st.session_state:
249
+ st.session_state.html_result = []
250
+ list_room_filter = st.sidebar.multiselect('Room Filter', filter, filter)
251
+ # list_prof_filter = st.sidebar.multiselect('Prof Filter', df_prof_filter, df_prof_filter)
252
+ if st.button('Generate'):
253
+ st.session_state.html_result = html_result
254
+ st.markdown(st.session_state.html_result, unsafe_allow_html=True)
255
+ if st.sidebar.button('Room Filter'):
256
+ filtered1 = get_filter(st.session_state.html_result, list_room_filter)
257
+ st.markdown(filtered1, unsafe_allow_html=True)
258
+
259
+ # if len(sys.argv) > 1:
260
+ # file_name = sys.argv[1]
261
+ # try:
262
+ # if st.button('Generate'):
263
+ # temp = session_state['html_result']
264
+ # filtered1 = get_filter(temp, list_filter)
265
+ # st.markdown(filtered1, unsafe_allow_html=True)
266
+
267
+ # except:
268
+ # traceback.print_exc()
269
+
270
+ with tab2:
271
+ for_stu()
reprocessing.ipynb ADDED
@@ -0,0 +1,589 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "3745035b",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "data": {
11
+ "text/html": [
12
+ "<div>\n",
13
+ "<style scoped>\n",
14
+ " .dataframe tbody tr th:only-of-type {\n",
15
+ " vertical-align: middle;\n",
16
+ " }\n",
17
+ "\n",
18
+ " .dataframe tbody tr th {\n",
19
+ " vertical-align: top;\n",
20
+ " }\n",
21
+ "\n",
22
+ " .dataframe thead th {\n",
23
+ " text-align: right;\n",
24
+ " }\n",
25
+ "</style>\n",
26
+ "<table border=\"1\" class=\"dataframe\">\n",
27
+ " <thead>\n",
28
+ " <tr style=\"text-align: right;\">\n",
29
+ " <th></th>\n",
30
+ " <th>MaMH</th>\n",
31
+ " <th>TenMH</th>\n",
32
+ " <th>NhomTo</th>\n",
33
+ " <th>ToTH</th>\n",
34
+ " <th>TenLop</th>\n",
35
+ " <th>TongSoSV</th>\n",
36
+ " <th>ThuKieuSo</th>\n",
37
+ " <th>TietBD</th>\n",
38
+ " <th>SoTiet</th>\n",
39
+ " <th>MaPH</th>\n",
40
+ " <th>DSTuanHoc</th>\n",
41
+ " <th>MaNV</th>\n",
42
+ " <th>TenDayDuNV</th>\n",
43
+ " <th>IsTKBDaXep</th>\n",
44
+ " <th>MaDV</th>\n",
45
+ " <th>TenDV</th>\n",
46
+ " <th>TenDVEg</th>\n",
47
+ " <th>NgayBD</th>\n",
48
+ " <th>NgayKT</th>\n",
49
+ " </tr>\n",
50
+ " </thead>\n",
51
+ " <tbody>\n",
52
+ " <tr>\n",
53
+ " <th>0</th>\n",
54
+ " <td>1</td>\n",
55
+ " <td>Functional Programming</td>\n",
56
+ " <td>1</td>\n",
57
+ " <td>NaN</td>\n",
58
+ " <td>ITIT16UN11, ITIT16UN21</td>\n",
59
+ " <td>10</td>\n",
60
+ " <td>2</td>\n",
61
+ " <td>1</td>\n",
62
+ " <td>3</td>\n",
63
+ " <td>LA1.605</td>\n",
64
+ " <td>-2345678901234567---</td>\n",
65
+ " <td>174</td>\n",
66
+ " <td>Dao Tran Hoang Chau</td>\n",
67
+ " <td>0</td>\n",
68
+ " <td>IT IT</td>\n",
69
+ " <td>Computer Science &amp; Engineering</td>\n",
70
+ " <td>Computer Science &amp; Engineering</td>\n",
71
+ " <td>42989</td>\n",
72
+ " <td>43094</td>\n",
73
+ " </tr>\n",
74
+ " <tr>\n",
75
+ " <th>1</th>\n",
76
+ " <td>2</td>\n",
77
+ " <td>Operating Systems</td>\n",
78
+ " <td>1</td>\n",
79
+ " <td>NaN</td>\n",
80
+ " <td>ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31</td>\n",
81
+ " <td>90</td>\n",
82
+ " <td>6</td>\n",
83
+ " <td>6</td>\n",
84
+ " <td>3</td>\n",
85
+ " <td>A1.309</td>\n",
86
+ " <td>-2345678901234567---</td>\n",
87
+ " <td>119</td>\n",
88
+ " <td>Tran Manh Ha</td>\n",
89
+ " <td>0</td>\n",
90
+ " <td>IT IT</td>\n",
91
+ " <td>Computer Science &amp; Engineering</td>\n",
92
+ " <td>Computer Science &amp; Engineering</td>\n",
93
+ " <td>42993</td>\n",
94
+ " <td>43098</td>\n",
95
+ " </tr>\n",
96
+ " <tr>\n",
97
+ " <th>2</th>\n",
98
+ " <td>2</td>\n",
99
+ " <td>Operating Systems</td>\n",
100
+ " <td>1</td>\n",
101
+ " <td>1.0</td>\n",
102
+ " <td>ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31</td>\n",
103
+ " <td>30</td>\n",
104
+ " <td>2</td>\n",
105
+ " <td>6</td>\n",
106
+ " <td>4</td>\n",
107
+ " <td>LA1.605</td>\n",
108
+ " <td>-----678901234------</td>\n",
109
+ " <td>119</td>\n",
110
+ " <td>Tran Manh Ha</td>\n",
111
+ " <td>0</td>\n",
112
+ " <td>IT IT</td>\n",
113
+ " <td>Computer Science &amp; Engineering</td>\n",
114
+ " <td>Computer Science &amp; Engineering</td>\n",
115
+ " <td>43017</td>\n",
116
+ " <td>43073</td>\n",
117
+ " </tr>\n",
118
+ " <tr>\n",
119
+ " <th>3</th>\n",
120
+ " <td>2</td>\n",
121
+ " <td>Operating Systems</td>\n",
122
+ " <td>1</td>\n",
123
+ " <td>2.0</td>\n",
124
+ " <td>ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31</td>\n",
125
+ " <td>30</td>\n",
126
+ " <td>2</td>\n",
127
+ " <td>1</td>\n",
128
+ " <td>4</td>\n",
129
+ " <td>LA1.608</td>\n",
130
+ " <td>-----678901234------</td>\n",
131
+ " <td>213</td>\n",
132
+ " <td>Nguyen Tien Dung</td>\n",
133
+ " <td>0</td>\n",
134
+ " <td>IT IT</td>\n",
135
+ " <td>Computer Science &amp; Engineering</td>\n",
136
+ " <td>Computer Science &amp; Engineering</td>\n",
137
+ " <td>43017</td>\n",
138
+ " <td>43073</td>\n",
139
+ " </tr>\n",
140
+ " <tr>\n",
141
+ " <th>4</th>\n",
142
+ " <td>2</td>\n",
143
+ " <td>Operating Systems</td>\n",
144
+ " <td>1</td>\n",
145
+ " <td>3.0</td>\n",
146
+ " <td>ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31</td>\n",
147
+ " <td>30</td>\n",
148
+ " <td>2</td>\n",
149
+ " <td>6</td>\n",
150
+ " <td>4</td>\n",
151
+ " <td>LA1.607</td>\n",
152
+ " <td>-----678901234------</td>\n",
153
+ " <td>213</td>\n",
154
+ " <td>Nguyen Tien Dung</td>\n",
155
+ " <td>0</td>\n",
156
+ " <td>IT IT</td>\n",
157
+ " <td>Computer Science &amp; Engineering</td>\n",
158
+ " <td>Computer Science &amp; Engineering</td>\n",
159
+ " <td>43017</td>\n",
160
+ " <td>43073</td>\n",
161
+ " </tr>\n",
162
+ " </tbody>\n",
163
+ "</table>\n",
164
+ "</div>"
165
+ ],
166
+ "text/plain": [
167
+ " MaMH TenMH NhomTo ToTH \\\n",
168
+ "0 1 Functional Programming 1 NaN \n",
169
+ "1 2 Operating Systems 1 NaN \n",
170
+ "2 2 Operating Systems 1 1.0 \n",
171
+ "3 2 Operating Systems 1 2.0 \n",
172
+ "4 2 Operating Systems 1 3.0 \n",
173
+ "\n",
174
+ " TenLop TongSoSV ThuKieuSo TietBD \\\n",
175
+ "0 ITIT16UN11, ITIT16UN21 10 2 1 \n",
176
+ "1 ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31 90 6 6 \n",
177
+ "2 ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31 30 2 6 \n",
178
+ "3 ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31 30 2 1 \n",
179
+ "4 ITIT15CS1, ITIT15IU11, ITIT15IU21, ITIT15IU31 30 2 6 \n",
180
+ "\n",
181
+ " SoTiet MaPH DSTuanHoc MaNV TenDayDuNV \\\n",
182
+ "0 3 LA1.605 -2345678901234567--- 174 Dao Tran Hoang Chau \n",
183
+ "1 3 A1.309 -2345678901234567--- 119 Tran Manh Ha \n",
184
+ "2 4 LA1.605 -----678901234------ 119 Tran Manh Ha \n",
185
+ "3 4 LA1.608 -----678901234------ 213 Nguyen Tien Dung \n",
186
+ "4 4 LA1.607 -----678901234------ 213 Nguyen Tien Dung \n",
187
+ "\n",
188
+ " IsTKBDaXep MaDV TenDV \\\n",
189
+ "0 0 IT IT Computer Science & Engineering \n",
190
+ "1 0 IT IT Computer Science & Engineering \n",
191
+ "2 0 IT IT Computer Science & Engineering \n",
192
+ "3 0 IT IT Computer Science & Engineering \n",
193
+ "4 0 IT IT Computer Science & Engineering \n",
194
+ "\n",
195
+ " TenDVEg NgayBD NgayKT \n",
196
+ "0 Computer Science & Engineering 42989 43094 \n",
197
+ "1 Computer Science & Engineering 42993 43098 \n",
198
+ "2 Computer Science & Engineering 43017 43073 \n",
199
+ "3 Computer Science & Engineering 43017 43073 \n",
200
+ "4 Computer Science & Engineering 43017 43073 "
201
+ ]
202
+ },
203
+ "execution_count": 1,
204
+ "metadata": {},
205
+ "output_type": "execute_result"
206
+ }
207
+ ],
208
+ "source": [
209
+ "import pandas as pd\n",
210
+ "import numpy as np\n",
211
+ "df = pd.read_csv(\"TKB HKI 2017-2018.csv\")\n",
212
+ "df.head()"
213
+ ]
214
+ },
215
+ {
216
+ "cell_type": "code",
217
+ "execution_count": 2,
218
+ "id": "a605911f",
219
+ "metadata": {},
220
+ "outputs": [
221
+ {
222
+ "data": {
223
+ "text/html": [
224
+ "<div>\n",
225
+ "<style scoped>\n",
226
+ " .dataframe tbody tr th:only-of-type {\n",
227
+ " vertical-align: middle;\n",
228
+ " }\n",
229
+ "\n",
230
+ " .dataframe tbody tr th {\n",
231
+ " vertical-align: top;\n",
232
+ " }\n",
233
+ "\n",
234
+ " .dataframe thead th {\n",
235
+ " text-align: right;\n",
236
+ " }\n",
237
+ "</style>\n",
238
+ "<table border=\"1\" class=\"dataframe\">\n",
239
+ " <thead>\n",
240
+ " <tr style=\"text-align: right;\">\n",
241
+ " <th></th>\n",
242
+ " <th>group_id</th>\n",
243
+ " <th>course_id</th>\n",
244
+ " <th>course_name</th>\n",
245
+ " <th>Lab</th>\n",
246
+ " <th>size</th>\n",
247
+ " <th>duration</th>\n",
248
+ " <th>room</th>\n",
249
+ " <th>prof_id</th>\n",
250
+ " <th>prof_name</th>\n",
251
+ " </tr>\n",
252
+ " </thead>\n",
253
+ " <tbody>\n",
254
+ " <tr>\n",
255
+ " <th>0</th>\n",
256
+ " <td>1</td>\n",
257
+ " <td>1</td>\n",
258
+ " <td>Functional Programming</td>\n",
259
+ " <td>False</td>\n",
260
+ " <td>10</td>\n",
261
+ " <td>3</td>\n",
262
+ " <td>LA1.605</td>\n",
263
+ " <td>174</td>\n",
264
+ " <td>Dao Tran Hoang Chau</td>\n",
265
+ " </tr>\n",
266
+ " <tr>\n",
267
+ " <th>1</th>\n",
268
+ " <td>2</td>\n",
269
+ " <td>2</td>\n",
270
+ " <td>Operating Systems</td>\n",
271
+ " <td>False</td>\n",
272
+ " <td>90</td>\n",
273
+ " <td>3</td>\n",
274
+ " <td>A1.309</td>\n",
275
+ " <td>119</td>\n",
276
+ " <td>Tran Manh Ha</td>\n",
277
+ " </tr>\n",
278
+ " <tr>\n",
279
+ " <th>2</th>\n",
280
+ " <td>3</td>\n",
281
+ " <td>2</td>\n",
282
+ " <td>Operating Systems</td>\n",
283
+ " <td>True</td>\n",
284
+ " <td>30</td>\n",
285
+ " <td>4</td>\n",
286
+ " <td>LA1.605</td>\n",
287
+ " <td>119</td>\n",
288
+ " <td>Tran Manh Ha</td>\n",
289
+ " </tr>\n",
290
+ " <tr>\n",
291
+ " <th>3</th>\n",
292
+ " <td>4</td>\n",
293
+ " <td>2</td>\n",
294
+ " <td>Operating Systems</td>\n",
295
+ " <td>True</td>\n",
296
+ " <td>30</td>\n",
297
+ " <td>4</td>\n",
298
+ " <td>LA1.608</td>\n",
299
+ " <td>213</td>\n",
300
+ " <td>Nguyen Tien Dung</td>\n",
301
+ " </tr>\n",
302
+ " <tr>\n",
303
+ " <th>4</th>\n",
304
+ " <td>5</td>\n",
305
+ " <td>2</td>\n",
306
+ " <td>Operating Systems</td>\n",
307
+ " <td>True</td>\n",
308
+ " <td>30</td>\n",
309
+ " <td>4</td>\n",
310
+ " <td>LA1.607</td>\n",
311
+ " <td>213</td>\n",
312
+ " <td>Nguyen Tien Dung</td>\n",
313
+ " </tr>\n",
314
+ " </tbody>\n",
315
+ "</table>\n",
316
+ "</div>"
317
+ ],
318
+ "text/plain": [
319
+ " group_id course_id course_name Lab size duration \\\n",
320
+ "0 1 1 Functional Programming False 10 3 \n",
321
+ "1 2 2 Operating Systems False 90 3 \n",
322
+ "2 3 2 Operating Systems True 30 4 \n",
323
+ "3 4 2 Operating Systems True 30 4 \n",
324
+ "4 5 2 Operating Systems True 30 4 \n",
325
+ "\n",
326
+ " room prof_id prof_name \n",
327
+ "0 LA1.605 174 Dao Tran Hoang Chau \n",
328
+ "1 A1.309 119 Tran Manh Ha \n",
329
+ "2 LA1.605 119 Tran Manh Ha \n",
330
+ "3 LA1.608 213 Nguyen Tien Dung \n",
331
+ "4 LA1.607 213 Nguyen Tien Dung "
332
+ ]
333
+ },
334
+ "execution_count": 2,
335
+ "metadata": {},
336
+ "output_type": "execute_result"
337
+ }
338
+ ],
339
+ "source": [
340
+ "df = pd.DataFrame(df)\n",
341
+ "df1 = df[['MaMH', 'TenMH', 'ToTH', 'TongSoSV', 'SoTiet', 'MaPH','MaNV', 'TenDayDuNV']]\n",
342
+ "df1 = df1.rename(columns={'MaMH': 'course_id', 'TenMH': 'course_name','ToTH': 'Lab', 'TongSoSV': 'size', 'SoTiet': 'duration', 'MaPH': 'room', 'MaNV': 'prof_id', 'TenDayDuNV': 'prof_name' })\n",
343
+ "df1['Lab'] = df1['Lab'].fillna(0)\n",
344
+ "df1['Lab'] = df1['Lab'].astype(str)\n",
345
+ "df1['prof_id'] = df1['prof_id'].astype(int)\n",
346
+ "df1['course_id'] = df1['course_id'].astype(int)\n",
347
+ "\n",
348
+ "for index, row in df1.iterrows():\n",
349
+ " if row['Lab'] == '1.0' or row['Lab'] == '2.0' or row['Lab'] == '3.0' or row['Lab'] == '4.0':\n",
350
+ " df1.at[index, 'Lab'] = 'True'\n",
351
+ " else:\n",
352
+ " df1.at[index, 'Lab'] = ''\n",
353
+ " \n",
354
+ "df1['Lab'] = df1['Lab'].astype(bool)\n",
355
+ "df1.reset_index(inplace=True)\n",
356
+ "df1 = df1.rename(columns={'index': 'group_id'})\n",
357
+ "df1['group_id'] = np.arange(1, len(df) + 1)\n",
358
+ "df1.head()"
359
+ ]
360
+ },
361
+ {
362
+ "cell_type": "code",
363
+ "execution_count": 3,
364
+ "id": "80f6ef63",
365
+ "metadata": {},
366
+ "outputs": [
367
+ {
368
+ "data": {
369
+ "text/html": [
370
+ "<div>\n",
371
+ "<style scoped>\n",
372
+ " .dataframe tbody tr th:only-of-type {\n",
373
+ " vertical-align: middle;\n",
374
+ " }\n",
375
+ "\n",
376
+ " .dataframe tbody tr th {\n",
377
+ " vertical-align: top;\n",
378
+ " }\n",
379
+ "\n",
380
+ " .dataframe thead th {\n",
381
+ " text-align: right;\n",
382
+ " }\n",
383
+ "</style>\n",
384
+ "<table border=\"1\" class=\"dataframe\">\n",
385
+ " <thead>\n",
386
+ " <tr style=\"text-align: right;\">\n",
387
+ " <th></th>\n",
388
+ " <th>room</th>\n",
389
+ " <th>size</th>\n",
390
+ " <th>Lab</th>\n",
391
+ " </tr>\n",
392
+ " </thead>\n",
393
+ " <tbody>\n",
394
+ " <tr>\n",
395
+ " <th>0</th>\n",
396
+ " <td>A1.309</td>\n",
397
+ " <td>90</td>\n",
398
+ " <td>False</td>\n",
399
+ " </tr>\n",
400
+ " <tr>\n",
401
+ " <th>1</th>\n",
402
+ " <td>L107</td>\n",
403
+ " <td>40</td>\n",
404
+ " <td>False</td>\n",
405
+ " </tr>\n",
406
+ " <tr>\n",
407
+ " <th>2</th>\n",
408
+ " <td>LA1.605</td>\n",
409
+ " <td>35</td>\n",
410
+ " <td>True</td>\n",
411
+ " </tr>\n",
412
+ " <tr>\n",
413
+ " <th>3</th>\n",
414
+ " <td>LA1.607</td>\n",
415
+ " <td>35</td>\n",
416
+ " <td>True</td>\n",
417
+ " </tr>\n",
418
+ " </tbody>\n",
419
+ "</table>\n",
420
+ "</div>"
421
+ ],
422
+ "text/plain": [
423
+ " room size Lab\n",
424
+ "0 A1.309 90 False\n",
425
+ "1 L107 40 False\n",
426
+ "2 LA1.605 35 True\n",
427
+ "3 LA1.607 35 True"
428
+ ]
429
+ },
430
+ "execution_count": 3,
431
+ "metadata": {},
432
+ "output_type": "execute_result"
433
+ }
434
+ ],
435
+ "source": [
436
+ "room_default = [['A1.309', 90, 0],\n",
437
+ " ['L107', 40, 0],\n",
438
+ " ['LA1.605', 35, 1],\n",
439
+ " ['LA1.607', 35, 1],\n",
440
+ "]\n",
441
+ "room_columns = ['room', 'size', 'Lab']\n",
442
+ "df_room = pd.DataFrame(room_default, columns=room_columns)\n",
443
+ "df_room['Lab'] = df_room['Lab'].astype(str)\n",
444
+ "for index, row in df_room.iterrows():\n",
445
+ " if row['Lab'] == '1':\n",
446
+ " df_room.at[index, 'Lab'] = 'True'\n",
447
+ " else:\n",
448
+ " df_room.at[index, 'Lab'] = ''\n",
449
+ "df_room['Lab'] = df_room['Lab'].astype(bool)\n",
450
+ "df_room"
451
+ ]
452
+ },
453
+ {
454
+ "cell_type": "code",
455
+ "execution_count": 4,
456
+ "id": "d6b5b6a2",
457
+ "metadata": {},
458
+ "outputs": [],
459
+ "source": [
460
+ "import json\n",
461
+ "\n",
462
+ "# create list of dictionaries representing each object in the JSON file\n",
463
+ "objects = []\n",
464
+ "\n",
465
+ "for index, row in df1.iterrows():\n",
466
+ " if row['prof_id'] != '':\n",
467
+ " # create professor object\n",
468
+ " prof = {\n",
469
+ " \"prof\": {\n",
470
+ " \"id\": row['prof_id'],\n",
471
+ " \"name\": row['prof_name']\n",
472
+ " }\n",
473
+ " }\n",
474
+ " if prof not in objects:\n",
475
+ " objects.append(prof)\n",
476
+ "\n",
477
+ " if row['course_id'] != '':\n",
478
+ " # create course object\n",
479
+ " course = {\n",
480
+ " \"course\": {\n",
481
+ " \"id\": row['course_id'],\n",
482
+ " \"name\": row['course_name']\n",
483
+ " }\n",
484
+ " }\n",
485
+ " if course not in objects:\n",
486
+ " objects.append(course)\n",
487
+ "\n",
488
+ " if row['group_id'] != '':\n",
489
+ " # create room object\n",
490
+ " group = {\n",
491
+ " \"group\": {\n",
492
+ " \"id\": row['group_id'],\n",
493
+ " \"size\": row['size']\n",
494
+ " }\n",
495
+ " }\n",
496
+ " if group not in objects:\n",
497
+ " objects.append(group)\n",
498
+ " \n",
499
+ " if row['prof_id'] != '' and row['course_id'] != '':\n",
500
+ " # create class object\n",
501
+ " class_ = {\n",
502
+ " \"class\": {\n",
503
+ " \"professor\": row['prof_id'],\n",
504
+ " \"course\": row['course_id'],\n",
505
+ " \"duration\": row['duration'],\n",
506
+ " \"group\": row['group_id'],\n",
507
+ " \"lab\": row['Lab']\n",
508
+ " }\n",
509
+ " }\n",
510
+ " if class_ not in objects:\n",
511
+ " objects.append(class_)\n",
512
+ " \n",
513
+ "for index, row in df_room.iterrows():\n",
514
+ " if row['room'] != '':\n",
515
+ " # create room object\n",
516
+ " room = {\n",
517
+ " \"room\": {\n",
518
+ " \"name\": row['room'],\n",
519
+ " \"lab\": row['Lab'],\n",
520
+ " \"size\": row['size']\n",
521
+ " }\n",
522
+ " }\n",
523
+ " objects.append(room) \n",
524
+ " \n",
525
+ "# create JSON object with list of objects\n",
526
+ "json_data = json.dumps(objects, sort_keys=False)\n",
527
+ "\n",
528
+ "# write JSON object to file\n",
529
+ "with open('GaSchedule3.json', 'w') as f:\n",
530
+ " f.write(json_data)"
531
+ ]
532
+ },
533
+ {
534
+ "cell_type": "code",
535
+ "execution_count": 5,
536
+ "id": "f7a33b15",
537
+ "metadata": {},
538
+ "outputs": [
539
+ {
540
+ "data": {
541
+ "text/plain": [
542
+ "'[{\"prof\": {\"id\": 174, \"name\": \"Dao Tran Hoang Chau\"}}, {\"course\": {\"id\": 1, \"name\": \"Functional Programming\"}}, {\"group\": {\"id\": 1, \"size\": 10}}, {\"class\": {\"professor\": 174, \"course\": 1, \"duration\": 3, \"group\": 1, \"lab\": false}}, {\"prof\": {\"id\": 119, \"name\": \"Tran Manh Ha\"}}, {\"course\": {\"id\": 2, \"name\": \"Operating Systems\"}}, {\"group\": {\"id\": 2, \"size\": 90}}, {\"class\": {\"professor\": 119, \"course\": 2, \"duration\": 3, \"group\": 2, \"lab\": false}}, {\"group\": {\"id\": 3, \"size\": 30}}, {\"class\": {\"professor\": 119, \"course\": 2, \"duration\": 4, \"group\": 3, \"lab\": true}}, {\"prof\": {\"id\": 213, \"name\": \"Nguyen Tien Dung\"}}, {\"group\": {\"id\": 4, \"size\": 30}}, {\"class\": {\"professor\": 213, \"course\": 2, \"duration\": 4, \"group\": 4, \"lab\": true}}, {\"group\": {\"id\": 5, \"size\": 30}}, {\"class\": {\"professor\": 213, \"course\": 2, \"duration\": 4, \"group\": 5, \"lab\": true}}, {\"prof\": {\"id\": 74, \"name\": \"Nguyen Van Sinh\"}}, {\"course\": {\"id\": 3, \"name\": \"IT Project Management\"}}, {\"group\": {\"id\": 6, \"size\": 35}}, {\"class\": {\"professor\": 74, \"course\": 3, \"duration\": 3, \"group\": 6, \"lab\": false}}, {\"group\": {\"id\": 7, \"size\": 35}}, {\"class\": {\"professor\": 74, \"course\": 3, \"duration\": 4, \"group\": 7, \"lab\": true}}, {\"prof\": {\"id\": 84, \"name\": \"Le Hai Duong\"}}, {\"course\": {\"id\": 4, \"name\": \"Introduction to Computing\"}}, {\"group\": {\"id\": 8, \"size\": 35}}, {\"class\": {\"professor\": 84, \"course\": 4, \"duration\": 3, \"group\": 8, \"lab\": false}}, {\"prof\": {\"id\": 19, \"name\": \"Huynh Kha Tu\"}}, {\"course\": {\"id\": 5, \"name\": \"Digital Logic Design\"}}, {\"group\": {\"id\": 9, \"size\": 90}}, {\"class\": {\"professor\": 19, \"course\": 5, \"duration\": 3, \"group\": 9, \"lab\": false}}, {\"prof\": {\"id\": 182, \"name\": \"Tran Thanh Tung\"}}, {\"course\": {\"id\": 6, \"name\": \"Object-Oriented Programming\"}}, {\"group\": {\"id\": 10, \"size\": 90}}, {\"class\": {\"professor\": 182, \"course\": 6, \"duration\": 3, \"group\": 10, \"lab\": false}}, {\"group\": {\"id\": 11, \"size\": 30}}, {\"class\": {\"professor\": 213, \"course\": 6, \"duration\": 4, \"group\": 11, \"lab\": true}}, {\"group\": {\"id\": 12, \"size\": 30}}, {\"class\": {\"professor\": 213, \"course\": 6, \"duration\": 4, \"group\": 12, \"lab\": true}}, {\"group\": {\"id\": 13, \"size\": 30}}, {\"class\": {\"professor\": 213, \"course\": 6, \"duration\": 4, \"group\": 13, \"lab\": true}}, {\"prof\": {\"id\": 349, \"name\": \"Nguyen Thi Thanh Sang\"}}, {\"course\": {\"id\": 7, \"name\": \"Software Engineering\"}}, {\"group\": {\"id\": 14, \"size\": 70}}, {\"class\": {\"professor\": 349, \"course\": 7, \"duration\": 3, \"group\": 14, \"lab\": false}}, {\"group\": {\"id\": 15, \"size\": 35}}, {\"class\": {\"professor\": 349, \"course\": 7, \"duration\": 4, \"group\": 15, \"lab\": true}}, {\"group\": {\"id\": 16, \"size\": 35}}, {\"class\": {\"professor\": 349, \"course\": 7, \"duration\": 4, \"group\": 16, \"lab\": true}}, {\"prof\": {\"id\": 62, \"name\": \"Vo Thi Luu Phuong\"}}, {\"course\": {\"id\": 8, \"name\": \"Computer Networks\"}}, {\"group\": {\"id\": 17, \"size\": 70}}, {\"class\": {\"professor\": 62, \"course\": 8, \"duration\": 3, \"group\": 17, \"lab\": false}}, {\"group\": {\"id\": 18, \"size\": 35}}, {\"class\": {\"professor\": 62, \"course\": 8, \"duration\": 4, \"group\": 18, \"lab\": true}}, {\"group\": {\"id\": 19, \"size\": 35}}, {\"class\": {\"professor\": 62, \"course\": 8, \"duration\": 4, \"group\": 19, \"lab\": true}}, {\"prof\": {\"id\": 60, \"name\": \"Ly Tu Nga\"}}, {\"group\": {\"id\": 20, \"size\": 20}}, {\"class\": {\"professor\": 60, \"course\": 8, \"duration\": 4, \"group\": 20, \"lab\": true}}, {\"course\": {\"id\": 9, \"name\": \"Web Application Development\"}}, {\"group\": {\"id\": 21, \"size\": 15}}, {\"class\": {\"professor\": 74, \"course\": 9, \"duration\": 3, \"group\": 21, \"lab\": false}}, {\"group\": {\"id\": 22, \"size\": 15}}, {\"class\": {\"professor\": 74, \"course\": 9, \"duration\": 4, \"group\": 22, \"lab\": true}}, {\"group\": {\"id\": 23, \"size\": 20}}, {\"class\": {\"professor\": 213, \"course\": 9, \"duration\": 4, \"group\": 23, \"lab\": true}}, {\"prof\": {\"id\": 36, \"name\": \"Le Thanh Son\"}}, {\"course\": {\"id\": 10, \"name\": \"Net-Centric Programming\"}}, {\"group\": {\"id\": 24, \"size\": 17}}, {\"class\": {\"professor\": 36, \"course\": 10, \"duration\": 3, \"group\": 24, \"lab\": false}}, {\"group\": {\"id\": 25, \"size\": 17}}, {\"class\": {\"professor\": 36, \"course\": 10, \"duration\": 4, \"group\": 25, \"lab\": true}}, {\"course\": {\"id\": 11, \"name\": \"Digital Logic Design Laboratory\"}}, {\"group\": {\"id\": 26, \"size\": 15}}, {\"class\": {\"professor\": 60, \"course\": 11, \"duration\": 4, \"group\": 26, \"lab\": false}}, {\"group\": {\"id\": 27, \"size\": 15}}, {\"class\": {\"professor\": 60, \"course\": 11, \"duration\": 4, \"group\": 27, \"lab\": false}}, {\"group\": {\"id\": 28, \"size\": 15}}, {\"class\": {\"professor\": 60, \"course\": 11, \"duration\": 4, \"group\": 28, \"lab\": false}}, {\"group\": {\"id\": 29, \"size\": 15}}, {\"class\": {\"professor\": 60, \"course\": 11, \"duration\": 4, \"group\": 29, \"lab\": false}}, {\"group\": {\"id\": 30, \"size\": 15}}, {\"class\": {\"professor\": 60, \"course\": 11, \"duration\": 4, \"group\": 30, \"lab\": false}}, {\"course\": {\"id\": 12, \"name\": \"Entrepreneurship\"}}, {\"group\": {\"id\": 31, \"size\": 80}}, {\"class\": {\"professor\": 174, \"course\": 12, \"duration\": 3, \"group\": 31, \"lab\": false}}, {\"course\": {\"id\": 13, \"name\": \"System & Network Administration\"}}, {\"group\": {\"id\": 32, \"size\": 35}}, {\"class\": {\"professor\": 36, \"course\": 13, \"duration\": 3, \"group\": 32, \"lab\": false}}, {\"group\": {\"id\": 33, \"size\": 35}}, {\"class\": {\"professor\": 36, \"course\": 13, \"duration\": 4, \"group\": 33, \"lab\": true}}, {\"prof\": {\"id\": 184, \"name\": \"Ha Viet Uyen Synh\"}}, {\"course\": {\"id\": 14, \"name\": \"Theoretical Models in Computing\"}}, {\"group\": {\"id\": 34, \"size\": 80}}, {\"class\": {\"professor\": 184, \"course\": 14, \"duration\": 3, \"group\": 34, \"lab\": false}}, {\"group\": {\"id\": 35, \"size\": 26}}, {\"class\": {\"professor\": 184, \"course\": 14, \"duration\": 4, \"group\": 35, \"lab\": true}}, {\"group\": {\"id\": 36, \"size\": 28}}, {\"class\": {\"professor\": 184, \"course\": 14, \"duration\": 4, \"group\": 36, \"lab\": true}}, {\"course\": {\"id\": 15, \"name\": \"Discrete Mathematics\"}}, {\"group\": {\"id\": 37, \"size\": 80}}, {\"class\": {\"professor\": 74, \"course\": 15, \"duration\": 3, \"group\": 37, \"lab\": false}}, {\"room\": {\"name\": \"A1.309\", \"lab\": false, \"size\": 90}}, {\"room\": {\"name\": \"L107\", \"lab\": false, \"size\": 40}}, {\"room\": {\"name\": \"LA1.605\", \"lab\": true, \"size\": 35}}, {\"room\": {\"name\": \"LA1.607\", \"lab\": true, \"size\": 35}}]'"
543
+ ]
544
+ },
545
+ "execution_count": 5,
546
+ "metadata": {},
547
+ "output_type": "execute_result"
548
+ }
549
+ ],
550
+ "source": [
551
+ "json_data"
552
+ ]
553
+ },
554
+ {
555
+ "cell_type": "code",
556
+ "execution_count": null,
557
+ "id": "ac354530",
558
+ "metadata": {},
559
+ "outputs": [],
560
+ "source": []
561
+ }
562
+ ],
563
+ "metadata": {
564
+ "kernelspec": {
565
+ "display_name": "Python 3",
566
+ "language": "python",
567
+ "name": "python3"
568
+ },
569
+ "language_info": {
570
+ "codemirror_mode": {
571
+ "name": "ipython",
572
+ "version": 3
573
+ },
574
+ "file_extension": ".py",
575
+ "mimetype": "text/x-python",
576
+ "name": "python",
577
+ "nbconvert_exporter": "python",
578
+ "pygments_lexer": "ipython3",
579
+ "version": "3.9.7"
580
+ },
581
+ "vscode": {
582
+ "interpreter": {
583
+ "hash": "9510137371fb582fb03f4a48cfea1312dabd94192ffed7cc50b24473a7d892dd"
584
+ }
585
+ }
586
+ },
587
+ "nbformat": 4,
588
+ "nbformat_minor": 5
589
+ }
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy >= 1.2.*
2
+ streamlit == 1.22.0
3
+ beautifulsoup4==4.9.3
4
+ hydralit >=1.0.9
5
+ hydralit_components >=1.0.4
session_state.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Hack to add per-session state to Streamlit.
2
+ Usage
3
+ -----
4
+ >>> import SessionState
5
+ >>>
6
+ >>> session_state = SessionState.get(user_name='', favorite_color='black')
7
+ >>> session_state.user_name
8
+ ''
9
+ >>> session_state.user_name = 'Mary'
10
+ >>> session_state.favorite_color
11
+ 'black'
12
+ Since you set user_name above, next time your script runs this will be the
13
+ result:
14
+ >>> session_state = get(user_name='', favorite_color='black')
15
+ >>> session_state.user_name
16
+ 'Mary'
17
+ """
18
+ try:
19
+ import streamlit.report_thread as ReportThread
20
+ from streamlit.server.server import Server
21
+ except Exception:
22
+ # Streamlit >= 0.65.0
23
+ import streamlit.report_thread as ReportThread
24
+ from streamlit.server.server import Server
25
+
26
+
27
+ class SessionState(object):
28
+ def __init__(self, **kwargs):
29
+ """A new SessionState object.
30
+ Parameters
31
+ ----------
32
+ **kwargs : any
33
+ Default values for the session state.
34
+ Example
35
+ -------
36
+ >>> session_state = SessionState(user_name='', favorite_color='black')
37
+ >>> session_state.user_name = 'Mary'
38
+ ''
39
+ >>> session_state.favorite_color
40
+ 'black'
41
+ """
42
+ for key, val in kwargs.items():
43
+ setattr(self, key, val)
44
+
45
+
46
+ def get(**kwargs):
47
+ """Gets a SessionState object for the current session.
48
+ Creates a new object if necessary.
49
+ Parameters
50
+ ----------
51
+ **kwargs : any
52
+ Default values you want to add to the session state, if we're creating a
53
+ new one.
54
+ Example
55
+ -------
56
+ >>> session_state = get(user_name='', favorite_color='black')
57
+ >>> session_state.user_name
58
+ ''
59
+ >>> session_state.user_name = 'Mary'
60
+ >>> session_state.favorite_color
61
+ 'black'
62
+ Since you set user_name above, next time your script runs this will be the
63
+ result:
64
+ >>> session_state = get(user_name='', favorite_color='black')
65
+ >>> session_state.user_name
66
+ 'Mary'
67
+ """
68
+ # Hack to get the session object from Streamlit.
69
+
70
+ ctx = ReportThread.get_report_ctx()
71
+
72
+ this_session = None
73
+
74
+ current_server = Server.get_current()
75
+ if hasattr(current_server, '_session_infos'):
76
+ # Streamlit < 0.56
77
+ session_infos = Server.get_current()._session_infos.values()
78
+ else:
79
+ session_infos = Server.get_current()._session_info_by_id.values()
80
+
81
+ for session_info in session_infos:
82
+ s = session_info.session
83
+ if (
84
+ # Streamlit < 0.54.0
85
+ (hasattr(s, '_main_dg') and s._main_dg == ctx.main_dg)
86
+ or
87
+ # Streamlit >= 0.54.0
88
+ (not hasattr(s, '_main_dg') and s.enqueue == ctx.enqueue)
89
+ or
90
+ # Streamlit >= 0.65.2
91
+ (not hasattr(s, '_main_dg') and s._uploaded_file_mgr == ctx.uploaded_file_mgr)
92
+ ):
93
+ this_session = s
94
+
95
+ if this_session is None:
96
+ raise RuntimeError(
97
+ "Oh noes. Couldn't get your Streamlit Session object. "
98
+ 'Are you doing something fancy with threads?')
99
+
100
+ # Got the session object! Now let's attach some state into it.
101
+
102
+ if not hasattr(this_session, '_custom_session_state'):
103
+ this_session._custom_session_state = SessionState(**kwargs)
104
+
105
+ return this_session._custom_session_state