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