Ignore:
Timestamp:
11 May 2016, 06:37:34 (9 years ago)
Author:
Henrik Bettermann
Message:

Distinguish male and female students.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students/reports
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py

    r13857 r13858  
    5656    site = grok.getSite()
    5757    levels = (100, 200, 300, 400, 500)
    58     levels = levels + (u'Total',)
    5958    if breakdown == 'faccode':
    6059        paths = tuple(sorted([x for x in site['faculties'].keys()],
     
    7473    cat = queryUtility(ICatalog, name="students_catalog")
    7574    result = cat.searchResults(current_session=(session, session))
    76     table = [[0 for x in xrange(len(levels))] for y in xrange(len(paths)+1)]
     75    table = [[0 for x in xrange(2 * len(levels) + 2)] for y in xrange(len(paths)+1)]
    7776    for stud in result:
    7877        if getattr(stud, breakdown) is None:
     
    8584        row = paths.index(row_name)
    8685        normalized_level = 100*(stud.current_level/100)
    87         col = levels.index(normalized_level)
     86        if stud.sex == 'f':
     87            col = 2 * levels.index(normalized_level) + 1
     88            total_col = -1
     89        elif stud.sex == 'm':
     90            col = 2 * levels.index(normalized_level)
     91            total_col = -2
     92        else:
     93            continue
    8894        table[row][col] += 1
    8995        table[-1][col] += 1
    90         table[row][-1] += 1
    91         table[-1][-1] += 1
     96        table[row][total_col] += 1
     97        table[-1][total_col] += 1
    9298    # turn lists into tuples
    9399    table = tuple([tuple(row) for row in table])
    94 
     100    levels = (u'100 male', u'100 female',
     101              u'200 male', u'200 female',
     102              u'300 male', u'300 female',
     103              u'400 male', u'400 female',
     104              u'500 male', u'500 female',
     105              u'Total male', u'Total female')
    95106    paths = paths + (u'Total',)
    96107    return (paths, levels, table)
     
    125136    ('LINEBELOW', (0,-1), (-1,-1), 0.25, colors.black),
    126137    ('LINEAFTER', (-1,0), (-1,-1), 0.25, colors.black),
    127     ('LINEBEFORE', (-1,0), (-1,-1), 1.0, colors.black),
    128     #('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black),
     138
     139    ('LINEBEFORE', (-2,0), (-2,-1), 1.0, colors.black),
     140
     141    ('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black),
    129142    #('LINEABOVE', (0,0), (-1,0), 0.25, colors.black),
    130143    ]
     
    150163        creator = getUtility(IPDFCreator, name='landscape')
    151164        table_data = tbl_data_to_table(*self.data)
    152         col_widths = [None,] + [1.6*cm] * len(self.data[1]) + [None,]
     165        col_widths = [None,] + [1.8*cm] * (len(self.data[1]) - 1)+ [2.0*cm] + [None,]
    153166        pdf_data = [Paragraph('<b>%s</b>' % self.creation_dt_string,
    154167                              STYLE["Normal"]),
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py

    r13857 r13858  
    1818    layer = FunctionalLayer
    1919
    20     levels = (100, 200, 300, 400, 500, 'Total')
     20    levels = (u'100 male', u'100 female', u'200 male', u'200 female', u'300 male', u'300 female',
     21              u'400 male', u'400 female', u'500 male', u'500 female', u'Total male', u'Total female')
    2122
    2223    def test_iface(self):
     
    2829
    2930    def test_get_student_stats_session_simple(self):
     31        self.student['studycourse'].current_level = 110
     32        self.student.sex = 'm'
    3033        # we can get a table with one student
    3134        result1 = get_student_stats(2010, 'faccode')
     
    3538            ((u'fac1', u'Total',),
    3639             self.levels,
    37              ((1, 0, 0, 0, 0, 1),
    38               (1, 0, 0, 0, 0, 1),)
    39              ))
     40             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
     41              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
     42            ))
    4043        self.assertEqual(
    4144            result2,
    4245            ((u'fac1', u'Total'),
    4346             self.levels,
    44              ((0, 0, 0, 0, 0, 0),
    45               (0, 0, 0, 0, 0, 0),)
    46               ))
     47             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     48              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
     49            ))
    4750        return
    4851
    4952    def test_get_student_stats_session_multiple(self):
    50         # we can get a table with several students
     53        # we can get a table with several faculties
    5154        self.create_cert(u'fac2', u'dep2', u'CERT2')
     55        self.student.sex = 'm'
    5256        result1 = get_student_stats(2010, 'faccode')
    5357        result2 = get_student_stats(2009, 'faccode')
     
    5660            ((u'fac1', u'fac2', u'Total'),
    5761             self.levels,
    58              ((1, 0, 0, 0, 0, 1),
    59               (0, 0, 0, 0, 0, 0),
    60               (1, 0, 0, 0, 0, 1),)
    61              ))
     62             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
     63              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     64              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
     65            ))
    6266        self.assertEqual(
    6367            result2,
    6468            ((u'fac1', u'fac2', u'Total'),
    6569             self.levels,
    66              ((0, 0, 0, 0, 0, 0),
    67               (0, 0, 0, 0, 0, 0),
    68               (0, 0, 0, 0, 0, 0),)
    69              ))
     70             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     71              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     72              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
     73            ))
    7074        return
    7175
     
    7377        # we can get a table with several students
    7478        self.create_cert(u'fac2', u'dep2', u'CERT2')
     79        self.student.sex = 'm'
    7580        result1 = get_student_stats(2010, 'depcode')
    7681        result2 = get_student_stats(2009, 'depcode')
     
    7984            ((u'fac1/dep1', u'fac2/dep2', u'Total'),
    8085             self.levels,
    81              ((1, 0, 0, 0, 0, 1),
    82               (0, 0, 0, 0, 0, 0),
    83               (1, 0, 0, 0, 0, 1),)
     86             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
     87              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     88              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
    8489             ))
    8590        self.assertEqual(
     
    8792            ((u'fac1/dep1', u'fac2/dep2', u'Total'),
    8893             self.levels,
    89              ((0, 0, 0, 0, 0, 0),
    90               (0, 0, 0, 0, 0, 0),
    91               (0, 0, 0, 0, 0, 0),)
     94             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     95              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
     96              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
    9297             ))
    9398        return
    9499
    95100    def test_create_pdf(self):
     101        self.student.sex = 'm'
    96102        self.create_cert(u'FAC2', u'dept2', u'CERT2')
    97         report = StudentLevelStatisticsReport(2010, 'faccode')
     103        self.student['studycourse'].current_level = 220
     104        report = StudentLevelStatisticsReport(2010, 'depcode')
    98105        result = report.create_pdf()
    99106        self.assertTrue(result.startswith('%PDF-'))
Note: See TracChangeset for help on using the changeset viewer.