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

Last change on this file since 1253 was 1251, checked in by joachim, 18 years ago

total now counts only students created before 20.12.06 (in custom)

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