source: WAeUP_SRP/branches/regebro-noskins/skins/waeup_student/getNewStudentStatistics.py @ 15142

Last change on this file since 15142 was 1520, checked in by joachim, 18 years ago

Ghana changes

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