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