## Script (Python) "getNewStudentStatistics" ##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.getNewStudentStatistics') logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) if not context.isStaff(): return 'Not allowed' entry_sessions = ('06','6') new_states = ('admitted', 'clearance_pin_entered', 'objection_raised', 'clearance_requested', 'cleared_and_validated', 'school_fee_paid', 'courses_registered', 'courses_validated', ) full_time = ('ume_ft','de_ft','ug_ft','pg_ft') part_time = ( 'de_pt','ug_pt','pg_pt') faculties = context.portal_catalog(portal_type="Faculty") l = [] fac_res = {} dict = {} dict['id'] = 'All Faculties' dict['title'] = 'All Faculties' res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time) dict['total_ft'] = len(res_ft) res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time) dict['total_pt'] = len(res_pt) for state in new_states: # full_time res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time) state_ft = state + '_ft' dict[state_ft] = len(res_ft) statepercent = state+'_ft_percent' if dict['total_ft'] > 0: dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) else: dict[statepercent] = 0 # part_time res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time) state_pt = state + '_pt' dict[state_pt] = len(res_pt) statepercent = state+'_pt_percent' if dict['total_pt'] > 0: dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) else: dict[statepercent] = 0 l.append(dict) for f in faculties: dict = {} dict['id'] = f.getId dict['title'] = f.Title res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) dict['total_ft'] = len(res_ft) res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) dict['total_pt'] = len(res_pt) for state in new_states: # full_time res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time) state_ft = state + '_ft' dict[state_ft] = len(res_ft) statepercent = state+'_ft_percent' if dict['total_ft'] > 0: dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) else: dict[statepercent] = 0 # part_time res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time) state_pt = state + '_pt' dict[state_pt] = len(res_pt) statepercent = state+'_pt_percent' if dict['total_pt'] > 0: dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) else: dict[statepercent] = 0 l.append(dict) return l