## 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.getRetStudentStatistics') logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) if not context.isStaff(): return 'Not allowed' entry_sessions = ('94','95','96','97','98','99','00','01','02','03','04','05') new_states = ('returning', 'school_fee_paid', 'courses_registered', 'courses_validated', ) faculties = context.portal_catalog(portal_type="Faculty") l = [] fac_res = {} dict = {} dict['id'] = 'All Faculties' dict['title'] = 'All Faculties' res = context.students_catalog(entry_session = entry_sessions) dict['total'] = len(res) for state in new_states: res = context.students_catalog(entry_session = entry_sessions, review_state = state) dict[state] = len(res) statepercent = state+'_percent' if dict['total'] > 0: dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) else: dict[statepercent] = 0 l.append(dict) for f in faculties: dict = {} dict['id'] = f.getId dict['title'] = f.Title res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId) dict['total'] = len(res) for state in new_states: res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state) dict[state] = len(res) statepercent = state+'_percent' if dict['total'] > 0: dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) else: dict[statepercent] = 0 l.append(dict) return l