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 = ('94','95','96','97','98','99','00','01','02','03','04','05') |
---|
23 | |
---|
24 | new_states = ('returning', |
---|
25 | 'school_fee_paid', |
---|
26 | 'courses_registered', |
---|
27 | 'courses_validated', |
---|
28 | ) |
---|
29 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
30 | |
---|
31 | l = [] |
---|
32 | |
---|
33 | |
---|
34 | fac_res = {} |
---|
35 | |
---|
36 | dict = {} |
---|
37 | dict['id'] = 'All Faculties' |
---|
38 | dict['title'] = 'All Faculties' |
---|
39 | res = context.students_catalog(entry_session = entry_sessions) |
---|
40 | dict['total'] = len(res) |
---|
41 | for state in new_states: |
---|
42 | res = context.students_catalog(entry_session = entry_sessions, review_state = state) |
---|
43 | dict[state] = len(res) |
---|
44 | statepercent = state+'_percent' |
---|
45 | if dict['total'] > 0: |
---|
46 | dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) |
---|
47 | else: |
---|
48 | dict[statepercent] = 0 |
---|
49 | l.append(dict) |
---|
50 | |
---|
51 | for f in faculties: |
---|
52 | dict = {} |
---|
53 | dict['id'] = f.getId |
---|
54 | dict['title'] = f.Title |
---|
55 | res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId) |
---|
56 | dict['total'] = len(res) |
---|
57 | for state in new_states: |
---|
58 | res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state) |
---|
59 | dict[state] = len(res) |
---|
60 | statepercent = state+'_percent' |
---|
61 | if dict['total'] > 0: |
---|
62 | dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) |
---|
63 | else: |
---|
64 | dict[statepercent] = 0 |
---|
65 | l.append(dict) |
---|
66 | |
---|
67 | return l |
---|
68 | |
---|
69 | |
---|