[3690] | 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= |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: getStudentStatistics.py 1277 2007-01-11 21:11:37Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Student Statistics |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | import logging |
---|
| 16 | logger = logging.getLogger('Skins.getSimpleStudentStatistics') |
---|
| 17 | |
---|
| 18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
| 19 | if not context.isStaff(): |
---|
| 20 | return |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | catA = ( 'school_fee_paid', |
---|
| 24 | 'courses_registered', |
---|
| 25 | 'courses_validated', |
---|
| 26 | ) |
---|
| 27 | |
---|
| 28 | catB = ( 'courses_registered', |
---|
| 29 | 'courses_validated', |
---|
| 30 | ) |
---|
| 31 | |
---|
| 32 | catC = ( 'student_created', |
---|
| 33 | 'returning', |
---|
| 34 | 'admitted', |
---|
| 35 | 'clearance_pin_entered', |
---|
| 36 | 'objection_raised', |
---|
| 37 | 'clearance_requested', |
---|
| 38 | 'cleared_and_validated', |
---|
| 39 | ) |
---|
| 40 | |
---|
| 41 | current_session = context.getSessionId()[0] |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | returning = ('110','120','200','210','220','300','310','320','400','410','420','500','510', '520','500','510','520','610','620','700','710','720','800','810','820',) |
---|
| 45 | new = ('100','600') |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
| 49 | |
---|
| 50 | l = [] |
---|
| 51 | |
---|
| 52 | fac_res = {} |
---|
| 53 | |
---|
| 54 | dict = {} |
---|
| 55 | dict['id'] = 'All Faculties' |
---|
| 56 | dict['title'] = 'All Faculties' |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | res_ft = context.students_catalog(level = returning) |
---|
| 60 | dict['total_ft'] = len(res_ft) |
---|
| 61 | |
---|
| 62 | res_pt = context.students_catalog(level = new) |
---|
| 63 | dict['total_pt'] = len(res_pt) |
---|
| 64 | |
---|
| 65 | res_Aft = context.students_catalog(review_state = catA, level = returning, session = current_session) |
---|
| 66 | dict['total_Aft'] = len(res_Aft) |
---|
| 67 | |
---|
| 68 | res_Apt = context.students_catalog(review_state = catA, level = new, session = current_session) |
---|
| 69 | dict['total_Apt'] = len(res_Apt) |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | res_Bft = context.students_catalog(review_state = catB, level = returning, session = current_session) |
---|
| 74 | dict['total_Bft'] = len(res_Bft) |
---|
| 75 | |
---|
| 76 | res_Bpt = context.students_catalog(review_state = catB, level = new, session = current_session) |
---|
| 77 | dict['total_Bpt'] = len(res_Bpt) |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | res_Cft = context.students_catalog(review_state = catC, level = returning, session = current_session) |
---|
| 82 | dict['total_Cft'] = len(res_Cft) |
---|
| 83 | |
---|
| 84 | res_Cpt = context.students_catalog(review_state = catC, level = new, session = current_session) |
---|
| 85 | dict['total_Cpt'] = len(res_Cpt) |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | res_total = context.students_catalog() |
---|
| 91 | dict['total_in_catalog'] = len(res_total) |
---|
| 92 | dict['not_categorized'] = dict['total_in_catalog'] - dict['total_ft'] - dict['total_pt'] |
---|
| 93 | |
---|
| 94 | l.append(dict) |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | for f in faculties: |
---|
| 98 | dict = {} |
---|
| 99 | dict['id'] = f.getId |
---|
| 100 | dict['title'] = f.Title |
---|
| 101 | |
---|
| 102 | res_ft = context.students_catalog(faculty = f.getId, level = returning) |
---|
| 103 | dict['total_ft'] = len(res_ft) |
---|
| 104 | |
---|
| 105 | res_pt = context.students_catalog(faculty = f.getId, level = new) |
---|
| 106 | dict['total_pt'] = len(res_pt) |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | res_Aft = context.students_catalog(faculty = f.getId, review_state = catA, level = returning, session = current_session) |
---|
| 110 | dict['total_Aft'] = len(res_Aft) |
---|
| 111 | |
---|
| 112 | res_Apt = context.students_catalog(faculty = f.getId, review_state = catA, level = new, session = current_session) |
---|
| 113 | dict['total_Apt'] = len(res_Apt) |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | res_Bft = context.students_catalog(faculty = f.getId, review_state = catB, level = returning, session = current_session) |
---|
| 118 | dict['total_Bft'] = len(res_Bft) |
---|
| 119 | |
---|
| 120 | res_Bpt = context.students_catalog(faculty = f.getId, review_state = catB, level = new, session = current_session) |
---|
| 121 | dict['total_Bpt'] = len(res_Bpt) |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | res_Cft = context.students_catalog(faculty = f.getId, review_state = catC, level = returning, session = current_session) |
---|
| 126 | dict['total_Cft'] = len(res_Cft) |
---|
| 127 | |
---|
| 128 | res_Cpt = context.students_catalog(faculty = f.getId, review_state = catC, level = new, session = current_session) |
---|
| 129 | dict['total_Cpt'] = len(res_Cpt) |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | l.append(dict) |
---|
| 135 | |
---|
| 136 | return l |
---|
| 137 | |
---|