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