[2243] | 1 | ## Script (Python) "getNewStudentStatistics" |
---|
| 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.getNewStudentStatistics') |
---|
| 17 | |
---|
| 18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
| 19 | if not context.isStaff(): |
---|
[2431] | 20 | return |
---|
[2243] | 21 | |
---|
[2660] | 22 | entry_sessions = (context.getSessionId()[0]) |
---|
[2243] | 23 | |
---|
[2431] | 24 | # students with entry_session None (-1) are interprteted as new AND returning students if they are |
---|
[2243] | 25 | # in either of the last three states |
---|
| 26 | |
---|
[2705] | 27 | new_states = ('student_created', |
---|
| 28 | 'admitted', |
---|
[2243] | 29 | 'clearance_pin_entered', |
---|
| 30 | 'objection_raised', |
---|
| 31 | 'clearance_requested', |
---|
| 32 | 'cleared_and_validated', |
---|
| 33 | 'school_fee_paid', |
---|
| 34 | 'courses_registered', |
---|
| 35 | 'courses_validated', |
---|
| 36 | ) |
---|
| 37 | |
---|
| 38 | full_time = ('ume_ft','de_ft','ug_ft','pg_ft') |
---|
| 39 | part_time = ( 'de_pt','ug_pt','pg_pt') |
---|
| 40 | |
---|
| 41 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
| 42 | |
---|
| 43 | l = [] |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | fac_res = {} |
---|
| 47 | |
---|
| 48 | dict = {} |
---|
| 49 | dict['id'] = 'All Faculties' |
---|
| 50 | dict['title'] = 'All Faculties' |
---|
| 51 | |
---|
| 52 | res_ft = context.students_catalog(entry_session = entry_sessions, mode = full_time, review_state = new_states) |
---|
| 53 | dict['total_ft'] = len(res_ft) |
---|
| 54 | |
---|
| 55 | res_pt = context.students_catalog(entry_session = entry_sessions, mode = part_time, review_state = new_states) |
---|
| 56 | dict['total_pt'] = len(res_pt) |
---|
| 57 | |
---|
| 58 | for state in new_states: |
---|
| 59 | # full_time |
---|
| 60 | res_ft = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = full_time) |
---|
| 61 | state_ft = state + '_ft' |
---|
| 62 | dict[state_ft] = len(res_ft) |
---|
| 63 | statepercent = state+'_ft_percent' |
---|
| 64 | if dict['total_ft'] > 0: |
---|
| 65 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
| 66 | else: |
---|
| 67 | dict[statepercent] = 0 |
---|
[2431] | 68 | |
---|
[2243] | 69 | # part_time |
---|
| 70 | res_pt = context.students_catalog(entry_session = entry_sessions, review_state = state, mode = part_time) |
---|
| 71 | state_pt = state + '_pt' |
---|
| 72 | dict[state_pt] = len(res_pt) |
---|
| 73 | statepercent = state+'_pt_percent' |
---|
| 74 | if dict['total_pt'] > 0: |
---|
| 75 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
| 76 | else: |
---|
[2431] | 77 | dict[statepercent] = 0 |
---|
| 78 | |
---|
[2243] | 79 | l.append(dict) |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | for f in faculties: |
---|
| 83 | dict = {} |
---|
| 84 | dict['id'] = f.getId |
---|
| 85 | dict['title'] = f.Title |
---|
| 86 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = full_time) |
---|
| 87 | dict['total_ft'] = len(res_ft) |
---|
| 88 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, mode = part_time) |
---|
[2431] | 89 | dict['total_pt'] = len(res_pt) |
---|
[2243] | 90 | for state in new_states: |
---|
| 91 | # full_time |
---|
| 92 | res_ft = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = full_time) |
---|
| 93 | state_ft = state + '_ft' |
---|
| 94 | dict[state_ft] = len(res_ft) |
---|
| 95 | statepercent = state+'_ft_percent' |
---|
| 96 | if dict['total_ft'] > 0: |
---|
| 97 | dict[statepercent] = "%.0f" % round(dict[state_ft]*100.0/dict['total_ft']) |
---|
| 98 | else: |
---|
| 99 | dict[statepercent] = 0 |
---|
[2431] | 100 | |
---|
[2243] | 101 | # part_time |
---|
| 102 | res_pt = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state, mode = part_time) |
---|
| 103 | state_pt = state + '_pt' |
---|
| 104 | dict[state_pt] = len(res_pt) |
---|
| 105 | statepercent = state+'_pt_percent' |
---|
| 106 | if dict['total_pt'] > 0: |
---|
| 107 | dict[statepercent] = "%.0f" % round(dict[state_pt]*100.0/dict['total_pt']) |
---|
| 108 | else: |
---|
[2431] | 109 | dict[statepercent] = 0 |
---|
| 110 | |
---|
[2243] | 111 | l.append(dict) |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | return l |
---|
| 116 | |
---|
| 117 | |
---|