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

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

prepare statistics for session 2007/2008

06/07 new students who are not yet cleared will not be counted.

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