source: WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py @ 2166

Last change on this file since 2166 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.7 KB
RevLine 
[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"""
12return Student Statistics
13"""
[1761]14
[1286]15import logging
[1571]16logger = logging.getLogger('Skins.getNewStudentStatistics')
[1286]17
[1571]18logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
[1286]19if not context.isStaff():
[1761]20    return 'Not allowed'
[1286]21
[2068]22entry_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]27new_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
37full_time =       ('ume_ft','de_ft','ug_ft','pg_ft')
38part_time =       (         'de_pt','ug_pt','pg_pt')
39
[1761]40faculties = context.portal_catalog(portal_type="Faculty")
41
42l = []
43
44
[1670]45fac_res = {}
[1761]46
47dict = {}
48dict['id'] = 'All Faculties'
49dict['title'] = 'All Faculties'
[2067]50
[2068]51res_ft = context.students_catalog(entry_session = entry_sessions,  mode = full_time, review_state = new_states)
[2067]52dict['total_ft'] = len(res_ft)
53
[2068]54res_pt = context.students_catalog(entry_session = entry_sessions,  mode = part_time, review_state = new_states)
[2067]55dict['total_pt'] = len(res_pt)
56
[1761]57for 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]78l.append(dict)
79
[2067]80
[1670]81for 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]114return l
[1530]115
[1761]116
Note: See TracBrowser for help on using the repository browser.