source: WAeUP_SRP/base/skins/waeup_statistics/getNewStudentStatistics.py @ 3560

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

new statistics for session 2007/2008

File size: 3.6 KB
Line 
1## Script (Python) "getNewStudentStatistics"
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.getNewStudentStatistics')
17
18logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
19if not context.isStaff():
20    return
21
22entry_sessions = (context.getSessionId()[0])
23
24# students with entry_session None (-1) are interprteted as new AND returning students if they are
25# in either of the last three states
26
27new_states =      ('student_created',
28                   'admitted',
29                   'clearance_pin_entered',
30                   'objection_raised',
31                   'clearance_requested',
32                   'cleared_and_validated',
33                   'school_fee_paid',
34                   'courses_registered',
35                   'courses_validated',
36                   )
37
38full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
39part_time =       (         'de_pt','ug_pt','pg_pt')
40
41faculties = context.portal_catalog(portal_type="Faculty")
42
43l = []
44
45
46fac_res = {}
47
48dict = {}
49dict['id'] = 'All Faculties'
50dict['title'] = 'All Faculties'
51
52res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = new_states)
53dict['total_ft'] = len(res_ft)
54
55res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = new_states)
56dict['total_pt'] = len(res_pt)
57
58for state in new_states:
59    # full_time
60    res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = full_time)
61    state_ft = state + '_ft'
62    dict[state_ft] = len(res_ft)
63    statepercent = state+'_ft_percent'
64    if dict['total_ft'] > 0:
65        dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
66    else:
67        dict[statepercent] = 0
68
69    # part_time
70    res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state,  mode = part_time)
71    state_pt = state + '_pt'
72    dict[state_pt] = len(res_pt)
73    statepercent = state+'_pt_percent'
74    if dict['total_pt'] > 0:
75        dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
76    else:
77        dict[statepercent] = 0
78
79l.append(dict)
80
81
82for f in faculties:
83    dict = {}
84    dict['id'] = f.getId
85    dict['title'] = f.Title
86    res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time)
87    dict['total_ft'] = len(res_ft)
88    res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time)
89    dict['total_pt'] = len(res_pt)
90    for state in new_states:
91        # full_time
92        res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time)
93        state_ft = state + '_ft'
94        dict[state_ft] = len(res_ft)
95        statepercent = state+'_ft_percent'
96        if dict['total_ft'] > 0:
97            dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft'])
98        else:
99            dict[statepercent] = 0
100
101        # part_time
102        res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time)
103        state_pt = state + '_pt'
104        dict[state_pt] = len(res_pt)
105        statepercent = state+'_pt_percent'
106        if dict['total_pt'] > 0:
107            dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt'])
108        else:
109            dict[statepercent] = 0
110
111    l.append(dict)
112
113
114
115return l
116
117
Note: See TracBrowser for help on using the repository browser.