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 | entry_sessions = ('-1','06','6') |
---|
23 | |
---|
24 | # students with entry_session None (-1) are interprteted as new AND returning students if they are |
---|
25 | # in either of the last three states |
---|
26 | |
---|
27 | new_states = ('admitted', |
---|
28 | 'clearance_pin_entered', |
---|
29 | 'objection_raised', |
---|
30 | 'clearance_requested', |
---|
31 | 'cleared_and_validated', |
---|
32 | 'school_fee_paid', |
---|
33 | 'courses_registered', |
---|
34 | 'courses_validated', |
---|
35 | ) |
---|
36 | |
---|
37 | full_time = ('ume_ft','de_ft','ug_ft','pg_ft') |
---|
38 | part_time = ( 'de_pt','ug_pt','pg_pt') |
---|
39 | |
---|
40 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
41 | |
---|
42 | l = [] |
---|
43 | |
---|
44 | |
---|
45 | fac_res = {} |
---|
46 | |
---|
47 | dict = {} |
---|
48 | dict['id'] = 'All Faculties' |
---|
49 | dict['title'] = 'All Faculties' |
---|
50 | |
---|
51 | res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time, review_state = new_states) |
---|
52 | dict['total_ft'] = len(res_ft) |
---|
53 | |
---|
54 | res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time, review_state = new_states) |
---|
55 | dict['total_pt'] = len(res_pt) |
---|
56 | |
---|
57 | for state in new_states: |
---|
58 | # full_time |
---|
59 | res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time) |
---|
60 | state_ft = state + '_ft' |
---|
61 | dict[state_ft] = len(res_ft) |
---|
62 | statepercent = state+'_ft_percent' |
---|
63 | if dict['total_ft'] > 0: |
---|
64 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
65 | else: |
---|
66 | dict[statepercent] = 0 |
---|
67 | |
---|
68 | # part_time |
---|
69 | res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time) |
---|
70 | state_pt = state + '_pt' |
---|
71 | dict[state_pt] = len(res_pt) |
---|
72 | statepercent = state+'_pt_percent' |
---|
73 | if dict['total_pt'] > 0: |
---|
74 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
75 | else: |
---|
76 | dict[statepercent] = 0 |
---|
77 | |
---|
78 | l.append(dict) |
---|
79 | |
---|
80 | |
---|
81 | for f in faculties: |
---|
82 | dict = {} |
---|
83 | dict['id'] = f.getId |
---|
84 | dict['title'] = f.Title |
---|
85 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) |
---|
86 | dict['total_ft'] = len(res_ft) |
---|
87 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) |
---|
88 | dict['total_pt'] = len(res_pt) |
---|
89 | for state in new_states: |
---|
90 | # full_time |
---|
91 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time) |
---|
92 | state_ft = state + '_ft' |
---|
93 | dict[state_ft] = len(res_ft) |
---|
94 | statepercent = state+'_ft_percent' |
---|
95 | if dict['total_ft'] > 0: |
---|
96 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
97 | else: |
---|
98 | dict[statepercent] = 0 |
---|
99 | |
---|
100 | # part_time |
---|
101 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time) |
---|
102 | state_pt = state + '_pt' |
---|
103 | dict[state_pt] = len(res_pt) |
---|
104 | statepercent = state+'_pt_percent' |
---|
105 | if dict['total_pt'] > 0: |
---|
106 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
107 | else: |
---|
108 | dict[statepercent] = 0 |
---|
109 | |
---|
110 | l.append(dict) |
---|
111 | |
---|
112 | |
---|
113 | |
---|
114 | return l |
---|
115 | |
---|
116 | |
---|