1 | ## Script (Python) "getRetStudentStatistics" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters= |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: getStudentStatistics.py 1277 2007-01-11 21:11:37Z joachim $ |
---|
11 | """ |
---|
12 | return Student Statistics |
---|
13 | """ |
---|
14 | |
---|
15 | import logging |
---|
16 | logger = logging.getLogger('Skins.getRetStudentStatistics') |
---|
17 | |
---|
18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
19 | if not context.isStaff(): |
---|
20 | return 'Not allowed' |
---|
21 | |
---|
22 | entry_sessions = ('','-1','94','95','96','97','98','99','00','01','02','03','04','05','06','0','1','2','3','4','5','6') |
---|
23 | |
---|
24 | current_session = context.getSessionId()[0] |
---|
25 | |
---|
26 | ret_states = ('returning', |
---|
27 | 'school_fee_paid', |
---|
28 | 'courses_registered', |
---|
29 | 'courses_validated', |
---|
30 | ) |
---|
31 | full_time = ('ume_ft','de_ft','ug_ft','pg_ft') |
---|
32 | part_time = ( 'de_pt','ug_pt','pg_pt') |
---|
33 | |
---|
34 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
35 | |
---|
36 | l = [] |
---|
37 | |
---|
38 | |
---|
39 | fac_res = {} |
---|
40 | |
---|
41 | dict = {} |
---|
42 | dict['id'] = 'All Faculties' |
---|
43 | dict['title'] = 'All Faculties' |
---|
44 | |
---|
45 | res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time, review_state = ret_states) |
---|
46 | dict['total_ft'] = len(res_ft) |
---|
47 | |
---|
48 | res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time, review_state = ret_states) |
---|
49 | dict['total_pt'] = len(res_pt) |
---|
50 | |
---|
51 | for state in ret_states: |
---|
52 | # full_time |
---|
53 | res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time, session = current_session) |
---|
54 | state_ft = state + '_ft' |
---|
55 | dict[state_ft] = len(res_ft) |
---|
56 | statepercent = state+'_ft_percent' |
---|
57 | if dict['total_ft'] > 0: |
---|
58 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
59 | else: |
---|
60 | dict[statepercent] = 0 |
---|
61 | |
---|
62 | # part_time |
---|
63 | res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time, session = current_session) |
---|
64 | state_pt = state + '_pt' |
---|
65 | dict[state_pt] = len(res_pt) |
---|
66 | statepercent = state+'_pt_percent' |
---|
67 | if dict['total_pt'] > 0: |
---|
68 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
69 | else: |
---|
70 | dict[statepercent] = 0 |
---|
71 | |
---|
72 | l.append(dict) |
---|
73 | |
---|
74 | |
---|
75 | for f in faculties: |
---|
76 | dict = {} |
---|
77 | dict['id'] = f.getId |
---|
78 | dict['title'] = f.Title |
---|
79 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) |
---|
80 | dict['total_ft'] = len(res_ft) |
---|
81 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) |
---|
82 | dict['total_pt'] = len(res_pt) |
---|
83 | for state in ret_states: |
---|
84 | # full_time |
---|
85 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time, session = current_session) |
---|
86 | state_ft = state + '_ft' |
---|
87 | dict[state_ft] = len(res_ft) |
---|
88 | statepercent = state+'_ft_percent' |
---|
89 | if dict['total_ft'] > 0: |
---|
90 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
91 | else: |
---|
92 | dict[statepercent] = 0 |
---|
93 | |
---|
94 | # part_time |
---|
95 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time, session = current_session) |
---|
96 | state_pt = state + '_pt' |
---|
97 | dict[state_pt] = len(res_pt) |
---|
98 | statepercent = state+'_pt_percent' |
---|
99 | if dict['total_pt'] > 0: |
---|
100 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
101 | else: |
---|
102 | dict[statepercent] = 0 |
---|
103 | |
---|
104 | l.append(dict) |
---|
105 | |
---|
106 | return l |
---|
107 | |
---|
108 | |
---|