1 | ## Script (Python) "getNewStudentStatistics" |
---|
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.getNewStudentStatistics') |
---|
17 | |
---|
18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
19 | if not context.isStaff(): |
---|
20 | return |
---|
21 | |
---|
22 | session_id = context.getSessionId()[0] |
---|
23 | session_id_num = int(session_id) |
---|
24 | entry_sessions = (session_id,str(session_id_num)) |
---|
25 | |
---|
26 | # students with entry_session None (-1) are interprteted as new AND returning students if they are |
---|
27 | # in either of the last three states |
---|
28 | |
---|
29 | new_states = ('student_created', |
---|
30 | 'admitted', |
---|
31 | 'clearance_pin_entered', |
---|
32 | 'objection_raised', |
---|
33 | 'clearance_requested', |
---|
34 | 'cleared_and_validated', |
---|
35 | 'school_fee_paid', |
---|
36 | 'courses_registered', |
---|
37 | 'courses_validated', |
---|
38 | ) |
---|
39 | |
---|
40 | full_time = ('ume_ft','de_ft','ug_ft','pg_ft') |
---|
41 | part_time = ( 'de_pt','ug_pt','pg_pt') |
---|
42 | diploma = ('dp_ft','dp_pt') |
---|
43 | |
---|
44 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
45 | |
---|
46 | l = [] |
---|
47 | |
---|
48 | |
---|
49 | fac_res = {} |
---|
50 | |
---|
51 | dict = {} |
---|
52 | dict['id'] = 'All Faculties' |
---|
53 | dict['title'] = 'All Faculties' |
---|
54 | |
---|
55 | res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time, review_state = new_states) |
---|
56 | dict['total_ft'] = len(res_ft) |
---|
57 | |
---|
58 | res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time, review_state = new_states) |
---|
59 | dict['total_pt'] = len(res_pt) |
---|
60 | |
---|
61 | res_dp = context.students_catalog(entry_session = entry_sessions, mode = diploma, review_state = new_states) |
---|
62 | dict['total_dp'] = len(res_dp) |
---|
63 | |
---|
64 | for state in new_states: |
---|
65 | # full_time |
---|
66 | res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time) |
---|
67 | state_ft = state + '_ft' |
---|
68 | dict[state_ft] = len(res_ft) |
---|
69 | statepercent = state+'_ft_percent' |
---|
70 | if dict['total_ft'] > 0: |
---|
71 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
72 | else: |
---|
73 | dict[statepercent] = 0 |
---|
74 | |
---|
75 | # part_time |
---|
76 | res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time) |
---|
77 | state_pt = state + '_pt' |
---|
78 | dict[state_pt] = len(res_pt) |
---|
79 | statepercent = state+'_pt_percent' |
---|
80 | if dict['total_pt'] > 0: |
---|
81 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
82 | else: |
---|
83 | dict[statepercent] = 0 |
---|
84 | |
---|
85 | # diploma |
---|
86 | res_dp = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = diploma) |
---|
87 | state_dp = state + '_dp' |
---|
88 | dict[state_dp] = len(res_dp) |
---|
89 | statepercent = state+'_dp_percent' |
---|
90 | if dict['total_dp'] > 0: |
---|
91 | dict[statepercent] = "%.0f" % round(dict[state_dp]*100.0/dict['total_dp']) |
---|
92 | else: |
---|
93 | dict[statepercent] = 0 |
---|
94 | |
---|
95 | l.append(dict) |
---|
96 | |
---|
97 | |
---|
98 | for f in faculties: |
---|
99 | dict = {} |
---|
100 | dict['id'] = f.getId |
---|
101 | dict['title'] = f.Title |
---|
102 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) |
---|
103 | dict['total_ft'] = len(res_ft) |
---|
104 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) |
---|
105 | dict['total_pt'] = len(res_pt) |
---|
106 | res_dp = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = diploma) |
---|
107 | dict['total_dp'] = len(res_dp) |
---|
108 | for state in new_states: |
---|
109 | # full_time |
---|
110 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time) |
---|
111 | state_ft = state + '_ft' |
---|
112 | dict[state_ft] = len(res_ft) |
---|
113 | statepercent = state+'_ft_percent' |
---|
114 | if dict['total_ft'] > 0: |
---|
115 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
116 | else: |
---|
117 | dict[statepercent] = 0 |
---|
118 | |
---|
119 | # part_time |
---|
120 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time) |
---|
121 | state_pt = state + '_pt' |
---|
122 | dict[state_pt] = len(res_pt) |
---|
123 | statepercent = state+'_pt_percent' |
---|
124 | if dict['total_pt'] > 0: |
---|
125 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
126 | else: |
---|
127 | dict[statepercent] = 0 |
---|
128 | |
---|
129 | # diploma |
---|
130 | res_dp = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = diploma) |
---|
131 | state_dp = state + '_dp' |
---|
132 | dict[state_dp] = len(res_dp) |
---|
133 | statepercent = state+'_dp_percent' |
---|
134 | if dict['total_dp'] > 0: |
---|
135 | dict[statepercent] = "%.0f" % round(dict[state_dp]*100.0/dict['total_dp']) |
---|
136 | else: |
---|
137 | dict[statepercent] = 0 |
---|
138 | |
---|
139 | l.append(dict) |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | return l |
---|
144 | |
---|
145 | |
---|