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 | total_new = aq_students(Eq('level','100')) |
---|
32 | total_new = float(len(total_new)) |
---|
33 | dep['new'] = "%.0f" % total_new |
---|
34 | |
---|
35 | |
---|
36 | #from Products.zdb import set_trace;set_trace() |
---|
37 | |
---|
38 | adm_res = context.portal_catalog(review_state ='admitted') |
---|
39 | adm_ids = [r.getId for r in adm_res] |
---|
40 | adm = len(adm_res) |
---|
41 | dep['admitted'] = adm |
---|
42 | dep['admitted_percent'] = "%.0f" % round(adm*100/total_new) |
---|
43 | |
---|
44 | cpe_res = context.portal_catalog(review_state ='clearance_pin_entered') |
---|
45 | cpe_ids = [r.getId for r in cpe_res] |
---|
46 | cpe = len(cpe_res) |
---|
47 | dep['clearance_pin_entered'] = cpe |
---|
48 | dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new) |
---|
49 | |
---|
50 | cr_res = context.portal_catalog(review_state='clearance_requested') |
---|
51 | cr_ids = [r.getId for r in cr_res] |
---|
52 | cr = len(cr_res) |
---|
53 | dep['clearance_requested'] = cr |
---|
54 | dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new) |
---|
55 | |
---|
56 | cav_res = context.portal_catalog(review_state ='cleared_and_validated') |
---|
57 | cav_ids = [r.getId for r in cav_res] |
---|
58 | cav = len(cav_res) |
---|
59 | dep['cleared_and_validated'] = cav |
---|
60 | dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new) |
---|
61 | |
---|
62 | or_res = context.portal_catalog(review_state='objection_raised') |
---|
63 | or_ids = [r.getId for r in or_res] |
---|
64 | ora = len(or_res) |
---|
65 | dep['objection_raised'] = ora |
---|
66 | dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new) |
---|
67 | |
---|
68 | ret_res = context.portal_catalog(review_state ='returning') |
---|
69 | ret_ids = [r.getId for r in ret_res] |
---|
70 | total_ret = aq_students(Ge('level','200')) |
---|
71 | total_ret = float(len(total_ret)) |
---|
72 | dep['returning'] = "%.0f" % total_ret |
---|
73 | |
---|
74 | l.append(dep) |
---|
75 | fs = context.portal_catalog(portal_type="Faculty") |
---|
76 | for 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 | |
---|
126 | return l |
---|