source: WAeUP_SRP/trunk/skins/waeup_student/getRetStudentStatistics.py @ 1542

Last change on this file since 1542 was 1536, checked in by Henrik Bettermann, 18 years ago

ticket 98

File size: 1.4 KB
RevLine 
[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"""
12return Student Statistics
13"""
14import logging
15logger = logging.getLogger('Student.Statistics')
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 returning statistics"' % context.portal_membership.getAuthenticatedMember())
24l = []
25if not context.isStaff():
26    return l
27dep = {}
[1530]28sum = 0
[1286]29dep['id'] = "All Faculties"
30
31#from Products.zdb import set_trace;set_trace()
32
33ret_res = context.portal_catalog(review_state ='returning')
34ret_ids = [r.getId for r in ret_res]
[1530]35ret = len(ret_res)
36dep['total'] = ret
[1286]37
38l.append(dep)
39fs = context.portal_catalog(portal_type="Faculty")
40for fid in [f.getId for f in fs]:
41    dep = {}
42    dep['id'] = fid
43    fquery = Eq('faculty',fid)
[1536]44    stud_res = aq_students(fquery)
45    stud_ids = [r.id for r in stud_res]
46    total = float(len(stud_res))
[1530]47
48    if total == 0:
49        continue
50
[1536]51    ret = len([s for s in stud_ids if s in ret_ids])
[1286]52    dep['returned'] = ret
[1530]53    sum += ret
[1286]54
55    if ret == 0:
56        continue
57
58    l.append(dep)
59
[1530]60l[0]['sum'] = sum
61
[1286]62return l
[1530]63
Note: See TracBrowser for help on using the repository browser.