source: WAeUP_SRP/trunk/skins/waeup_student/getStudentStatistics.py @ 1196

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

minor changes

  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1## Script (Python) "getStudentStatistics"
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 1196 2007-01-04 10:30:39Z henrik $
11"""
12return Student Statistics
13"""
14import logging
15logger = logging.getLogger('Student.Statistic')
16
17try:
18    from Products.AdvancedQuery import Eq, Between, Le,In
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"
29total = len(context.students_catalog())
30dep['students'] = total
31cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
32cpe_ids = [r.getId for r in cpe_res]
33cpe = len(cpe_res)
34dep['clearance_pin_entered'] = cpe
35dep['clearance_pin_entered_percent'] = (cpe*100/total)
36cr_res = context.portal_catalog(review_state='clearance_requested')
37cr_ids = [r.getId for r in cr_res]
38cr = len(cr_res)
39dep['clearance_requested'] = cr
40dep['clearance_requested_percent'] = (cr*100/total)
41cav_res = context.portal_catalog(review_state ='cleared_and_validated')
42cav_ids = [r.getId for r in cav_res]
43cav = len(cav_res)
44dep['cleared_and_validated'] = cav
45dep['cleared_and_validated_percent'] = (cav*100/total)
46or_res = context.portal_catalog(review_state='objection_raised')
47or_ids = [r.getId for r in or_res]
48ora = len(or_res)
49dep['objection_raised'] = ora
50dep['objection_raised_percent'] = (ora*100/total)
51l.append(dep)
52fs = context.portal_catalog(portal_type="Faculty")
53#from Products.zdb import set_trace;set_trace()
54for fid in [f.getId for f in fs]:
55    dep = {}
56    dep['id'] = fid
57    fquery = Eq('portal_type','Faculty')
58    fac_res = context.students_catalog(faculty=fid)
59    fac_ids = [r.id for r in fac_res]
60    total = len(fac_res)
61    if total == 0:
62        continue
63    dep['students'] = total
64    cpe = len([s for s in fac_ids if s in cpe_ids])
65    dep['clearance_pin_entered'] = cpe
66    dep['clearance_pin_entered_percent'] = 0
67    if total:
68        dep['clearance_pin_entered_percent'] = (cpe*100/total)
69    cr = len([s for s in fac_ids if s in cr_ids])
70    dep['clearance_requested'] = cr
71    dep['clearance_requested_percent'] = 0
72    if total:
73        dep['clearance_requested_percent'] = (cr*100/total)
74    cav = len([s for s in fac_ids if s in cav_ids])
75    dep['cleared_and_validated'] = cav
76    dep['cleared_and_validated_percent'] = 0
77    if total:
78        dep['cleared_and_validated_percent'] = (cav*100/total)
79    ora = len([s for s in fac_ids if s in or_ids])
80    dep['objection_raised'] = ora
81    dep['objection_raised_percent'] = 0
82    if total:
83        dep['objection_raised_percent'] = (ora*100/total)
84    l.append(dep)
85return l
Note: See TracBrowser for help on using the repository browser.