[2243] | 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.getRetStudentStatistics') |
---|
| 17 | |
---|
| 18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
| 19 | if not context.isStaff(): |
---|
| 20 | return 'Not allowed' |
---|
| 21 | |
---|
| 22 | entry_sessions = ('-1','94','95','96','97','98','99','00','01','02','03','04','05','0','1','2','3','4','5') |
---|
| 23 | |
---|
| 24 | ret_states = ('returning', |
---|
| 25 | 'school_fee_paid', |
---|
| 26 | 'courses_registered', |
---|
| 27 | 'courses_validated', |
---|
| 28 | ) |
---|
| 29 | full_time = ('ume_ft','de_ft','ug_ft','pg_ft') |
---|
| 30 | part_time = ( 'de_pt','ug_pt','pg_pt') |
---|
| 31 | |
---|
| 32 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
| 33 | |
---|
| 34 | l = [] |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | fac_res = {} |
---|
| 38 | |
---|
| 39 | dict = {} |
---|
| 40 | dict['id'] = 'All Faculties' |
---|
| 41 | dict['title'] = 'All Faculties' |
---|
| 42 | |
---|
| 43 | res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time, review_state = ret_states) |
---|
| 44 | dict['total_ft'] = len(res_ft) |
---|
| 45 | |
---|
| 46 | res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time, review_state = ret_states) |
---|
| 47 | dict['total_pt'] = len(res_pt) |
---|
| 48 | |
---|
| 49 | for state in ret_states: |
---|
| 50 | # full_time |
---|
| 51 | res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time) |
---|
| 52 | state_ft = state + '_ft' |
---|
| 53 | dict[state_ft] = len(res_ft) |
---|
| 54 | statepercent = state+'_ft_percent' |
---|
| 55 | if dict['total_ft'] > 0: |
---|
| 56 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
| 57 | else: |
---|
| 58 | dict[statepercent] = 0 |
---|
| 59 | |
---|
| 60 | # part_time |
---|
| 61 | res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time) |
---|
| 62 | state_pt = state + '_pt' |
---|
| 63 | dict[state_pt] = len(res_pt) |
---|
| 64 | statepercent = state+'_pt_percent' |
---|
| 65 | if dict['total_pt'] > 0: |
---|
| 66 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
| 67 | else: |
---|
| 68 | dict[statepercent] = 0 |
---|
| 69 | |
---|
| 70 | l.append(dict) |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | for f in faculties: |
---|
| 74 | dict = {} |
---|
| 75 | dict['id'] = f.getId |
---|
| 76 | dict['title'] = f.Title |
---|
| 77 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) |
---|
| 78 | dict['total_ft'] = len(res_ft) |
---|
| 79 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) |
---|
| 80 | dict['total_pt'] = len(res_pt) |
---|
| 81 | for state in ret_states: |
---|
| 82 | # full_time |
---|
| 83 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time) |
---|
| 84 | state_ft = state + '_ft' |
---|
| 85 | dict[state_ft] = len(res_ft) |
---|
| 86 | statepercent = state+'_ft_percent' |
---|
| 87 | if dict['total_ft'] > 0: |
---|
| 88 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
| 89 | else: |
---|
| 90 | dict[statepercent] = 0 |
---|
| 91 | |
---|
| 92 | # part_time |
---|
| 93 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time) |
---|
| 94 | state_pt = state + '_pt' |
---|
| 95 | dict[state_pt] = len(res_pt) |
---|
| 96 | statepercent = state+'_pt_percent' |
---|
| 97 | if dict['total_pt'] > 0: |
---|
| 98 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
| 99 | else: |
---|
| 100 | dict[statepercent] = 0 |
---|
| 101 | |
---|
| 102 | l.append(dict) |
---|
| 103 | |
---|
| 104 | return l |
---|
| 105 | |
---|
| 106 | |
---|