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

Last change on this file since 1925 was 1788, checked in by Henrik Bettermann, 18 years ago
  • missing icons added
  • getStatistics has to take into consideration that entry_session is stored in two different ways
File size: 1.9 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
[1788]22entry_sessions = ('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                   )
29faculties = context.portal_catalog(portal_type="Faculty")
[1286]30
[1762]31l = []
[1551]32
33
[1762]34fac_res = {}
[1571]35
[1762]36dict = {}
37dict['id'] = 'All Faculties'
38dict['title'] = 'All Faculties'
39res = context.students_catalog(entry_session = entry_sessions)
40dict['total'] = len(res)
[1781]41for state in ret_states:
[1762]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
49l.append(dict)
[1530]50
[1762]51for f in faculties:
52    dict = {}
53    dict['id'] = f.getId
54    dict['title'] = f.Title
55    res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId)
56    dict['total'] = len(res)
[1781]57    for state in ret_states:
[1762]58        res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state)
59        dict[state] = len(res)
60        statepercent = state+'_percent'
61        if dict['total'] > 0:
62            dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
63        else:
64            dict[statepercent] = 0
65    l.append(dict)
[1286]66
67return l
[1530]68
[1762]69
Note: See TracBrowser for help on using the repository browser.