[1286] | 1 | ## Script (Python) "getRetStudentStatistics" |
---|
| 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 returning 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 | #from Products.zdb import set_trace;set_trace() |
---|
| 32 | |
---|
| 33 | ret_res = context.portal_catalog(review_state ='returning') |
---|
| 34 | ret_ids = [r.getId for r in ret_res] |
---|
| 35 | total_returned = aq_students(Ge('level','200')) |
---|
| 36 | total_returned = float(len(total_returned)) |
---|
| 37 | dep['returned'] = "%.0f" % total_returned |
---|
| 38 | |
---|
| 39 | l.append(dep) |
---|
| 40 | fs = context.portal_catalog(portal_type="Faculty") |
---|
| 41 | for fid in [f.getId for f in fs]: |
---|
| 42 | dep = {} |
---|
| 43 | dep['id'] = fid |
---|
| 44 | fquery = Eq('faculty',fid) |
---|
| 45 | squery = Ge('level','200') |
---|
| 46 | fac_res = aq_students(fquery & squery) |
---|
| 47 | fac_ids = [r.id for r in fac_res] |
---|
| 48 | ret = len([s for s in fac_ids if s in ret_ids]) |
---|
| 49 | dep['returned'] = ret |
---|
| 50 | |
---|
| 51 | if ret == 0: |
---|
| 52 | continue |
---|
| 53 | |
---|
| 54 | l.append(dep) |
---|
| 55 | |
---|
| 56 | return l |
---|