source: WAeUP_SRP/base/skins/waeup_statistics/getRetStudentStatistics.py @ 3649

Last change on this file since 3649 was 2705, checked in by Henrik Bettermann, 17 years ago

new statistics for session 2007/2008

File size: 3.5 KB
Line 
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"""
12return Student Statistics
13"""
14
15import logging
16logger = logging.getLogger('Skins.getRetStudentStatistics')
17
18logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
19if not context.isStaff():
20    return 'Not allowed'
21
22entry_sessions = ('','-1','94','95','96','97','98','99','00','01','02','03','04','05','06','0','1','2','3','4','5','6')
23
24current_session = context.getSessionId()[0]
25
26ret_states =      ('returning',
27                   'school_fee_paid',
28                   'courses_registered',
29                   'courses_validated',
30                   )
31full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
32part_time =       (         'de_pt','ug_pt','pg_pt')
33
34faculties = context.portal_catalog(portal_type="Faculty")
35
36l = []
37
38
39fac_res = {}
40
41dict = {}
42dict['id'] = 'All Faculties'
43dict['title'] = 'All Faculties'
44
45res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = ret_states)
46dict['total_ft'] = len(res_ft)
47
48res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = ret_states)
49dict['total_pt'] = len(res_pt)
50
51for 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
72l.append(dict)
73
74
75for 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
106return l
107
108
Note: See TracBrowser for help on using the repository browser.