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

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

close security holes

File size: 3.4 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
21
22entry_sessions = ('-1','94','95','96','97','98','99','00','01','02','03','04','05','0','1','2','3','4','5')
23
24ret_states =      ('returning',
25                   'school_fee_paid',
26                   'courses_registered',
27                   'courses_validated',
28                   )
29full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
30part_time =       (         'de_pt','ug_pt','pg_pt')
31
32faculties = context.portal_catalog(portal_type="Faculty")
33
34l = []
35
36
37fac_res = {}
38
39dict = {}
40dict['id'] = 'All Faculties'
41dict['title'] = 'All Faculties'
42
43res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = ret_states)
44dict['total_ft'] = len(res_ft)
45
46res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = ret_states)
47dict['total_pt'] = len(res_pt)
48
49for state in ret_states:
50    # full_time
51    res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = full_time)
52    state_ft = state + '_ft'
53    dict[state_ft] = len(res_ft)
54    statepercent = state+'_ft_percent'
55    if dict['total_ft'] > 0:
56        dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
57    else:
58        dict[statepercent] = 0
59
60    # part_time
61    res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = part_time)
62    state_pt = state + '_pt'
63    dict[state_pt] = len(res_pt)
64    statepercent = state+'_pt_percent'
65    if dict['total_pt'] > 0:
66        dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
67    else:
68        dict[statepercent] = 0
69
70l.append(dict)
71
72
73for f in faculties:
74    dict = {}
75    dict['id'] = f.getId
76    dict['title'] = f.Title
77    res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time)
78    dict['total_ft'] = len(res_ft)
79    res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time)
80    dict['total_pt'] = len(res_pt)
81    for state in ret_states:
82        # full_time
83        res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time)
84        state_ft = state + '_ft'
85        dict[state_ft] = len(res_ft)
86        statepercent = state+'_ft_percent'
87        if dict['total_ft'] > 0:
88            dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
89        else:
90            dict[statepercent] = 0
91
92        # part_time
93        res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time)
94        state_pt = state + '_pt'
95        dict[state_pt] = len(res_pt)
96        statepercent = state+'_pt_percent'
97        if dict['total_pt'] > 0:
98            dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
99        else:
100            dict[statepercent] = 0
101
102    l.append(dict)
103
104return l
105
106
Note: See TracBrowser for help on using the repository browser.