@@ -3,5 +3,79 @@ def get_structure(fetcher, cookies, student_no, token):
33 return fetcher .get_structure_via_api (cookies , student_no , token )
44
55
6+ def filter_grades_data (data ):
7+ if not data or 'Result' not in data :
8+ return data
9+
10+ result = data ['Result' ]
11+ filtered_result = {
12+ 'StudentName' : result .get ('StudentName' ),
13+ 'StudentClassName' : result .get ('StudentClassName' ),
14+ 'StudentSeatNo' : result .get ('StudentSeatNo' ),
15+ 'StudentNo' : result .get ('StudentNo' ),
16+ 'GetDataTimeDisplay' : result .get ('GetDataTimeDisplay' ),
17+ 'Show班級排名' : result .get ('Show班級排名' ),
18+ 'Show班級排名人數' : result .get ('Show班級排名人數' ),
19+ 'Show類組排名' : result .get ('Show類組排名' ),
20+ 'Show類組排名人數' : result .get ('Show類組排名人數' ),
21+ }
22+
23+ if 'ExamItem' in result and result ['ExamItem' ]:
24+ exam = result ['ExamItem' ]
25+ filtered_result ['ExamItem' ] = {
26+ 'ExamName' : exam .get ('ExamName' ),
27+ 'ClassRank' : exam .get ('ClassRank' ),
28+ 'ClassCount' : exam .get ('ClassCount' ),
29+ '類組排名' : exam .get ('類組排名' ),
30+ '類組排名Count' : exam .get ('類組排名Count' )
31+ }
32+
33+ if 'SubjectExamInfoList' in result :
34+ filtered_result ['SubjectExamInfoList' ] = [
35+ {
36+ 'SubjectName' : subject .get ('SubjectName' ),
37+ 'ScoreDisplay' : subject .get ('ScoreDisplay' ),
38+ 'Score' : subject .get ('Score' ),
39+ 'ClassAVGScoreDisplay' : subject .get ('ClassAVGScoreDisplay' ),
40+ 'ClassAVGScore' : subject .get ('ClassAVGScore' ),
41+ 'ClassRank' : subject .get ('ClassRank' ),
42+ 'ClassRankCount' : subject .get ('ClassRankCount' ),
43+ 'YearRank' : subject .get ('YearRank' ),
44+ 'YearRankCount' : subject .get ('YearRankCount' ),
45+ 'YearTermDisplay' : subject .get ('YearTermDisplay' )
46+ }
47+ for subject in result ['SubjectExamInfoList' ]
48+ ]
49+
50+ if '成績五標List' in result :
51+ filtered_result ['成績五標List' ] = [
52+ {
53+ 'SubjectName' : std .get ('SubjectName' ),
54+ '頂標' : std .get ('頂標' ),
55+ '前標' : std .get ('前標' ),
56+ '均標' : std .get ('均標' ),
57+ '後標' : std .get ('後標' ),
58+ '底標' : std .get ('底標' ),
59+ '標準差' : std .get ('標準差' ),
60+ '大於90Count' : std .get ('大於90Count' , 0 ),
61+ '大於80Count' : std .get ('大於80Count' , 0 ),
62+ '大於70Count' : std .get ('大於70Count' , 0 ),
63+ '大於60Count' : std .get ('大於60Count' , 0 ),
64+ '大於50Count' : std .get ('大於50Count' , 0 ),
65+ '大於40Count' : std .get ('大於40Count' , 0 ),
66+ '大於30Count' : std .get ('大於30Count' , 0 ),
67+ '大於20Count' : std .get ('大於20Count' , 0 ),
68+ '大於10Count' : std .get ('大於10Count' , 0 ),
69+ '大於0Count' : std .get ('大於0Count' , 0 )
70+ }
71+ for std in result ['成績五標List' ]
72+ ]
73+
74+ # 保留原本的 Message, Status 等外層結構
75+ data ['Result' ] = filtered_result
76+ return data
77+
78+
679def fetch_grades (fetcher , cookies , student_no , token , year_value , exam_value ):
7- return fetcher .fetch_grades_via_api (cookies , student_no , token , year_value , exam_value )
80+ raw_data = fetcher .fetch_grades_via_api (cookies , student_no , token , year_value , exam_value )
81+ return filter_grades_data (raw_data )
0 commit comments