source: WAeUP_SRP/trunk/skins/waeup_student/getRetStudentStatistics.py @ 2124

Last change on this file since 2124 was 2068, checked in by Henrik Bettermann, 17 years ago

see comment 07/27/07 13:57:14 in ticket #315

basic student statistics included

File size: 3.4 KB
RevLine 
[1763]1## Script (Python) "getRetStudentStatistics"
[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"""
12return Student Statistics
13"""
[1762]14
[1286]15import logging
[1551]16logger = logging.getLogger('Skins.getRetStudentStatistics')
[1286]17
[1571]18logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
[1286]19if not context.isStaff():
[1762]20    return 'Not allowed'
[1286]21
[2068]22entry_sessions = ('-1','94','95','96','97','98','99','00','01','02','03','04','05','0','1','2','3','4','5')
[1286]23
[1781]24ret_states =      ('returning',
[1762]25                   'school_fee_paid',
26                   'courses_registered',
27                   'courses_validated',
28                   )
[2067]29full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
[2068]30part_time =       (         'de_pt','ug_pt','pg_pt')
31
[1762]32faculties = context.portal_catalog(portal_type="Faculty")
[1286]33
[1762]34l = []
[1551]35
36
[1762]37fac_res = {}
[1571]38
[1762]39dict = {}
40dict['id'] = 'All Faculties'
41dict['title'] = 'All Faculties'
[2067]42
[2068]43res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = ret_states)
[2067]44dict['total_ft'] = len(res_ft)
45
[2068]46res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = ret_states)
[2067]47dict['total_pt'] = len(res_pt)
48
[1781]49for state in ret_states:
[2067]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'])
[1762]57    else:
58        dict[statepercent] = 0
[2068]59
[2067]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:
[2068]68        dict[statepercent] = 0
69
[1762]70l.append(dict)
[1530]71
[2067]72
[1762]73for f in faculties:
74    dict = {}
75    dict['id'] = f.getId
76    dict['title'] = f.Title
[2067]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)
[2068]80    dict['total_pt'] = len(res_pt)
[1781]81    for state in ret_states:
[2067]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'])
[1762]89        else:
90            dict[statepercent] = 0
[2068]91
[2067]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:
[2068]100            dict[statepercent] = 0
101
[1762]102    l.append(dict)
[1286]103
104return l
[1530]105
[1762]106
Note: See TracBrowser for help on using the repository browser.