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

Last change on this file since 1225 was 1213, checked in by joachim, 18 years ago

fix svn conflict

  • 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 1213 2007-01-06 14:46:44Z joachim $
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
23#from Products.zdb import set_trace;set_trace()
24logger.info('"%s","invoked Statistic"' % context.portal_membership.getAuthenticatedMember())
25l = []
26if not context.isStaff():
27    return l
28dep = {}
29dep['id'] = "All"
30total = len(context.students_catalog())
31dep['students'] = total
32cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
33cpe_ids = [r.getId for r in cpe_res]
34cpe = len(cpe_res)
35dep['clearance_pin_entered'] = cpe
36dep['clearance_pin_entered_percent'] = (cpe*100/total)
37cr_res = context.portal_catalog(review_state='clearance_requested')
38cr_ids = [r.getId for r in cr_res]
39cr = len(cr_res)
40dep['clearance_requested'] = cr
41dep['clearance_requested_percent'] = (cr*100/total)
42cav_res = context.portal_catalog(review_state ='cleared_and_validated')
43cav_ids = [r.getId for r in cav_res]
44cav = len(cav_res)
45dep['cleared_and_validated'] = cav
46dep['cleared_and_validated_percent'] = (cav*100/total)
47or_res = context.portal_catalog(review_state='objection_raised')
48or_ids = [r.getId for r in or_res]
49ora = len(or_res)
50dep['objection_raised'] = ora
51dep['objection_raised_percent'] = (ora*100/total)
52l.append(dep)
53fs = context.portal_catalog(portal_type="Faculty")
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.