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