[1081] | 1 | ## Script (Python) "getStudentStatistics" |
---|
| 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 1128 2006-12-22 00:28:30Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Student Statistic |
---|
| 13 | """ |
---|
| 14 | try: |
---|
| 15 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
| 16 | aq_portal = context.portal_catalog.evalAdvancedQuery |
---|
| 17 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
| 18 | except: |
---|
| 19 | evalAdvancedQuery = None |
---|
| 20 | l = [] |
---|
| 21 | if not context.isStaff(): |
---|
| 22 | return l |
---|
| 23 | dep = {} |
---|
| 24 | dep['id'] = "All" |
---|
[1112] | 25 | total = len(context.students_catalog()) |
---|
| 26 | dep['students'] = total |
---|
| 27 | cpe_res = context.portal_catalog(review_state ='clearance_pin_entered') |
---|
| 28 | cpe_ids = [r.getId for r in cpe_res] |
---|
| 29 | cpe = len(cpe_res) |
---|
| 30 | dep['clearance_pin_entered'] = cpe |
---|
| 31 | dep['clearance_pin_entered_percent'] = (cpe*100/total) |
---|
| 32 | cr_res = context.portal_catalog(review_state='clearance_requested') |
---|
| 33 | cr_ids = [r.getId for r in cr_res] |
---|
| 34 | cr = len(cr_res) |
---|
| 35 | dep['clearance_requested'] = cr |
---|
| 36 | dep['clearance_requested_percent'] = (cr*100/total) |
---|
| 37 | cav_res = context.portal_catalog(review_state ='cleared_and_validated') |
---|
| 38 | cav_ids = [r.getId for r in cav_res] |
---|
| 39 | cav = len(cav_res) |
---|
| 40 | dep['cleared_and_validated'] = cav |
---|
| 41 | dep['cleared_and_validated_percent'] = (cav*100/total) |
---|
| 42 | or_res = context.portal_catalog(review_state='objection_raised') |
---|
| 43 | or_ids = [r.getId for r in or_res] |
---|
| 44 | ora = len(or_res) |
---|
| 45 | dep['objection_raised'] = ora |
---|
| 46 | dep['objection_raised_percent'] = (ora*100/total) |
---|
[1081] | 47 | l.append(dep) |
---|
[1112] | 48 | fs = context.portal_catalog(portal_type="Faculty") |
---|
| 49 | #from Products.zdb import set_trace;set_trace() |
---|
| 50 | for fid in [f.getId for f in fs]: |
---|
| 51 | dep = {} |
---|
| 52 | dep['id'] = fid |
---|
| 53 | fquery = Eq('portal_type','Faculty') |
---|
| 54 | fac_res = context.students_catalog(faculty=fid) |
---|
| 55 | fac_ids = [r.id for r in fac_res] |
---|
| 56 | total = len(fac_res) |
---|
[1128] | 57 | if total == 0: |
---|
| 58 | continue |
---|
[1112] | 59 | dep['students'] = total |
---|
| 60 | cpe = len([s for s in fac_ids if s in cpe_ids]) |
---|
| 61 | dep['clearance_pin_entered'] = cpe |
---|
| 62 | dep['clearance_pin_entered_percent'] = 0 |
---|
| 63 | if total: |
---|
| 64 | dep['clearance_pin_entered_percent'] = (cpe*100/total) |
---|
| 65 | cr = len([s for s in fac_ids if s in cr_ids]) |
---|
| 66 | dep['clearance_requested'] = cr |
---|
| 67 | dep['clearance_requested_percent'] = 0 |
---|
| 68 | if total: |
---|
| 69 | dep['clearance_requested_percent'] = (cr*100/total) |
---|
| 70 | cav = len([s for s in fac_ids if s in cav_ids]) |
---|
| 71 | dep['cleared_and_validated'] = cav |
---|
| 72 | dep['cleared_and_validated_percent'] = 0 |
---|
| 73 | if total: |
---|
| 74 | dep['cleared_and_validated_percent'] = (cav*100/total) |
---|
| 75 | ora = len([s for s in fac_ids if s in or_ids]) |
---|
| 76 | dep['objection_raised'] = ora |
---|
| 77 | dep['objection_raised_percent'] = 0 |
---|
| 78 | if total: |
---|
| 79 | dep['objection_raised_percent'] = (ora*100/total) |
---|
| 80 | l.append(dep) |
---|
[1081] | 81 | return l |
---|