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=session_id=None
|
---|
8 | ##title=
|
---|
9 | ##
|
---|
10 | # $Id: getPaymentStatistics.py 5579 2010-11-08 08:46:31Z henrik $
|
---|
11 | """
|
---|
12 | return Payment Statistics
|
---|
13 | """
|
---|
14 |
|
---|
15 | from Products.AdvancedQuery import Eq, Between, Le,In
|
---|
16 |
|
---|
17 | import logging
|
---|
18 | logger = logging.getLogger('Skins.getPaymentStatistics')
|
---|
19 |
|
---|
20 | import DateTime,csv
|
---|
21 |
|
---|
22 | member = context.portal_membership.getAuthenticatedMember()
|
---|
23 | logger.info('%s invoked statistics' % member)
|
---|
24 | if not context.isStaff():
|
---|
25 | return
|
---|
26 |
|
---|
27 | IPTP = ('ACC','BFN','BUS','HIS','ECO','PAD','PGD','SOC')
|
---|
28 |
|
---|
29 | #INE = ('ATE','CEM','EDU','GST','SSE','STE ')
|
---|
30 |
|
---|
31 | catA = ( 'school_fee_paid',
|
---|
32 | 'courses_registered',
|
---|
33 | 'courses_validated',
|
---|
34 | )
|
---|
35 |
|
---|
36 | if not session_id:
|
---|
37 | session_id = context.getSessionId()[0]
|
---|
38 |
|
---|
39 | L1 = ('100','110','120')
|
---|
40 | L2 = ('200','210','220')
|
---|
41 | L3 = ('300','310','320')
|
---|
42 | L4 = ('400','410','420')
|
---|
43 | L5 = ('500','510','520')
|
---|
44 | L6 = ('600','610','620')
|
---|
45 | L7 = ('700','710','720')
|
---|
46 | L8 = ('800','810','820')
|
---|
47 | d = {}
|
---|
48 |
|
---|
49 | # Diploma and Direct entry students
|
---|
50 |
|
---|
51 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','dp_pt')
|
---|
52 | d['dp_pt'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
53 |
|
---|
54 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','de_pt')
|
---|
55 | d['de_pt'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
56 |
|
---|
57 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','de_sw')
|
---|
58 | d['de_sw'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
59 |
|
---|
60 | # IPTP students
|
---|
61 |
|
---|
62 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L1)
|
---|
63 | d['ug_pt_iptp_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
64 |
|
---|
65 |
|
---|
66 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L2)
|
---|
67 | d['ug_pt_iptp_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
68 |
|
---|
69 |
|
---|
70 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L3)
|
---|
71 | d['ug_pt_iptp_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
72 |
|
---|
73 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L4)
|
---|
74 | d['ug_pt_iptp_400'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
75 |
|
---|
76 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_pt') & In('department',IPTP) & In('level',L5)
|
---|
77 | d['ug_pt_iptp_500'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
78 |
|
---|
79 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L6)
|
---|
80 | d['pg_pt_iptp_600'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
81 |
|
---|
82 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L7)
|
---|
83 | d['pg_pt_iptp_700'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
84 |
|
---|
85 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_pt') & In('department',IPTP) & In('level',L8)
|
---|
86 | d['pg_pt_iptp_800'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
87 |
|
---|
88 | #INE sandwich
|
---|
89 |
|
---|
90 |
|
---|
91 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L1)
|
---|
92 | d['ug_sw_ine_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
93 |
|
---|
94 |
|
---|
95 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L2)
|
---|
96 | d['ug_sw_ine_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
97 |
|
---|
98 |
|
---|
99 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L3)
|
---|
100 | d['ug_sw_ine_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
101 |
|
---|
102 |
|
---|
103 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L4)
|
---|
104 | d['ug_sw_ine_400'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
105 |
|
---|
106 |
|
---|
107 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',IPTP) & In('level',L5)
|
---|
108 | d['ug_sw_ine_500'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
109 |
|
---|
110 |
|
---|
111 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L6)
|
---|
112 | d['pg_sw_ine_600'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
113 |
|
---|
114 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L7)
|
---|
115 | d['pg_sw_ine_700'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
116 |
|
---|
117 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pg_sw') & ~In('department',IPTP) & In('level',L8)
|
---|
118 | d['pg_sw_ine_800'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
119 |
|
---|
120 | l = []
|
---|
121 | l += d,
|
---|
122 |
|
---|
123 | csv_name = context.waeup_tool.dumpListToCSV(l,'payments_statistics')
|
---|
124 | logger.info('%s dumped payments statistics to %s' % (member,csv_name))
|
---|
125 |
|
---|
126 | return d
|
---|