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

Last change on this file since 1988 was 1788, checked in by Henrik Bettermann, 17 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
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
[1788]22entry_sessions = ('06','6')
[1286]23
[1761]24new_states =      ('admitted',
[1670]25                   'clearance_pin_entered',
[1761]26                   'objection_raised',
[1670]27                   'clearance_requested',
28                   'cleared_and_validated',
[1761]29                   'school_fee_paid',
30                   'courses_registered',
31                   'courses_validated',
[1670]32                   )
[1761]33faculties = context.portal_catalog(portal_type="Faculty")
34
35l = []
36
37
[1670]38fac_res = {}
[1761]39
40dict = {}
41dict['id'] = 'All Faculties'
42dict['title'] = 'All Faculties'
[1762]43res = context.students_catalog(entry_session = entry_sessions)
[1761]44dict['total'] = len(res)
45for state in new_states:
[1762]46    res = context.students_catalog(entry_session = entry_sessions, review_state = state)
[1761]47    dict[state] = len(res)
[1762]48    statepercent = state+'_percent'
[1761]49    if dict['total'] > 0:
50        dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total'])
51    else:
[1762]52        dict[statepercent] = 0
[1761]53l.append(dict)
54
[1670]55for f in faculties:
56    dict = {}
57    dict['id'] = f.getId
58    dict['title'] = f.Title
[1762]59    res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId)
[1761]60    dict['total'] = len(res)
61    for state in new_states:
[1762]62        res = context.students_catalog(entry_session = entry_sessions, faculty = f.getId, review_state = state)
[1761]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'])
[1671]67        else:
[1762]68            dict[statepercent] = 0
[1761]69    l.append(dict)
[1286]70
71return l
[1530]72
[1761]73
Note: See TracBrowser for help on using the repository browser.