[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 |
---|
[1551] | 15 | logger = logging.getLogger('Skins.getRetStudentStatistics') |
---|
[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 |
---|
[1571] | 23 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
[1286] | 24 | l = [] |
---|
| 25 | if not context.isStaff(): |
---|
| 26 | return l |
---|
| 27 | dep = {} |
---|
| 28 | dep['id'] = "All Faculties" |
---|
| 29 | |
---|
| 30 | |
---|
[1551] | 31 | ret_res1 = context.portal_catalog(review_state = 'returning') |
---|
| 32 | ret_ids1 = [r.getId for r in ret_res1] |
---|
| 33 | total_ret = len(ret_ids1) |
---|
[1286] | 34 | |
---|
[1551] | 35 | ret_res2 = context.portal_catalog(review_state = ('school_fee_paid','courses_registered','courses_validated',)) |
---|
| 36 | ret_ids2 = [r.getId for r in ret_res2] |
---|
| 37 | |
---|
| 38 | retquery = Ge('level','300') | (Eq('level','200') & Eq('entry_mode','UME')) |
---|
| 39 | ret_res3 = aq_students(retquery) |
---|
| 40 | ret_ids3 = [r.id for r in ret_res3] |
---|
| 41 | |
---|
[1286] | 42 | l.append(dep) |
---|
[1551] | 43 | sum_ret = 0 |
---|
| 44 | sum_sfp = 0 |
---|
[1286] | 45 | fs = context.portal_catalog(portal_type="Faculty") |
---|
| 46 | for fid in [f.getId for f in fs]: |
---|
| 47 | dep = {} |
---|
| 48 | dep['id'] = fid |
---|
| 49 | fquery = Eq('faculty',fid) |
---|
[1536] | 50 | stud_res = aq_students(fquery) |
---|
| 51 | stud_ids = [r.id for r in stud_res] |
---|
| 52 | total = float(len(stud_res)) |
---|
[1530] | 53 | if total == 0: |
---|
| 54 | continue |
---|
[1551] | 55 | sfp = len([s for s in stud_ids if s in ret_ids2 and s in ret_ids3]) |
---|
| 56 | dep['sfp'] = sfp |
---|
| 57 | ret = len([s for s in stud_ids if s in ret_ids1]) |
---|
| 58 | dep['ret'] = ret |
---|
| 59 | sum_ret += ret |
---|
| 60 | sum_sfp += sfp |
---|
[1571] | 61 | |
---|
[1551] | 62 | l.append(dep) |
---|
[1530] | 63 | |
---|
[1551] | 64 | l[0]['ret'] = sum_ret |
---|
| 65 | l[0]['sfp'] = sum_sfp |
---|
| 66 | l[0]['total_ret'] = total_ret + sum_sfp |
---|
| 67 | l[0]['total_li'] = sum_ret + sum_sfp |
---|
[1286] | 68 | |
---|
| 69 | |
---|
| 70 | return l |
---|
[1530] | 71 | |
---|