267 |
{{ title[0] }}
268 |
269 | {{ title[2] }} 发表
270 | {{ title[3] }}
271 |
272 |
273 |
16 |
17 |
48 |
49 |
60 |
75 |
76 |
77 |
78 |
79 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/templates/personal_information.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
个人中心
12 |
13 |
14 |
15 |
16 |
17 |
48 |
49 |
62 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
98 |
99 |
100 |
个人信息
101 |
102 |
首页 >
103 |
个人中心 >
104 |
个人信息
105 |
106 |
107 |
108 |
姓名:{{ result[0][0] }}
109 |
学号:{{ result[0][2] }}
110 |
学院:{{ result[0][3] }}
111 |
专业:{{ result[0][4] }}
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/templates/recommed.html:
--------------------------------------------------------------------------------
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 |
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 |
--------------------------------------------------------------------------------
/templates/register.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
注册
6 |
7 |
8 |
9 |
10 |
11 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
89 |
90 |
--------------------------------------------------------------------------------
/templates/train_plan.html:
--------------------------------------------------------------------------------
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 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | 总进度
83 |
89 | 思想政治
90 |
96 | 外语
97 |
103 | 文化素质
104 |
110 | 体育
111 |
117 | 军事
118 |
124 | 健康教育
125 |
131 | 数学
132 |
138 | 物理
139 |
145 | 计算机
146 |
152 | 学科基础
153 |
159 | 专业选修
160 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
179 |
180 |
183 |
184 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
202 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
--------------------------------------------------------------------------------
/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__init__.py
--------------------------------------------------------------------------------
/utils/__pycache__/__init__.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/__init__.cpython-36.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/__init__.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/__init__.cpython-37.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/config.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/config.cpython-36.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/config.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/config.cpython-37.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/map_student_course.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/map_student_course.cpython-36.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/map_student_course.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/map_student_course.cpython-37.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/query.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/query.cpython-36.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/query.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/query.cpython-37.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/recommed_module.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/recommed_module.cpython-36.pyc
--------------------------------------------------------------------------------
/utils/__pycache__/recommed_module.cpython-37.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/utils/__pycache__/recommed_module.cpython-37.pyc
--------------------------------------------------------------------------------
/utils/map_student_course.py:
--------------------------------------------------------------------------------
1 | from utils.query import query
2 |
3 | def get_map_student():
4 | map_student = {}
5 | stuNo2MatNo = {}
6 | sql = "SELECT NAME, STU_NO FROM STUDENT WHERE STU_NO<>'admin'"
7 | result = query(sql)
8 | map_student_id = 0
9 | for cur in result:
10 | values = list(cur)
11 | map_student[map_student_id] = values
12 | map_student_id = map_student_id + 1
13 |
14 | map_course = {}
15 | sql="SELECT CO_NAME FROM EDUCATION_PLAN"
16 | result = query(sql)
17 | map_course_id = 0
18 | for cur in result:
19 | map_course[map_course_id] = cur[0]
20 | map_course_id = map_course_id + 1
21 |
22 | for idx in range(len(map_student)):
23 | stuNo2MatNo[map_student[idx][1]] = idx
24 | return map_student, map_course, stuNo2MatNo
25 |
26 |
27 | def get_matrix(map_student):
28 | matrix = []
29 | for i in range(30):
30 | matrix.append([])
31 | for i in range(30):
32 | stu_no = map_student[i][1]
33 | #print(stu_no)
34 | sql="SELECT COMMENT FROM CHOOSE WHERE STU_NO='%s'" % (stu_no)
35 | score=query(sql)
36 | #print(score)
37 | for j in range(118):
38 | matrix[i].append(int(score[j][0]))
39 |
40 | return matrix
41 |
42 |
--------------------------------------------------------------------------------
/utils/query.py:
--------------------------------------------------------------------------------
1 | import pymysql
2 | from config import config
3 |
4 | def query(sql):
5 | """
6 | 功能; 使用sql语句查询数据库中学生选课信息.
7 | 参数: sql(string)
8 | """
9 | db = pymysql.connect('localhost', 'root', config['MYSQL_PASSWORD'], config['DATABASE_NAME'], charset='utf8')
10 | cur = db.cursor()
11 | try:
12 | cur.execute(sql)
13 | result = cur.fetchall()
14 | db.commit()
15 |
16 | #print('query success')
17 |
18 | # print('query success')
19 | except:
20 | # print('query loss')
21 | db.rollback()
22 | cur.close()
23 | db.close()
24 | return result
25 |
26 |
27 | def update(sql):
28 | """
29 | 功能; 使用sql语句更新数据库中学生选课信息。
30 | 参数: sql(string)
31 | """
32 | db = pymysql.connect('localhost', 'root', config['MYSQL_PASSWORD'], config['DATABASE_NAME'], charset='utf8')
33 | cur = db.cursor()
34 | try:
35 | cur.execute(sql)
36 | db.commit()
37 | #print('update success')
38 | # print('update success')
39 | except:
40 | # print('update loss')
41 | db.rollback()
42 | cur.close()
43 | db.close()
44 |
45 | def getPlanTreeJson(stu_id):
46 | """
47 | 功能: 传入学生stu_id,然后利用stu_id从数据库查询得到该学生选课信息,再转换为计划树所需的json格式
48 | :param stu_id: 唯一标识学生的id号
49 | :return: 学生选课计划树Json数据
50 | """
51 | print(stu_id)
52 | sql = "select FINISHED_CO from EDU_STU_PLAN WHERE STU_NO='%s'" % stu_id
53 | result = query(sql)
54 | print(result)
55 | finished_co = result[0][0]
56 | print(finished_co)
57 |
58 | data = {}
59 | data['name'] = '总进度'
60 | children = []
61 |
62 | children1 = {}
63 | children1['name'] = '思想政治理论'
64 | children1_list =[]
65 | children2 = {}
66 | children2['name'] = '外语'
67 | children2_list = []
68 | children3 = {}
69 | children3['name'] = '文化素质教育必修'
70 | children3_list = []
71 | children4 = {}
72 | children4['name'] = '体育'
73 | children4_list = []
74 | children5 = {}
75 | children5['name'] = '军事'
76 | children5_list = []
77 | children6 = {}
78 | children6['name'] = '健康教育'
79 | children6_list = []
80 | children7 = {}
81 | children7['name'] = '数学'
82 | children7_list = []
83 | children8 = {}
84 | children8['name'] = '物理'
85 | children8_list = []
86 | children9 = {}
87 | children9['name'] = '计算机'
88 | children9_list = []
89 | children10 = {}
90 | children10['name'] = '学科基础'
91 | children10_list = []
92 | children11 = {}
93 | children11['name'] = '专业选修'
94 | children11_list = []
95 | aid = 1
96 |
97 | score = [0.0] * 15
98 |
99 | add_time_list = []
100 | for j in range(44):
101 | add_time_list.append([])
102 |
103 | sql="SELECT CO_NO,COMMENT FROM CHOOSE WHERE STU_NO='%s'" % stu_id
104 | course2score=query(sql)
105 | co2score = {}
106 | for cur in course2score:
107 | co2score[cur[0]] = cur[1]
108 |
109 | #print(co2score)
110 |
111 | for co in finished_co:
112 | course_add = {}
113 | aid_str = str(aid)
114 | sql = "select CLASSIFICATION, START_TIME, CO_NAME, IS_MUST, CREDITS, CO_NO from education_plan WHERE CO_100='%s'" % aid_str
115 | co_name = query(sql)
116 | #print('数据库查询结果')
117 | #print(co_name)
118 | aid = aid + 1
119 | add_is_list = []
120 |
121 | add_curse = {}
122 | add_is = {}
123 |
124 | add_score = float(co_name[0][4])
125 |
126 | if co == '0':
127 | #print(co_name)
128 | add_curse['name'] = co_name[0][2]
129 | add_curse['itemStyle'] = {'borderColor': 'red'}
130 | add_curse['value'] = add_score
131 | add_curse['score'] = int(co2score[co_name[0][5]])
132 |
133 | if co_name[0][3] == 1:
134 | add_is['name'] = '必修'
135 | else:
136 | add_is['name'] = '选修'
137 |
138 | add_is_list.append(add_curse)
139 | add_is['children'] = add_is_list
140 | # add_time['name'] = str(co_name[0][1])
141 | # add_time_list.append(add_is)
142 | # add_time['children'] = add_time_list
143 | else:
144 | add_curse['name'] = co_name[0][2]
145 | add_curse['itemStyle'] = {'borderColor': 'green'}
146 | add_curse['value'] = add_score
147 | add_curse['score'] = int(co2score[co_name[0][5]])
148 |
149 | if co_name[0][3] == 1:
150 | add_is['name'] = '必修'
151 | else:
152 | add_is['name'] = '选修'
153 |
154 | add_is_list.append(add_curse)
155 | add_is['children'] = add_is_list
156 | # add_time['name'] = str(co_name[0][1])
157 | # add_time_list.append(add_is)
158 | # add_time['children'] = add_time_list
159 |
160 | str_co_time = str(co_name[0][1])
161 | if co_name[0][0] == '思想政治理论':
162 | if str_co_time[3] == '6':
163 | add_time_list[0].append(add_is)
164 | if str_co_time[3] == '7':
165 | add_time_list[1].append(add_is)
166 | if str_co_time[3] == '8':
167 | add_time_list[2].append(add_is)
168 | if str_co_time[3] == '9':
169 | add_time_list[3].append(add_is)
170 | if co_name[0][0] == '外语':
171 | if str_co_time[3] == '6':
172 | add_time_list[4].append(add_is)
173 | if str_co_time[3] == '7':
174 | add_time_list[5].append(add_is)
175 | if str_co_time[3] == '8':
176 | add_time_list[6].append(add_is)
177 | if str_co_time[3] == '9':
178 | add_time_list[7].append(add_is)
179 | if co_name[0][0] == '文化素质教育必修':
180 | if str_co_time[3] == '6':
181 | add_time_list[8].append(add_is)
182 | if str_co_time[3] == '7':
183 | add_time_list[9].append(add_is)
184 | if str_co_time[3] == '8':
185 | add_time_list[10].append(add_is)
186 | if str_co_time[3] == '9':
187 | add_time_list[11].append(add_is)
188 | if co_name[0][0] == '体育':
189 | if str_co_time[3] == '6':
190 | add_time_list[12].append(add_is)
191 | if str_co_time[3] == '7':
192 | add_time_list[13].append(add_is)
193 | if str_co_time[3] == '8':
194 | add_time_list[14].append(add_is)
195 | if str_co_time[3] == '9':
196 | add_time_list[15].append(add_is)
197 | if co_name[0][0] == '军事':
198 | if str_co_time[3] == '6':
199 | add_time_list[16].append(add_is)
200 | if str_co_time[3] == '7':
201 | add_time_list[17].append(add_is)
202 | if str_co_time[3] == '8':
203 | add_time_list[18].append(add_is)
204 | if str_co_time[3] == '9':
205 | add_time_list[19].append(add_is)
206 | if co_name[0][0] == '健康教育':
207 | if str_co_time[3] == '6':
208 | add_time_list[20].append(add_is)
209 | if str_co_time[3] == '7':
210 | add_time_list[21].append(add_is)
211 | if str_co_time[3] == '8':
212 | add_time_list[22].append(add_is)
213 | if str_co_time[3] == '9':
214 | add_time_list[23].append(add_is)
215 | if co_name[0][0] == '数学':
216 | if str_co_time[3] == '6':
217 | add_time_list[24].append(add_is)
218 | if str_co_time[3] == '7':
219 | add_time_list[25].append(add_is)
220 | if str_co_time[3] == '8':
221 | add_time_list[26].append(add_is)
222 | if str_co_time[3] == '9':
223 | add_time_list[27].append(add_is)
224 | if co_name[0][0] == '物理':
225 | if str_co_time[3] == '6':
226 | add_time_list[28].append(add_is)
227 | if str_co_time[3] == '7':
228 | add_time_list[29].append(add_is)
229 | if str_co_time[3] == '8':
230 | add_time_list[30].append(add_is)
231 | if str_co_time[3] == '9':
232 | add_time_list[31].append(add_is)
233 | if co_name[0][0] == '计算机':
234 | if str_co_time[3] == '6':
235 | add_time_list[32].append(add_is)
236 | if str_co_time[3] == '7':
237 | add_time_list[33].append(add_is)
238 | if str_co_time[3] == '8':
239 | add_time_list[34].append(add_is)
240 | if str_co_time[3] == '9':
241 | add_time_list[35].append(add_is)
242 | if co_name[0][0] == '学科基础':
243 | if str_co_time[3] == '6':
244 | add_time_list[36].append(add_is)
245 | if str_co_time[3] == '7':
246 | add_time_list[37].append(add_is)
247 | if str_co_time[3] == '8':
248 | add_time_list[38].append(add_is)
249 | if str_co_time[3] == '9':
250 | add_time_list[39].append(add_is)
251 | if co_name[0][0] == '专业选修':
252 | if str_co_time[3] == '6':
253 | add_time_list[40].append(add_is)
254 | if str_co_time[3] == '7':
255 | add_time_list[41].append(add_is)
256 | if str_co_time[3] == '8':
257 | add_time_list[42].append(add_is)
258 | if str_co_time[3] == '9':
259 | add_time_list[43].append(add_is)
260 |
261 | add_time = {}
262 | add_time['name'] = '2016'
263 | add_time['children'] = add_time_list[0]
264 | children1_list.append(add_time)
265 | add_time = {}
266 | add_time['name'] = '2017'
267 | add_time['children'] = add_time_list[1]
268 | children1_list.append(add_time)
269 | add_time = {}
270 | add_time['name'] = '2018'
271 | add_time['children'] = add_time_list[2]
272 | children1_list.append(add_time)
273 | add_time = {}
274 | add_time['name'] = '2019'
275 | add_time['children'] = add_time_list[3]
276 | children1_list.append(add_time)
277 |
278 | add_time = {}
279 | add_time['name'] = '2016'
280 | add_time['children'] = add_time_list[4]
281 | children2_list.append(add_time)
282 | add_time = {}
283 | add_time['name'] = '2017'
284 | add_time['children'] = add_time_list[5]
285 | children2_list.append(add_time)
286 | add_time = {}
287 | add_time['name'] = '2018'
288 | add_time['children'] = add_time_list[6]
289 | children2_list.append(add_time)
290 | add_time = {}
291 | add_time['name'] = '2019'
292 | add_time['children'] = add_time_list[7]
293 | children2_list.append(add_time)
294 |
295 | add_time = {}
296 | add_time['name'] = '2016'
297 | add_time['children'] = add_time_list[8]
298 | children3_list.append(add_time)
299 | add_time = {}
300 | add_time['name'] = '2017'
301 | add_time['children'] = add_time_list[9]
302 | children3_list.append(add_time)
303 | add_time = {}
304 | add_time['name'] = '2018'
305 | add_time['children'] = add_time_list[10]
306 | children3_list.append(add_time)
307 | add_time = {}
308 | add_time['name'] = '2019'
309 | add_time['children'] = add_time_list[11]
310 | children3_list.append(add_time)
311 |
312 | add_time = {}
313 | add_time['name'] = '2016'
314 | add_time['children'] = add_time_list[12]
315 | children4_list.append(add_time)
316 | add_time = {}
317 | add_time['name'] = '2017'
318 | add_time['children'] = add_time_list[13]
319 | children4_list.append(add_time)
320 | add_time = {}
321 | add_time['name'] = '2018'
322 | add_time['children'] = add_time_list[14]
323 | children4_list.append(add_time)
324 | add_time = {}
325 | add_time['name'] = '2019'
326 | add_time['children'] = add_time_list[15]
327 | children4_list.append(add_time)
328 |
329 | add_time = {}
330 | add_time['name'] = '2016'
331 | add_time['children'] = add_time_list[16]
332 | children5_list.append(add_time)
333 | add_time = {}
334 | add_time['name'] = '2017'
335 | add_time['children'] = add_time_list[17]
336 | children5_list.append(add_time)
337 | add_time = {}
338 | add_time['name'] = '2018'
339 | add_time['children'] = add_time_list[18]
340 | children5_list.append(add_time)
341 | add_time = {}
342 | add_time['name'] = '2019'
343 | add_time['children'] = add_time_list[19]
344 | children5_list.append(add_time)
345 |
346 | add_time = {}
347 | add_time['name'] = '2016'
348 | add_time['children'] = add_time_list[20]
349 | children6_list.append(add_time)
350 | add_time = {}
351 | add_time['name'] = '2017'
352 | add_time['children'] = add_time_list[21]
353 | children6_list.append(add_time)
354 | add_time = {}
355 | add_time['name'] = '2018'
356 | add_time['children'] = add_time_list[22]
357 | children6_list.append(add_time)
358 | add_time = {}
359 | add_time['name'] = '2019'
360 | add_time['children'] = add_time_list[23]
361 | children6_list.append(add_time)
362 |
363 | add_time = {}
364 | add_time['name'] = '2016'
365 | add_time['children'] = add_time_list[24]
366 | children7_list.append(add_time)
367 | add_time = {}
368 | add_time['name'] = '2017'
369 | add_time['children'] = add_time_list[25]
370 | children7_list.append(add_time)
371 | add_time = {}
372 | add_time['name'] = '2018'
373 | add_time['children'] = add_time_list[26]
374 | children7_list.append(add_time)
375 | add_time = {}
376 | add_time['name'] = '2019'
377 | add_time['children'] = add_time_list[27]
378 | children7_list.append(add_time)
379 |
380 | add_time = {}
381 | add_time['name'] = '2016'
382 | add_time['children'] = add_time_list[28]
383 | children8_list.append(add_time)
384 | add_time = {}
385 | add_time['name'] = '2017'
386 | add_time['children'] = add_time_list[29]
387 | children8_list.append(add_time)
388 | add_time = {}
389 | add_time['name'] = '2018'
390 | add_time['children'] = add_time_list[30]
391 | children8_list.append(add_time)
392 | add_time = {}
393 | add_time['name'] = '2019'
394 | add_time['children'] = add_time_list[31]
395 | children8_list.append(add_time)
396 |
397 | add_time = {}
398 | add_time['name'] = '2016'
399 | add_time['children'] = add_time_list[32]
400 | children9_list.append(add_time)
401 | add_time = {}
402 | add_time['name'] = '2017'
403 | add_time['children'] = add_time_list[33]
404 | children9_list.append(add_time)
405 | add_time = {}
406 | add_time['name'] = '2018'
407 | add_time['children'] = add_time_list[34]
408 | children9_list.append(add_time)
409 | add_time = {}
410 | add_time['name'] = '2019'
411 | add_time['children'] = add_time_list[35]
412 | children9_list.append(add_time)
413 |
414 | add_time = {}
415 | add_time['name'] = '2016'
416 | add_time['children'] = add_time_list[36]
417 | children10_list.append(add_time)
418 | add_time = {}
419 | add_time['name'] = '2017'
420 | add_time['children'] = add_time_list[37]
421 | children10_list.append(add_time)
422 | add_time = {}
423 | add_time['name'] = '2018'
424 | add_time['children'] = add_time_list[38]
425 | children10_list.append(add_time)
426 | add_time = {}
427 | add_time['name'] = '2019'
428 | add_time['children'] = add_time_list[39]
429 | children10_list.append(add_time)
430 |
431 | add_time = {}
432 | add_time['name'] = '2016'
433 | add_time['children'] = add_time_list[40]
434 | children11_list.append(add_time)
435 | add_time = {}
436 | add_time['name'] = '2017'
437 | add_time['children'] = add_time_list[41]
438 | children11_list.append(add_time)
439 | add_time = {}
440 | add_time['name'] = '2018'
441 | add_time['children'] = add_time_list[42]
442 | children11_list.append(add_time)
443 | add_time = {}
444 | add_time['name'] = '2019'
445 | add_time['children'] = add_time_list[43]
446 | children11_list.append(add_time)
447 |
448 | children1['value'] = 16
449 | children2['value'] = 8
450 | children3['value'] = 5.5
451 | children4['value'] = 4
452 | children5['value'] = 5
453 | children6['value'] = 0.5
454 | children7['value'] = 21.5
455 | children8['value'] = 9
456 | children9['value'] = 4.0
457 | children10['value'] = 24.5
458 | children11['value'] = 21.5
459 |
460 | children1['children'] = children1_list
461 | children2['children'] = children2_list
462 | children3['children'] = children3_list
463 | children4['children'] = children4_list
464 | children5['children'] = children5_list
465 | children6['children'] = children6_list
466 | children7['children'] = children7_list
467 | children8['children'] = children8_list
468 | children9['children'] = children9_list
469 | children10['children'] = children10_list
470 | children11['children'] = children11_list
471 |
472 | children.append(children1)
473 | children.append(children2)
474 | children.append(children3)
475 | children.append(children4)
476 | children.append(children5)
477 | children.append(children6)
478 | children.append(children7)
479 | children.append(children8)
480 | children.append(children9)
481 | children.append(children10)
482 | children.append(children11)
483 | data['children'] = children
484 | return data
485 |
486 | def updateDatabase(stu_id, train_plan):
487 | """
488 | 功能: 用户在“培养计划”界面点击“提交”按钮后,使用最新“计划树”信息更新数据库
489 | :param stu_id: 唯一标识学生的id
490 | :param train_plan: “培养计划”界面“计划树”数据的json格式
491 | :return: 无
492 | """
493 | data = train_plan['children']
494 | array_finish = [0]*120
495 | # print(array_finish)
496 | for data_children in data:
497 | data_children = data_children['children']
498 | print(data_children)
499 | for data_children_child_1 in data_children:
500 | # print('data_children_child', data_children_child)
501 | data_children_child_1 = data_children_child_1['children']
502 | for data_children_child in data_children_child_1:
503 | name = data_children_child['children'][0]['name']
504 | color = data_children_child['children'][0]['itemStyle']['borderColor']
505 | #print(name, color)
506 | sql = "select CO_100 from education_plan WHERE CO_NAME='%s'" % name
507 | co_100 = query(sql)
508 | co_100 = co_100[0][0]
509 |
510 | if color == 'red':
511 | array_finish[int(co_100)] = 0
512 | else:
513 | array_finish[int(co_100)] = 1
514 | finish_co = ''
515 | for i in range(1, 119):
516 | if array_finish[i] == 1:
517 | finish_co += '1'
518 | else:
519 | finish_co += '0'
520 | print(finish_co)
521 | #print(array_finish)
522 | sql = "UPDATE edu_stu_plan SET FINISHED_CO='%s' WHERE STU_NO='%s'" % (finish_co,stu_id)
523 | update(sql)
524 |
525 |
526 | def updateScore(stu_id, scores):
527 | sql="SELECT CO_NO, CO_NAME FROM EDUCATION_PLAN";
528 | name2no = {}
529 | result = query(sql)
530 | for cur in result:
531 | name2no[cur[1]] = cur[0]
532 |
533 | for cur in scores:
534 | sql="UPDATE CHOOSE SET COMMENT='%d' WHERE STU_NO='%s' AND CO_NO='%s'" % (scores[cur], stu_id, name2no[cur])
535 | #print(sql)
536 | update(sql)
--------------------------------------------------------------------------------
/utils/recommed_module.py:
--------------------------------------------------------------------------------
1 | # 相似性度量函数, 输入列向量, 归一化 0-1
2 | from numpy import *
3 | import numpy as np
4 | from numpy import linalg as la
5 |
6 | def getSigK(Sigma, k):
7 | '''
8 | 输入:
9 | Sigma: 输入的奇异值向量
10 | k: 取前几个奇异值
11 | 输出:(k,k)的矩阵
12 | '''
13 | eyeK = np.eye(k)
14 | return mat(eyeK * Sigma[:k])
15 | def reBuild(U, Sigma, VT, k):
16 | '''
17 | 使用前k个特征值重构数据
18 | '''
19 | Sigk = getSigK(Sigma, k)
20 | # 左行右列
21 | return mat(np.dot(np.dot(U[:,:k], Sigk), VT[: k,:]))
22 |
23 | def ecludSim(inA,inB):
24 | return 1.0/(1.0 + la.norm(inA - inB))
25 |
26 | def cosSim(inA, inB):
27 | '''
28 | 基于余弦相似性度量
29 | '''
30 | sim = float(inA.T* inB) / (la.norm(inA) * la.norm(inB))
31 | return 0.5 + 0.5 * sim
32 |
33 | def svdMethod(svdData, dataMat, simMeas, user, item):
34 | '''
35 | 输入:
36 | 见recommend函数
37 | 输出:
38 | Score(double): user对item的评分
39 | 算法流程:
40 | 1. for item_other in allItem
41 | 2. if haveBeenScore(item_other)
42 | 3. compute_Simliar_Score(item, item_other)
43 | 4. return Score
44 | '''
45 | N = shape(dataMat)[1]
46 | simTotal = 0.0
47 | ratSimTotal = 0.0
48 | U, Sigma, I_t = svdData
49 | k = 0
50 | while sum(Sigma[:k]) < sum(Sigma) * 0.9:
51 | k = k+ 1
52 | SigK = getSigK(Sigma, k)
53 | itemFeature = dataMat.T * U[:,:k] * SigK.I
54 | for j in range(N):
55 | if dataMat[user,j] == 0 or j == item:
56 | continue
57 | sim = simMeas(itemFeature[item,:].T, itemFeature[j,:].T)
58 | # print("the similarity between {} and {} is {}".format(j,item, sim))
59 | ratSim = dataMat[user, j] * sim
60 | simTotal += sim
61 | ratSimTotal += ratSim
62 | if simTotal == 0:
63 | return 0
64 | return ratSimTotal / simTotal
65 |
66 | def recommedCoursePerson(dataMat, user, N=7, simMeas=ecludSim, estMethod=svdMethod):
67 | '''
68 | 输入:
69 | dataMat(mat)(M,N): 评分矩阵.
70 | use(int): 想推荐的用户id.
71 | N(int): 为用户推荐的未评分的商品个数
72 | simMeas(double): 两个特征向量的相似度评价函数
73 | estMethod(double):推荐核心方法,计算商品对于用户的分数的函数
74 | 输出:
75 | N * (item, 评分): N个商品以及其的评分
76 | 算法流程:
77 | 1. 找到所有未评分的商品
78 | 2. 若没有未评分商品,退出
79 | 3. 遍历未评分商品.
80 | 4. 计算用户可能对该商品的评分
81 | 5. 排序取前N个输出.
82 | '''
83 | print(user)
84 | dataMat = mat(dataMat)
85 | unRatedItems = nonzero(dataMat[user,:].A == 0)[1]
86 | if len(unRatedItems) == 0:
87 | print("没有未评分商品")
88 | return None
89 | U, Sigma, I_t = la.svd(dataMat)
90 | item_and_score = []
91 | for item in unRatedItems:
92 | score = estMethod([U, Sigma, I_t], dataMat, simMeas, user, item)
93 | item_and_score.append((item, score))
94 |
95 | k = 0
96 | while sum(Sigma[:k]) < sum(Sigma) * 0.9:
97 | k = k+ 1
98 | SigK = getSigK(Sigma, k)
99 | userFeature = dataMat * I_t[:,:k] * SigK.I
100 | recomedUserVec = userFeature[user,:]
101 | user_and_score = []
102 | for idx, each in enumerate(userFeature):
103 | if user != idx:
104 | user_and_score.append((idx, cosSim(recomedUserVec.T, each.T)))
105 | recommedCourse = sorted(item_and_score, key=lambda k: k[1], reverse=True)[:min(N, len(item_and_score))]
106 | recommedPerson = sorted(user_and_score, key=lambda k: k[1], reverse=True)[:min(N, len(user_and_score))]
107 | print(recommedCourse)
108 | print(recommedPerson)
109 | return recommedCourse, recommedPerson
110 |
111 |
112 | def toBarJson(data, dict2id):
113 | """
114 |
115 | :param data: [(0, 5.0), (1, 5.0), (2, 5.0)]
116 | :return::
117 | {
118 | "source": [
119 | [2.3, "计算机视觉"],
120 | [1.1, "自然语言处理"],
121 | [2.4, "高等数学"],
122 | [3.1, "线性代数"],
123 | [4.7, "计算机网络"],
124 | [5.1, "离散数学"]
125 | ]
126 | }
127 | """
128 | jsonData = {"source":[]}
129 | for each in data:
130 | unit = [each[1], dict2id[each[0]]]
131 | jsonData['source'].append(unit)
132 | return jsonData
133 |
134 | def regularData(data, a, b):
135 | """
136 | 功能,将列表的值归一化到[a,b]之间
137 | """
138 | dataNum = [i[0] for i in data['source']]
139 | Max, Min = max(dataNum), min(dataNum)
140 | k = (b-a)/(Max-Min)
141 | dataRg = [a+ k*(i-Min) for i in dataNum]
142 | for idx,each in enumerate(data['source']):
143 | each[0] = dataRg[idx]
144 | return data
--------------------------------------------------------------------------------
/utils/resource.py:
--------------------------------------------------------------------------------
1 | data = {}
2 | data['name'] = '总进度'
3 | children = []
4 |
5 | children1 = {}
6 | children1['name'] = '思想政治理论'
7 |
8 | children2 = {}
9 | children1['name'] = '外语'
10 |
11 | children3 = {}
12 | children1['name'] = '文化素质教育必修'
13 |
14 | children4 = {}
15 | children1['name'] = '体育'
16 |
17 | children5 = {}
18 | children1['name'] = '军事'
19 |
20 | children6 = {}
21 | children1['name'] = '健康教育'
22 |
23 | children7 = {}
24 | children1['name'] = '数学'
25 |
26 | children8 = {}
27 | children1['name'] = '物理'
28 |
29 | children9 = {}
30 | children1['name'] = '计算机'
31 |
32 | children10 = {}
33 | children1['name'] = '学科基础'
34 |
35 | children11 = {}
36 | children1['name'] = '专业选修'
37 |
38 | children.append(children1)
39 | children.append(children2)
40 | children.append(children3)
41 | children.append(children4)
42 | children.append(children5)
43 | children.append(children6)
44 | children.append(children7)
45 | children.append(children8)
46 | children.append(children9)
47 | children.append(children10)
48 | children.append(children11)
49 |
50 |
--------------------------------------------------------------------------------
/utils/toJson.py:
--------------------------------------------------------------------------------
1 |
2 | def toJson(data, length):
3 | json = []
4 | for row in data:
5 | res ={}
6 | res['value'] = row[0]
7 | json.append(res)
8 |
9 | return json
--------------------------------------------------------------------------------
/学生培养计划管理系统说明书.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xiefan-guo/studentTrainPlan/daf74215a6c683cb4f48d096d338a52d75f8a1fb/学生培养计划管理系统说明书.pdf
--------------------------------------------------------------------------------