## Script (Python) "getRetStudentStatistics" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: getStudentStatistics.py 1277 2007-01-11 21:11:37Z joachim $ """ return Student Statistics """ import logging logger = logging.getLogger('Skins.getSimpleStudentStatistics') logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) if not context.isStaff(): return catA = ( 'school_fee_paid', 'courses_registered', 'courses_validated', ) catB = ( 'courses_registered', 'courses_validated', ) catC = ( 'student_created', 'returning', 'admitted', 'clearance_pin_entered', 'objection_raised', 'clearance_requested', 'cleared_and_validated', ) current_session = context.getSessionId()[0] full_time = ('ug_ft','',) part_time = ('pce') diploma = ('prence') faculties = context.portal_catalog(portal_type="Faculty") l = [] fac_res = {} dict = {} dict['id'] = 'All Schools' dict['title'] = 'All Schools' res_ft = context.students_catalog(mode = full_time) dict['total_ft'] = len(res_ft) res_pt = context.students_catalog(mode = part_time) dict['total_pt'] = len(res_pt) res_dp = context.students_catalog(mode = diploma) dict['total_dp'] = len(res_dp) res_Aft = context.students_catalog(review_state = catA, mode = full_time, session = current_session) dict['total_Aft'] = len(res_Aft) res_Apt = context.students_catalog(review_state = catA, mode = part_time, session = current_session) dict['total_Apt'] = len(res_Apt) res_Adp = context.students_catalog(review_state = catA, mode = diploma, session = current_session) dict['total_Adp'] = len(res_Adp) res_Bft = context.students_catalog(review_state = catB, mode = full_time, session = current_session) dict['total_Bft'] = len(res_Bft) res_Bpt = context.students_catalog(review_state = catB, mode = part_time, session = current_session) dict['total_Bpt'] = len(res_Bpt) res_Bdp = context.students_catalog(review_state = catB, mode = diploma, session = current_session) dict['total_Bdp'] = len(res_Bpt) res_Cft = context.students_catalog(review_state = catC, mode = full_time, session = current_session) dict['total_Cft'] = len(res_Cft) res_Cpt = context.students_catalog(review_state = catC, mode = part_time, session = current_session) dict['total_Cpt'] = len(res_Cpt) res_Cdp = context.students_catalog(review_state = catC, mode = diploma, session = current_session) dict['total_Cdp'] = len(res_Cdp) res_total = context.students_catalog() dict['total_in_catalog'] = len(res_total) dict['not_categorized'] = dict['total_in_catalog'] - dict['total_ft'] - dict['total_pt'] - dict['total_dp'] l.append(dict) for f in faculties: dict = {} dict['id'] = f.getId dict['title'] = f.Title res_ft = context.students_catalog(faculty = f.getId, mode = full_time) dict['total_ft'] = len(res_ft) res_pt = context.students_catalog(faculty = f.getId, mode = part_time) dict['total_pt'] = len(res_pt) res_dp = context.students_catalog(faculty = f.getId, mode = diploma) dict['total_dp'] = len(res_dp) res_Aft = context.students_catalog(faculty = f.getId, review_state = catA, mode = full_time, session = current_session) dict['total_Aft'] = len(res_Aft) res_Apt = context.students_catalog(faculty = f.getId, review_state = catA, mode = part_time, session = current_session) dict['total_Apt'] = len(res_Apt) res_Adp = context.students_catalog(faculty = f.getId, review_state = catA, mode = diploma, session = current_session) dict['total_Adp'] = len(res_Adp) res_Bft = context.students_catalog(faculty = f.getId, review_state = catB, mode = full_time, session = current_session) dict['total_Bft'] = len(res_Bft) res_Bpt = context.students_catalog(faculty = f.getId, review_state = catB, mode = part_time, session = current_session) dict['total_Bpt'] = len(res_Bpt) res_Bdp = context.students_catalog(faculty = f.getId, review_state = catB, mode = diploma, session = current_session) dict['total_Bdp'] = len(res_Bpt) res_Cft = context.students_catalog(faculty = f.getId, review_state = catC, mode = full_time, session = current_session) dict['total_Cft'] = len(res_Cft) res_Cpt = context.students_catalog(faculty = f.getId, review_state = catC, mode = part_time, session = current_session) dict['total_Cpt'] = len(res_Cpt) res_Cdp = context.students_catalog(faculty = f.getId, review_state = catC, mode = diploma, session = current_session) dict['total_Cdp'] = len(res_Cdp) l.append(dict) return l