source: WAeUP_SRP/base/skins/waeup_statistics/getPreviousRetStudentStatistics.py @ 2987

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

in case they want to see more ...

File size: 3.6 KB
Line 
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"""
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 =      ('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                   )
36full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
37part_time =       (         'de_pt','ug_pt','pg_pt')
38
39faculties = context.portal_catalog(portal_type="Faculty")
40
41l = []
42
43
44fac_res = {}
45
46dict = {}
47dict['id'] = 'All Faculties'
48dict['title'] = 'All Faculties'
49
50res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = ret_states)
51dict['total_ft'] = len(res_ft)
52
53res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = ret_states)
54dict['total_pt'] = len(res_pt)
55
56for 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
77l.append(dict)
78
79
80for 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
111return l
112
113
Note: See TracBrowser for help on using the repository browser.