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

Last change on this file since 2006 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: 2.0 KB
Line 
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"""
14
15import logging
16logger = logging.getLogger('Skins.getNewStudentStatistics')
17
18logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
19if not context.isStaff():
20    return 'Not allowed'
21
22entry_sessions = ('06','6')
23
24new_states =      ('admitted',
25                   'clearance_pin_entered',
26                   'objection_raised',
27                   'clearance_requested',
28                   'cleared_and_validated',
29                   'school_fee_paid',
30                   'courses_registered',
31                   'courses_validated',
32                   )
33faculties = context.portal_catalog(portal_type="Faculty")
34
35l = []
36
37
38fac_res = {}
39
40dict = {}
41dict['id'] = 'All Faculties'
42dict['title'] = 'All Faculties'
43res = context.students_catalog(entry_session = entry_sessions)
44dict['total'] = len(res)
45for state in new_states:
46    res = context.students_catalog(entry_session = entry_sessions, review_state = state)
47    dict[state] = len(res)
48    statepercent = state+'_percent'
49    if dict['total'] > 0:
50        dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
51    else:
52        dict[statepercent] = 0
53l.append(dict)
54
55for f in faculties:
56    dict = {}
57    dict['id'] = f.getId
58    dict['title'] = f.Title
59    res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId)
60    dict['total'] = len(res)
61    for state in new_states:
62        res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state)
63        dict[state] = len(res)
64        statepercent = state+'_percent'
65        if dict['total'] > 0:
66            dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
67        else:
68            dict[statepercent] = 0
69    l.append(dict)
70
71return l
72
73
Note: See TracBrowser for help on using the repository browser.