[1762] | 1 | ## Script (Python) "getNewStudentStatistics" |
---|
[1286] | 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 | """ |
---|
[1762] | 14 | |
---|
[1286] | 15 | import logging |
---|
[1551] | 16 | logger = logging.getLogger('Skins.getRetStudentStatistics') |
---|
[1286] | 17 | |
---|
[1571] | 18 | logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) |
---|
[1286] | 19 | if not context.isStaff(): |
---|
[1762] | 20 | return 'Not allowed' |
---|
[1286] | 21 | |
---|
[1762] | 22 | entry_sessions = ('98','99','00','01','02','03','04','05') |
---|
[1286] | 23 | |
---|
[1762] | 24 | new_states = ('returning', |
---|
| 25 | 'school_fee_paid', |
---|
| 26 | 'courses_registered', |
---|
| 27 | 'courses_validated', |
---|
| 28 | ) |
---|
| 29 | faculties = context.portal_catalog(portal_type="Faculty") |
---|
[1286] | 30 | |
---|
[1762] | 31 | l = [] |
---|
[1551] | 32 | |
---|
| 33 | |
---|
[1762] | 34 | fac_res = {} |
---|
[1571] | 35 | |
---|
[1762] | 36 | dict = {} |
---|
| 37 | dict['id'] = 'All Faculties' |
---|
| 38 | dict['title'] = 'All Faculties' |
---|
| 39 | res = context.students_catalog(entry_session = entry_sessions) |
---|
| 40 | dict['total'] = len(res) |
---|
| 41 | for state in new_states: |
---|
| 42 | res = context.students_catalog(entry_session = entry_sessions, review_state = state) |
---|
| 43 | dict[state] = len(res) |
---|
| 44 | statepercent = state+'_percent' |
---|
| 45 | if dict['total'] > 0: |
---|
| 46 | dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) |
---|
| 47 | else: |
---|
| 48 | dict[statepercent] = 0 |
---|
| 49 | #fac_res['all'] = dict |
---|
| 50 | l.append(dict) |
---|
[1530] | 51 | |
---|
[1762] | 52 | for f in faculties: |
---|
| 53 | dict = {} |
---|
| 54 | dict['id'] = f.getId |
---|
| 55 | dict['title'] = f.Title |
---|
| 56 | res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId) |
---|
| 57 | dict['total'] = len(res) |
---|
| 58 | for state in new_states: |
---|
| 59 | res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state) |
---|
| 60 | dict[state] = len(res) |
---|
| 61 | statepercent = state+'_percent' |
---|
| 62 | if dict['total'] > 0: |
---|
| 63 | dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) |
---|
| 64 | else: |
---|
| 65 | dict[statepercent] = 0 |
---|
| 66 | #fac_res[f.getId] = dict |
---|
| 67 | l.append(dict) |
---|
[1286] | 68 | |
---|
| 69 | return l |
---|
[1530] | 70 | |
---|
[1762] | 71 | |
---|