source: WAeUP_SRP/branches/uli/skins/waeup_student/getRetStudentStatistics.py @ 10822

Last change on this file since 10822 was 1593, checked in by uli, 18 years ago

Merged current trunk into uli-branch.

File size: 1.8 KB
Line 
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"""
12return Student Statistics
13"""
14import logging
15logger = logging.getLogger('Skins.getRetStudentStatistics')
16
17try:
18    from Products.AdvancedQuery import Eq, Between, Le,In, Ge
19    aq_portal = context.portal_catalog.evalAdvancedQuery
20    aq_students = context.students_catalog.evalAdvancedQuery
21except:
22    evalAdvancedQuery = None
23logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
24l = []
25if not context.isStaff():
26    return l
27dep = {}
28dep['id'] = "All Faculties"
29
30
31ret_res1 = context.portal_catalog(review_state = 'returning')
32ret_ids1 = [r.getId for r in ret_res1]
33total_ret = len(ret_ids1)
34
35ret_res2 = context.portal_catalog(review_state = ('school_fee_paid','courses_registered','courses_validated',))
36ret_ids2 = [r.getId for r in ret_res2]
37
38retquery = Ge('level','300') | (Eq('level','200') & Eq('entry_mode','UME'))
39ret_res3 = aq_students(retquery)
40ret_ids3 = [r.id for r in ret_res3]
41
42l.append(dep)
43sum_ret = 0
44sum_sfp = 0
45fs = context.portal_catalog(portal_type="Faculty")
46for 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
64l[0]['ret'] = sum_ret
65l[0]['sfp'] = sum_sfp
66l[0]['total_ret'] = total_ret + sum_sfp
67l[0]['total_li'] = sum_ret + sum_sfp
68
69
70return l
71
Note: See TracBrowser for help on using the repository browser.