Ignore:
Timestamp:
3 Sep 2015, 15:12:03 (9 years ago)
Author:
Henrik Bettermann
Message:
 
Location:
main/waeup.kofa/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r13223 r13236  
    441.3.2.dev0 (unreleased)
    55=======================
     6
     7* Fix department breakdown of student statistics.
    68
    79* Enable purging of applicants containers.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py

    r12913 r13236  
    4040    Returns a table ordered by code (faculty or department, one per row) and
    4141    registration state (cols). The result is a 3-tuple representing
    42     ((<CODES>), (<STATES>), (<NUM_OF_STUDENTS>)). The
     42    ((<PATHS>), (<STATES>), (<NUM_OF_STUDENTS>)). The
    4343    (<NUM_OF_STUDENTS>) is an n-tuple with each entry containing the
    4444    number of students found in that faculty/department and with the respective
     
    5858    states = states + (u'Total',)
    5959    if breakdown == 'faccode':
    60         codes = tuple(sorted([x for x in site['faculties'].keys()],
     60        paths = tuple(sorted([x for x in site['faculties'].keys()],
    6161                                 key=lambda x: x.lower()))
    62         paths = codes
    6362    elif breakdown == 'depcode':
    6463        faculties = site['faculties']
    65         depcodes = []
    6664        deppaths = []
    6765        for fac in faculties.values():
    6866            for dep in fac.values():
    69                 depcodes.append(dep.code)
    7067                deppaths.append('%s/%s' % (fac.code, dep.code))
    71         codes = tuple(sorted([x for x in depcodes],
    72                                  key=lambda x: x.lower()))
    7368        paths = tuple(sorted([x for x in deppaths],
    7469                                 key=lambda x: x.lower()))
     
    7974    cat = queryUtility(ICatalog, name="students_catalog")
    8075    result = cat.searchResults(current_session=(session, session))
    81     table = [[0 for x in xrange(len(states))] for y in xrange(len(codes)+1)]
     76    table = [[0 for x in xrange(len(states))] for y in xrange(len(paths)+1)]
    8277    mode_groups = getUtility(IKofaUtils).MODE_GROUPS
    8378    for stud in result:
     
    8681        if level != 0 and stud.current_level != level:
    8782            continue
    88         if getattr(stud, breakdown) not in codes:
    89             # studs can have a faccode ``None``
     83        if getattr(stud, breakdown) is None:
    9084            continue
    91         row = codes.index(getattr(stud, breakdown))
     85        if breakdown == 'faccode':
     86            row_name = getattr(stud, 'faccode')
     87        elif breakdown == 'depcode':
     88            row_name = '%s/%s' % (
     89                getattr(stud, 'faccode'), getattr(stud, 'depcode'))
     90        row = paths.index(row_name)
    9291        col = states.index(stud.state)
    9392        table[row][col] += 1
Note: See TracChangeset for help on using the changeset viewer.