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 | """ |
---|
12 | return Student Statistics |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Student.Statistics') |
---|
16 | |
---|
17 | try: |
---|
18 | from Products.AdvancedQuery import Eq, Between, Le,In, Ge |
---|
19 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
20 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
21 | except: |
---|
22 | evalAdvancedQuery = None |
---|
23 | logger.info('"%s","invoked new statistics"' % context.portal_membership.getAuthenticatedMember()) |
---|
24 | l = [] |
---|
25 | if not context.isStaff(): |
---|
26 | return l |
---|
27 | dep = {} |
---|
28 | |
---|
29 | dep['id'] = "All Faculties" |
---|
30 | |
---|
31 | umequery = 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) |
---|
35 | total_new = aq_students(umequery) |
---|
36 | total_new = float(len(total_new)) |
---|
37 | dep['new'] = "%.0f" % total_new |
---|
38 | |
---|
39 | |
---|
40 | #from Products.zdb import set_trace;set_trace() |
---|
41 | |
---|
42 | adm_res = context.portal_catalog(review_state ='admitted') |
---|
43 | adm_ids = [r.getId for r in adm_res] |
---|
44 | adm = len(adm_res) |
---|
45 | dep['admitted'] = adm |
---|
46 | dep['admitted_percent'] = "%.0f" % round(adm*100/total_new) |
---|
47 | |
---|
48 | cpe_res = context.portal_catalog(review_state ='clearance_pin_entered') |
---|
49 | cpe_ids = [r.getId for r in cpe_res] |
---|
50 | cpe = len(cpe_res) |
---|
51 | dep['clearance_pin_entered'] = cpe |
---|
52 | dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new) |
---|
53 | |
---|
54 | cr_res = context.portal_catalog(review_state='clearance_requested') |
---|
55 | cr_ids = [r.getId for r in cr_res] |
---|
56 | cr = len(cr_res) |
---|
57 | dep['clearance_requested'] = cr |
---|
58 | dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new) |
---|
59 | |
---|
60 | cav_res = context.portal_catalog(review_state ='cleared_and_validated') |
---|
61 | cav_ids = [r.getId for r in cav_res] |
---|
62 | cav = len(cav_res) |
---|
63 | dep['cleared_and_validated'] = cav |
---|
64 | dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new) |
---|
65 | |
---|
66 | or_res = context.portal_catalog(review_state='objection_raised') |
---|
67 | or_ids = [r.getId for r in or_res] |
---|
68 | ora = len(or_res) |
---|
69 | dep['objection_raised'] = ora |
---|
70 | dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new) |
---|
71 | |
---|
72 | l.append(dep) |
---|
73 | fs = context.portal_catalog(portal_type="Faculty") |
---|
74 | for 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 | |
---|
119 | return l |
---|