## 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', ) 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