source: WAeUP_SRP/branches/uli/skins/waeup_student/getNewStudentStatistics.py @ 1693

Last change on this file since 1693 was 1593, checked in by uli, 18 years ago

Merged current trunk into uli-branch.

File size: 3.8 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"""
14import logging
15logger = logging.getLogger('Skins.getNewStudentStatistics')
16
17try:
18    from Products.AdvancedQuery import Eq, Between, Le,In, Ge
19    aq_portal = context.portal_catalog.evalAdvancedQuery
20    aq_students = context.students_catalog.evalAdvancedQuery
21except:
22    evalAdvancedQuery = None
23logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
24l = []
25if not context.isStaff():
26    return l
27dep = {}
28
29dep['id'] = "All Faculties"
30
31freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
32total_new = aq_students(freshquery)
33total_new = float(len(total_new))
34dep['new'] = "%.0f" % total_new
35
36
37#from Products.zdb import set_trace;set_trace()
38
39adm_res = context.portal_catalog(review_state ='admitted')
40adm_ids = [r.getId for r in adm_res]
41adm = len(adm_res)
42dep['admitted'] = adm
43dep['admitted_percent'] =  "%.0f" % round(adm*100/total_new)
44
45cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
46cpe_ids = [r.getId for r in cpe_res]
47cpe = len(cpe_res)
48dep['clearance_pin_entered'] = cpe
49dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new)
50
51cr_res = context.portal_catalog(review_state='clearance_requested')
52cr_ids = [r.getId for r in cr_res]
53cr = len(cr_res)
54dep['clearance_requested'] = cr
55dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new)
56
57cav_res = context.portal_catalog(review_state ='cleared_and_validated')
58cav_ids = [r.getId for r in cav_res]
59cav = len(cav_res)
60dep['cleared_and_validated'] = cav
61dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new)
62
63or_res = context.portal_catalog(review_state='objection_raised')
64or_ids = [r.getId for r in or_res]
65ora = len(or_res)
66dep['objection_raised'] = ora
67dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new)
68
69total_sfp = total_new - (cav + cr + cpe + adm + ora)
70dep['rest'] = int(total_sfp)
71dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new)
72
73
74l.append(dep)
75fs = context.portal_catalog(portal_type="Faculty")
76for fid in [f.getId for f in fs]:
77    dep = {}
78    dep['id'] = fid
79    fquery = Eq('faculty',fid)
80    fac_res = aq_students(fquery & freshquery)
81    fac_ids = [r.id for r in fac_res]
82    total = float(len(fac_res))
83
84    if total == 0:
85        continue
86
87    dep['new'] = "%.0f" % total
88
89    adm = len([s for s in fac_ids if s in adm_ids])
90    dep['admitted'] = adm
91    dep['admitted_percent'] = 0
92    if total:
93        dep['admitted_percent'] = "%.0f" % round(adm*100/total)
94
95    cpe = len([s for s in fac_ids if s in cpe_ids])
96    dep['clearance_pin_entered'] = cpe
97    dep['clearance_pin_entered_percent'] = 0
98    if total:
99        dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total)
100    cr = len([s for s in fac_ids if s in cr_ids])
101    dep['clearance_requested'] = cr
102    dep['clearance_requested_percent'] = 0
103    if total:
104        dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total)
105    cav = len([s for s in fac_ids if s in cav_ids])
106    dep['cleared_and_validated'] = cav
107    dep['cleared_and_validated_percent'] = 0
108    if total:
109        dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total)
110
111    ora = len([s for s in fac_ids if s in or_ids])
112    dep['objection_raised'] = ora
113    dep['objection_raised_percent'] = 0
114    if total:
115        dep['objection_raised_percent'] = "%.0f" % round(ora*100/total)
116
117    rest = int(total - (cav + cr + cpe + adm + ora))
118    dep['rest'] = rest
119    dep['rest_percent'] = "%.0f" % round(rest*100/total)
120
121    l.append(dep)
122
123return l
124
Note: See TracBrowser for help on using the repository browser.