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

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

new logging format Part 4 (rest)

File size: 1.8 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
[1551]15logger = logging.getLogger('Skins.getRetStudentStatistics')
[1286]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
[1571]23logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
[1286]24l = []
25if not context.isStaff():
26    return l
27dep = {}
28dep['id'] = "All Faculties"
29
30
[1551]31ret_res1 = context.portal_catalog(review_state = 'returning')
32ret_ids1 = [r.getId for r in ret_res1]
33total_ret = len(ret_ids1)
[1286]34
[1551]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
[1286]42l.append(dep)
[1551]43sum_ret = 0
44sum_sfp = 0
[1286]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)
[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]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
[1286]68
69
70return l
[1530]71
Note: See TracBrowser for help on using the repository browser.