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: getNewStudentStatistics_old.py 1673 2007-04-09 16:01:51Z joachim $ |
---|
11 | """ |
---|
12 | return Student Statistics |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('Skins.getNewStudentStatistics') |
---|
16 | |
---|
17 | try: |
---|
18 | from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp |
---|
19 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
20 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
21 | except: |
---|
22 | evalAdvancedQuery = None |
---|
23 | logger.info('%s invoked 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 | freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE')) |
---|
32 | total_new = aq_students(freshquery) |
---|
33 | total_new = float(len(total_new)) |
---|
34 | ##newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*') |
---|
35 | ##total_new = aq_portal(newquery) |
---|
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 | total_sfp = total_new - (cav + cr + cpe + adm + ora) |
---|
73 | dep['rest'] = int(total_sfp) |
---|
74 | dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new) |
---|
75 | |
---|
76 | |
---|
77 | l.append(dep) |
---|
78 | fs = context.portal_catalog(portal_type="Faculty") |
---|
79 | for fid in [f.getId for f in fs]: |
---|
80 | dep = {} |
---|
81 | dep['id'] = fid |
---|
82 | fquery = Eq('faculty',fid) |
---|
83 | fac_res = aq_students(fquery & freshquery) |
---|
84 | fac_ids = [r.id for r in fac_res] |
---|
85 | total = float(len(fac_res)) |
---|
86 | |
---|
87 | if total == 0: |
---|
88 | continue |
---|
89 | |
---|
90 | dep['new'] = "%.0f" % total |
---|
91 | |
---|
92 | adm = len([s for s in fac_ids if s in adm_ids]) |
---|
93 | dep['admitted'] = adm |
---|
94 | dep['admitted_percent'] = 0 |
---|
95 | if total: |
---|
96 | dep['admitted_percent'] = "%.0f" % round(adm*100/total) |
---|
97 | |
---|
98 | cpe = len([s for s in fac_ids if s in cpe_ids]) |
---|
99 | dep['clearance_pin_entered'] = cpe |
---|
100 | dep['clearance_pin_entered_percent'] = 0 |
---|
101 | if total: |
---|
102 | dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total) |
---|
103 | cr = len([s for s in fac_ids if s in cr_ids]) |
---|
104 | dep['clearance_requested'] = cr |
---|
105 | dep['clearance_requested_percent'] = 0 |
---|
106 | if total: |
---|
107 | dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total) |
---|
108 | cav = len([s for s in fac_ids if s in cav_ids]) |
---|
109 | dep['cleared_and_validated'] = cav |
---|
110 | dep['cleared_and_validated_percent'] = 0 |
---|
111 | if total: |
---|
112 | dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total) |
---|
113 | |
---|
114 | ora = len([s for s in fac_ids if s in or_ids]) |
---|
115 | dep['objection_raised'] = ora |
---|
116 | dep['objection_raised_percent'] = 0 |
---|
117 | if total: |
---|
118 | dep['objection_raised_percent'] = "%.0f" % round(ora*100/total) |
---|
119 | |
---|
120 | rest = int(total - (cav + cr + cpe + adm + ora)) |
---|
121 | dep['rest'] = rest |
---|
122 | dep['rest_percent'] = "%.0f" % round(rest*100/total) |
---|
123 | |
---|
124 | l.append(dep) |
---|
125 | |
---|
126 | return l |
---|
127 | |
---|