[1286] | 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 |
---|
[1593] | 15 | logger = logging.getLogger('Skins.getNewStudentStatistics') |
---|
[1286] | 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 |
---|
[1593] | 23 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
[1286] | 24 | l = [] |
---|
| 25 | if not context.isStaff(): |
---|
| 26 | return l |
---|
| 27 | dep = {} |
---|
| 28 | |
---|
| 29 | dep['id'] = "All Faculties" |
---|
| 30 | |
---|
[1530] | 31 | freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE')) |
---|
| 32 | total_new = aq_students(freshquery) |
---|
[1286] | 33 | total_new = float(len(total_new)) |
---|
| 34 | dep['new'] = "%.0f" % total_new |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | #from Products.zdb import set_trace;set_trace() |
---|
| 38 | |
---|
| 39 | adm_res = context.portal_catalog(review_state ='admitted') |
---|
| 40 | adm_ids = [r.getId for r in adm_res] |
---|
| 41 | adm = len(adm_res) |
---|
| 42 | dep['admitted'] = adm |
---|
| 43 | dep['admitted_percent'] = "%.0f" % round(adm*100/total_new) |
---|
| 44 | |
---|
| 45 | cpe_res = context.portal_catalog(review_state ='clearance_pin_entered') |
---|
| 46 | cpe_ids = [r.getId for r in cpe_res] |
---|
| 47 | cpe = len(cpe_res) |
---|
| 48 | dep['clearance_pin_entered'] = cpe |
---|
| 49 | dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new) |
---|
| 50 | |
---|
| 51 | cr_res = context.portal_catalog(review_state='clearance_requested') |
---|
| 52 | cr_ids = [r.getId for r in cr_res] |
---|
| 53 | cr = len(cr_res) |
---|
| 54 | dep['clearance_requested'] = cr |
---|
| 55 | dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new) |
---|
| 56 | |
---|
| 57 | cav_res = context.portal_catalog(review_state ='cleared_and_validated') |
---|
| 58 | cav_ids = [r.getId for r in cav_res] |
---|
| 59 | cav = len(cav_res) |
---|
| 60 | dep['cleared_and_validated'] = cav |
---|
| 61 | dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new) |
---|
| 62 | |
---|
| 63 | or_res = context.portal_catalog(review_state='objection_raised') |
---|
| 64 | or_ids = [r.getId for r in or_res] |
---|
| 65 | ora = len(or_res) |
---|
| 66 | dep['objection_raised'] = ora |
---|
| 67 | dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new) |
---|
| 68 | |
---|
[1530] | 69 | total_sfp = total_new - (cav + cr + cpe + adm + ora) |
---|
| 70 | dep['rest'] = int(total_sfp) |
---|
| 71 | dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new) |
---|
| 72 | |
---|
| 73 | |
---|
[1286] | 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) |
---|
[1530] | 80 | fac_res = aq_students(fquery & freshquery) |
---|
[1286] | 81 | fac_ids = [r.id for r in fac_res] |
---|
| 82 | total = float(len(fac_res)) |
---|
[1530] | 83 | |
---|
| 84 | if total == 0: |
---|
| 85 | continue |
---|
| 86 | |
---|
[1286] | 87 | dep['new'] = "%.0f" % total |
---|
| 88 | |
---|
| 89 | adm = len([s for s in fac_ids if s in adm_ids]) |
---|
| 90 | dep['admitted'] = adm |
---|
| 91 | dep['admitted_percent'] = 0 |
---|
| 92 | if total: |
---|
| 93 | dep['admitted_percent'] = "%.0f" % round(adm*100/total) |
---|
| 94 | |
---|
| 95 | cpe = len([s for s in fac_ids if s in cpe_ids]) |
---|
| 96 | dep['clearance_pin_entered'] = cpe |
---|
| 97 | dep['clearance_pin_entered_percent'] = 0 |
---|
| 98 | if total: |
---|
| 99 | dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total) |
---|
| 100 | cr = len([s for s in fac_ids if s in cr_ids]) |
---|
| 101 | dep['clearance_requested'] = cr |
---|
| 102 | dep['clearance_requested_percent'] = 0 |
---|
| 103 | if total: |
---|
| 104 | dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total) |
---|
| 105 | cav = len([s for s in fac_ids if s in cav_ids]) |
---|
| 106 | dep['cleared_and_validated'] = cav |
---|
| 107 | dep['cleared_and_validated_percent'] = 0 |
---|
| 108 | if total: |
---|
| 109 | dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total) |
---|
[1593] | 110 | |
---|
[1286] | 111 | ora = len([s for s in fac_ids if s in or_ids]) |
---|
| 112 | dep['objection_raised'] = ora |
---|
| 113 | dep['objection_raised_percent'] = 0 |
---|
| 114 | if total: |
---|
| 115 | dep['objection_raised_percent'] = "%.0f" % round(ora*100/total) |
---|
| 116 | |
---|
[1530] | 117 | rest = int(total - (cav + cr + cpe + adm + ora)) |
---|
| 118 | dep['rest'] = rest |
---|
| 119 | dep['rest_percent'] = "%.0f" % round(rest*100/total) |
---|
[1286] | 120 | |
---|
| 121 | l.append(dep) |
---|
| 122 | |
---|
| 123 | return l |
---|
[1530] | 124 | |
---|