source: WAeUP_SRP/branches/srpp_on_branch/skins/waeup_student/getNewStudentStatistics.py @ 5505

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

new student statistics
sc payment beautified
student workflow state and transition renamed

File size: 3.9 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
31total_new = aq_students(Eq('level','100'))
32total_new = float(len(total_new))
33dep['new'] = "%.0f" % total_new
34
35
36#from Products.zdb import set_trace;set_trace()
37
38adm_res = context.portal_catalog(review_state ='admitted')
39adm_ids = [r.getId for r in adm_res]
40adm = len(adm_res)
41dep['admitted'] = adm
42dep['admitted_percent'] =  "%.0f" % round(adm*100/total_new)
43
44cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
45cpe_ids = [r.getId for r in cpe_res]
46cpe = len(cpe_res)
47dep['clearance_pin_entered'] = cpe
48dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new)
49
50cr_res = context.portal_catalog(review_state='clearance_requested')
51cr_ids = [r.getId for r in cr_res]
52cr = len(cr_res)
53dep['clearance_requested'] = cr
54dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new)
55
56cav_res = context.portal_catalog(review_state ='cleared_and_validated')
57cav_ids = [r.getId for r in cav_res]
58cav = len(cav_res)
59dep['cleared_and_validated'] = cav
60dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new)
61
62or_res = context.portal_catalog(review_state='objection_raised')
63or_ids = [r.getId for r in or_res]
64ora = len(or_res)
65dep['objection_raised'] = ora
66dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new)
67
68ret_res = context.portal_catalog(review_state ='returning')
69ret_ids = [r.getId for r in ret_res]
70total_ret = aq_students(Ge('level','200'))
71total_ret = float(len(total_ret))
72dep['returning'] = "%.0f" % total_ret
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    squery = Eq('level','100')
81    fac_res = aq_students(fquery & squery)
82    fac_ids = [r.id for r in fac_res]
83    total = float(len(fac_res))
84    #if total == 0:
85    #    continue
86    dep['new'] = "%.0f" % total
87
88    adm = len([s for s in fac_ids if s in adm_ids])
89    dep['admitted'] = adm
90    dep['admitted_percent'] = 0
91    if total:
92        dep['admitted_percent'] = "%.0f" % round(adm*100/total)
93
94    cpe = len([s for s in fac_ids if s in cpe_ids])
95    dep['clearance_pin_entered'] = cpe
96    dep['clearance_pin_entered_percent'] = 0
97    if total:
98        dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total)
99    cr = len([s for s in fac_ids if s in cr_ids])
100    dep['clearance_requested'] = cr
101    dep['clearance_requested_percent'] = 0
102    if total:
103        dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total)
104    cav = len([s for s in fac_ids if s in cav_ids])
105    dep['cleared_and_validated'] = cav
106    dep['cleared_and_validated_percent'] = 0
107    if total:
108        dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total)
109    ora = len([s for s in fac_ids if s in or_ids])
110    dep['objection_raised'] = ora
111    dep['objection_raised_percent'] = 0
112    if total:
113        dep['objection_raised_percent'] = "%.0f" % round(ora*100/total)
114
115    squery = Ge('level','200')
116    fac_res = aq_students(fquery & squery)
117    fac_ids = [r.id for r in fac_res]
118    ret = len([s for s in fac_ids if s in ret_ids])
119    dep['returning'] = ret
120
121    if total == 0 and ret == 0:
122        continue
123
124    l.append(dep)
125
126return l
Note: See TracBrowser for help on using the repository browser.