[5560] | 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 5560 2010-10-06 08:05:01Z 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 | ARTS = ('CRS','ISS','HIS','MUS','ECO','GEO','POL','SOS','CCA','ECU','THA','GED','GSE','PES','SPC','ENG ','FRE','ARB','HAU','IGB','YOR')
|
---|
| 28 |
|
---|
| 29 | #SCS = ('BIO','CHE','HED','MAT','PED','PHY ','CSC','ISC','PHE','AGE','BED','HEC','TED','FAA')
|
---|
| 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 |
|
---|
| 46 | d = {}
|
---|
| 47 |
|
---|
| 48 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','pd_ft')
|
---|
| 49 | d['pd_ft'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 50 |
|
---|
| 51 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','prence') & In('department',ARTS)
|
---|
| 52 | d['prence_arts'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 53 |
|
---|
| 54 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','prence') & ~In('department',ARTS)
|
---|
| 55 | d['prence_sci'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 56 |
|
---|
| 57 | # regular students
|
---|
| 58 |
|
---|
| 59 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L1)
|
---|
| 60 | d['ug_ft_arts_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 61 |
|
---|
| 62 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L1)
|
---|
| 63 | d['ug_ft_sci_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 64 |
|
---|
| 65 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L2)
|
---|
| 66 | d['ug_ft_arts_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 67 |
|
---|
| 68 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L2)
|
---|
| 69 | d['ug_ft_sci_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 70 |
|
---|
| 71 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L3)
|
---|
| 72 | d['ug_ft_arts_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 73 |
|
---|
| 74 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L3)
|
---|
| 75 | d['ug_ft_sci_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 76 |
|
---|
| 77 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & In('department',ARTS) & In('level',L4)
|
---|
| 78 | d['ug_ft_arts_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 79 |
|
---|
| 80 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_ft') & ~In('department',ARTS) & In('level',L4)
|
---|
| 81 | d['ug_ft_sci_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 82 |
|
---|
| 83 | # sandwich
|
---|
| 84 |
|
---|
| 85 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L1)
|
---|
| 86 | d['ug_sw_arts_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 87 |
|
---|
| 88 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L1)
|
---|
| 89 | d['ug_sw_sci_100'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 90 |
|
---|
| 91 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L2)
|
---|
| 92 | d['ug_sw_arts_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 93 |
|
---|
| 94 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L2)
|
---|
| 95 | d['ug_sw_sci_200'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 96 |
|
---|
| 97 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L3)
|
---|
| 98 | d['ug_sw_arts_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 99 |
|
---|
| 100 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L3)
|
---|
| 101 | d['ug_sw_sci_300'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 102 |
|
---|
| 103 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L4)
|
---|
| 104 | d['ug_sw_arts_400'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 105 |
|
---|
| 106 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L4)
|
---|
| 107 | d['ug_sw_sci_400'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 108 |
|
---|
| 109 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L5)
|
---|
| 110 | d['ug_sw_arts_500'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 111 |
|
---|
| 112 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L5)
|
---|
| 113 | d['ug_sw_sci_500'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 114 |
|
---|
| 115 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & In('department',ARTS) & In('level',L6)
|
---|
| 116 | d['ug_sw_arts_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 117 |
|
---|
| 118 | query = Eq('session',session_id) & In('review_state',catA) & Eq('mode','ug_sw') & ~In('department',ARTS) & In('level',L6)
|
---|
| 119 | d['ug_sw_sci_rep'] = len(context.students_catalog.evalAdvancedQuery(query))
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | l = []
|
---|
| 123 | l += d,
|
---|
| 124 |
|
---|
| 125 | csv_name = context.waeup_tool.dumpListToCSV(l,'payments_statistics')
|
---|
| 126 | logger.info('%s dumped payments statistics to %s' % (member,csv_name))
|
---|
| 127 |
|
---|
| 128 | return d
|
---|