source: WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py @ 1389

Last change on this file since 1389 was 1318, checked in by Henrik Bettermann, 18 years ago

statistics prepared for entry_level requests

File size: 3.7 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('Student.Statistics')
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 new statistics"' % context.portal_membership.getAuthenticatedMember())
24l = []
25if not context.isStaff():
26    return l
27dep = {}
28
29dep['id'] = "All Faculties"
30
31umequery = Eq('level','100')
32#dequery = Eq('entry_mode','DE')  # only correct for 2006/2007
33#total_new = aq_students(umequery or dequery)
34total_new = aq_students(umequery)
35total_new = float(len(total_new))
36dep['new'] = "%.0f" % total_new
37
38
39#from Products.zdb import set_trace;set_trace()
40
41adm_res = context.portal_catalog(review_state ='admitted')
42adm_ids = [r.getId for r in adm_res]
43adm = len(adm_res)
44dep['admitted'] = adm
45dep['admitted_percent'] =  "%.0f" % round(adm*100/total_new)
46
47cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
48cpe_ids = [r.getId for r in cpe_res]
49cpe = len(cpe_res)
50dep['clearance_pin_entered'] = cpe
51dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new)
52
53cr_res = context.portal_catalog(review_state='clearance_requested')
54cr_ids = [r.getId for r in cr_res]
55cr = len(cr_res)
56dep['clearance_requested'] = cr
57dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new)
58
59cav_res = context.portal_catalog(review_state ='cleared_and_validated')
60cav_ids = [r.getId for r in cav_res]
61cav = len(cav_res)
62dep['cleared_and_validated'] = cav
63dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new)
64
65or_res = context.portal_catalog(review_state='objection_raised')
66or_ids = [r.getId for r in or_res]
67ora = len(or_res)
68dep['objection_raised'] = ora
69dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new)
70
71l.append(dep)
72fs = context.portal_catalog(portal_type="Faculty")
73for fid in [f.getId for f in fs]:
74    dep = {}
75    dep['id'] = fid
76    fquery = Eq('faculty',fid)
77    #umequery = Eq('level','100')
78    #fac_res = aq_students(fquery & umequery & dequery)
79    fac_res = aq_students(fquery & umequery)
80    fac_ids = [r.id for r in fac_res]
81    total = float(len(fac_res))
82    #if total == 0:
83    #    continue
84    dep['new'] = "%.0f" % total
85
86    adm = len([s for s in fac_ids if s in adm_ids])
87    dep['admitted'] = adm
88    dep['admitted_percent'] = 0
89    if total:
90        dep['admitted_percent'] = "%.0f" % round(adm*100/total)
91
92    cpe = len([s for s in fac_ids if s in cpe_ids])
93    dep['clearance_pin_entered'] = cpe
94    dep['clearance_pin_entered_percent'] = 0
95    if total:
96        dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total)
97    cr = len([s for s in fac_ids if s in cr_ids])
98    dep['clearance_requested'] = cr
99    dep['clearance_requested_percent'] = 0
100    if total:
101        dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total)
102    cav = len([s for s in fac_ids if s in cav_ids])
103    dep['cleared_and_validated'] = cav
104    dep['cleared_and_validated_percent'] = 0
105    if total:
106        dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total)
107    ora = len([s for s in fac_ids if s in or_ids])
108    dep['objection_raised'] = ora
109    dep['objection_raised_percent'] = 0
110    if total:
111        dep['objection_raised_percent'] = "%.0f" % round(ora*100/total)
112
113    if total == 0:
114        continue
115
116    l.append(dep)
117
118return l
Note: See TracBrowser for help on using the repository browser.