source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics_old.py @ 14312

Last change on this file since 14312 was 1673, checked in by joachim, 18 years ago

merge up to 1672

  • Property svn:keywords set to Id
File size: 3.9 KB
RevLine 
[1670]1## Script (Python) "getNewStudentStatistics"
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: getNewStudentStatistics_old.py 1673 2007-04-09 16:01:51Z joachim $
11"""
12return Student Statistics
13"""
14import logging
15logger = logging.getLogger('Skins.getNewStudentStatistics')
16
17try:
18    from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp
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 = {}
28
29dep['id'] = "All Faculties"
30
31freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE'))
32total_new = aq_students(freshquery)
33total_new = float(len(total_new))
34##newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*')
35##total_new = aq_portal(newquery)
36##total_new = float(len(total_new))
37dep['new'] = "%.0f" % total_new
38
39
40#from Products.zdb import set_trace;set_trace()
41
42adm_res = context.portal_catalog(review_state ='admitted')
43adm_ids = [r.getId for r in adm_res]
44adm = len(adm_res)
45dep['admitted'] = adm
46dep['admitted_percent'] =  "%.0f" % round(adm*100/total_new)
47
48cpe_res = context.portal_catalog(review_state ='clearance_pin_entered')
49cpe_ids = [r.getId for r in cpe_res]
50cpe = len(cpe_res)
51dep['clearance_pin_entered'] = cpe
52dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new)
53
54cr_res = context.portal_catalog(review_state='clearance_requested')
55cr_ids = [r.getId for r in cr_res]
56cr = len(cr_res)
57dep['clearance_requested'] = cr
58dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new)
59
60cav_res = context.portal_catalog(review_state ='cleared_and_validated')
61cav_ids = [r.getId for r in cav_res]
62cav = len(cav_res)
63dep['cleared_and_validated'] = cav
64dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new)
65
66or_res = context.portal_catalog(review_state='objection_raised')
67or_ids = [r.getId for r in or_res]
68ora = len(or_res)
69dep['objection_raised'] = ora
70dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new)
71
72total_sfp = total_new - (cav + cr + cpe + adm + ora)
73dep['rest'] = int(total_sfp)
74dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new)
75
76
77l.append(dep)
78fs = context.portal_catalog(portal_type="Faculty")
79for fid in [f.getId for f in fs]:
80    dep = {}
81    dep['id'] = fid
82    fquery = Eq('faculty',fid)
83    fac_res = aq_students(fquery & freshquery)
84    fac_ids = [r.id for r in fac_res]
85    total = float(len(fac_res))
86
87    if total == 0:
88        continue
89
90    dep['new'] = "%.0f" % total
91
92    adm = len([s for s in fac_ids if s in adm_ids])
93    dep['admitted'] = adm
94    dep['admitted_percent'] = 0
95    if total:
96        dep['admitted_percent'] = "%.0f" % round(adm*100/total)
97
98    cpe = len([s for s in fac_ids if s in cpe_ids])
99    dep['clearance_pin_entered'] = cpe
100    dep['clearance_pin_entered_percent'] = 0
101    if total:
102        dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total)
103    cr = len([s for s in fac_ids if s in cr_ids])
104    dep['clearance_requested'] = cr
105    dep['clearance_requested_percent'] = 0
106    if total:
107        dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total)
108    cav = len([s for s in fac_ids if s in cav_ids])
109    dep['cleared_and_validated'] = cav
110    dep['cleared_and_validated_percent'] = 0
111    if total:
112        dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total)
113
114    ora = len([s for s in fac_ids if s in or_ids])
115    dep['objection_raised'] = ora
116    dep['objection_raised_percent'] = 0
117    if total:
118        dep['objection_raised_percent'] = "%.0f" % round(ora*100/total)
119
120    rest = int(total - (cav + cr + cpe + adm + ora))
121    dep['rest'] = rest
122    dep['rest_percent'] = "%.0f" % round(rest*100/total)
123
124    l.append(dep)
125
126return l
127
Note: See TracBrowser for help on using the repository browser.