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('Skins.getRetStudentStatistics') |
---|
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 | dep['id'] = "All Faculties" |
---|
29 | |
---|
30 | |
---|
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) |
---|
34 | |
---|
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 | |
---|
42 | l.append(dep) |
---|
43 | sum_ret = 0 |
---|
44 | sum_sfp = 0 |
---|
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) |
---|
50 | stud_res = aq_students(fquery) |
---|
51 | stud_ids = [r.id for r in stud_res] |
---|
52 | total = float(len(stud_res)) |
---|
53 | if total == 0: |
---|
54 | continue |
---|
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 |
---|
61 | |
---|
62 | l.append(dep) |
---|
63 | |
---|
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 |
---|
68 | |
---|
69 | |
---|
70 | return l |
---|
71 | |
---|