source: WAeUP_SRP/trunk/skins/waeup_statistics/getRetStudentStatistics.py @ 7657

Last change on this file since 7657 was 3774, checked in by Henrik Bettermann, 16 years ago

resolve ticket #462

File size: 4.9 KB
RevLine 
[2243]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():
[2660]20    return 'Not allowed'
[2243]21
[2705]22current_session = context.getSessionId()[0]
23
[3774]24
25
26range1 = range(94,100,1)
27range2 = range(0,int(current_session),1)
28missing_values = ['','-1']
29entry_sessions = missing_values + [str(k) for k in range1+range2] + ['0'+str(k) for k in range2]
30
31#entry_sessions = ('','-1','94','95','96','97','98','99','00','01','02','03','04','05','06','07','0','1','2','3','4','5','6','7')
32
[2243]33ret_states =      ('returning',
34                   'school_fee_paid',
35                   'courses_registered',
36                   'courses_validated',
37                   )
38full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
39part_time =       (         'de_pt','ug_pt','pg_pt')
[3774]40diploma   =       ('dp_ft','dp_pt')
[2243]41
42faculties = context.portal_catalog(portal_type="Faculty")
43
44l = []
45
46
47fac_res = {}
48
49dict = {}
50dict['id'] = 'All Faculties'
51dict['title'] = 'All Faculties'
52
53res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = ret_states)
54dict['total_ft'] = len(res_ft)
55
56res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = ret_states)
57dict['total_pt'] = len(res_pt)
58
[3774]59res_dp = context.students_catalog(entry_session = entry_sessions,  mode = diploma, review_state = ret_states)
60dict['total_dp'] = len(res_dp)
61
[2243]62for state in ret_states:
63    # full_time
[2705]64    res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = full_time, session = current_session)
[2243]65    state_ft = state + '_ft'
66    dict[state_ft] = len(res_ft)
67    statepercent = state+'_ft_percent'
68    if dict['total_ft'] > 0:
69        dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
70    else:
71        dict[statepercent] = 0
72
73    # part_time
[2705]74    res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = part_time, session = current_session)
[2243]75    state_pt = state + '_pt'
76    dict[state_pt] = len(res_pt)
77    statepercent = state+'_pt_percent'
78    if dict['total_pt'] > 0:
79        dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
80    else:
81        dict[statepercent] = 0
[3774]82       
83    # diploma
84    res_dp = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = diploma, session = current_session)
85    state_dp = state + '_dp'
86    dict[state_dp] = len(res_dp)
87    statepercent = state+'_dp_percent'
88    if dict['total_dp'] > 0:
89        dict[statepercent] = "%.0f" % round(dict[state_dp]*100.0/dict['total_dp'])
90    else:
91        dict[statepercent] = 0       
[2243]92
93l.append(dict)
94
95
96for f in faculties:
97    dict = {}
98    dict['id'] = f.getId
99    dict['title'] = f.Title
100    res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time)
101    dict['total_ft'] = len(res_ft)
102    res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time)
103    dict['total_pt'] = len(res_pt)
[3774]104    res_dp = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = diploma)
105    dict['total_dp'] = len(res_dp)   
[2243]106    for state in ret_states:
107        # full_time
[2705]108        res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time, session = current_session)
[2243]109        state_ft = state + '_ft'
110        dict[state_ft] = len(res_ft)
111        statepercent = state+'_ft_percent'
112        if dict['total_ft'] > 0:
113            dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
114        else:
115            dict[statepercent] = 0
116
117        # part_time
[2705]118        res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time, session = current_session)
[2243]119        state_pt = state + '_pt'
120        dict[state_pt] = len(res_pt)
121        statepercent = state+'_pt_percent'
122        if dict['total_pt'] > 0:
123            dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
124        else:
125            dict[statepercent] = 0
[3774]126           
127        # diploma
128        res_dp = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = diploma, session = current_session)
129        state_dp = state + '_dp'
130        dict[state_dp] = len(res_dp)
131        statepercent = state+'_dp_percent'
132        if dict['total_dp'] > 0:
133            dict[statepercent] = "%.0f" % round(dict[state_dp]*100.0/dict['total_dp'])
134        else:
135            dict[statepercent] = 0
136           
[2243]137
138    l.append(dict)
139
140return l
141
142
Note: See TracBrowser for help on using the repository browser.