Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py	(revision 13857)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py	(revision 13858)
@@ -56,5 +56,4 @@
     site = grok.getSite()
     levels = (100, 200, 300, 400, 500)
-    levels = levels + (u'Total',)
     if breakdown == 'faccode':
         paths = tuple(sorted([x for x in site['faculties'].keys()],
@@ -74,5 +73,5 @@
     cat = queryUtility(ICatalog, name="students_catalog")
     result = cat.searchResults(current_session=(session, session))
-    table = [[0 for x in xrange(len(levels))] for y in xrange(len(paths)+1)]
+    table = [[0 for x in xrange(2 * len(levels) + 2)] for y in xrange(len(paths)+1)]
     for stud in result:
         if getattr(stud, breakdown) is None:
@@ -85,12 +84,24 @@
         row = paths.index(row_name)
         normalized_level = 100*(stud.current_level/100)
-        col = levels.index(normalized_level)
+        if stud.sex == 'f':
+            col = 2 * levels.index(normalized_level) + 1
+            total_col = -1
+        elif stud.sex == 'm':
+            col = 2 * levels.index(normalized_level)
+            total_col = -2
+        else:
+            continue
         table[row][col] += 1
         table[-1][col] += 1
-        table[row][-1] += 1
-        table[-1][-1] += 1
+        table[row][total_col] += 1
+        table[-1][total_col] += 1
     # turn lists into tuples
     table = tuple([tuple(row) for row in table])
-
+    levels = (u'100 male', u'100 female',
+              u'200 male', u'200 female',
+              u'300 male', u'300 female',
+              u'400 male', u'400 female',
+              u'500 male', u'500 female',
+              u'Total male', u'Total female')
     paths = paths + (u'Total',)
     return (paths, levels, table)
@@ -125,6 +136,8 @@
     ('LINEBELOW', (0,-1), (-1,-1), 0.25, colors.black),
     ('LINEAFTER', (-1,0), (-1,-1), 0.25, colors.black),
-    ('LINEBEFORE', (-1,0), (-1,-1), 1.0, colors.black),
-    #('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black),
+
+    ('LINEBEFORE', (-2,0), (-2,-1), 1.0, colors.black),
+
+    ('LINEABOVE', (0,-1), (-1,-1), 1.0, colors.black),
     #('LINEABOVE', (0,0), (-1,0), 0.25, colors.black),
     ]
@@ -150,5 +163,5 @@
         creator = getUtility(IPDFCreator, name='landscape')
         table_data = tbl_data_to_table(*self.data)
-        col_widths = [None,] + [1.6*cm] * len(self.data[1]) + [None,]
+        col_widths = [None,] + [1.8*cm] * (len(self.data[1]) - 1)+ [2.0*cm] + [None,]
         pdf_data = [Paragraph('<b>%s</b>' % self.creation_dt_string,
                               STYLE["Normal"]),
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py	(revision 13857)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py	(revision 13858)
@@ -18,5 +18,6 @@
     layer = FunctionalLayer
 
-    levels = (100, 200, 300, 400, 500, 'Total')
+    levels = (u'100 male', u'100 female', u'200 male', u'200 female', u'300 male', u'300 female',
+              u'400 male', u'400 female', u'500 male', u'500 female', u'Total male', u'Total female')
 
     def test_iface(self):
@@ -28,4 +29,6 @@
 
     def test_get_student_stats_session_simple(self):
+        self.student['studycourse'].current_level = 110
+        self.student.sex = 'm'
         # we can get a table with one student
         result1 = get_student_stats(2010, 'faccode')
@@ -35,19 +38,20 @@
             ((u'fac1', u'Total',),
              self.levels,
-             ((1, 0, 0, 0, 0, 1),
-              (1, 0, 0, 0, 0, 1),)
-             ))
+             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
+              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
+            ))
         self.assertEqual(
             result2,
             ((u'fac1', u'Total'),
              self.levels,
-             ((0, 0, 0, 0, 0, 0),
-              (0, 0, 0, 0, 0, 0),)
-              ))
+             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+            ))
         return
 
     def test_get_student_stats_session_multiple(self):
-        # we can get a table with several students
+        # we can get a table with several faculties
         self.create_cert(u'fac2', u'dep2', u'CERT2')
+        self.student.sex = 'm'
         result1 = get_student_stats(2010, 'faccode')
         result2 = get_student_stats(2009, 'faccode')
@@ -56,16 +60,16 @@
             ((u'fac1', u'fac2', u'Total'),
              self.levels,
-             ((1, 0, 0, 0, 0, 1),
-              (0, 0, 0, 0, 0, 0),
-              (1, 0, 0, 0, 0, 1),)
-             ))
+             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
+            ))
         self.assertEqual(
             result2,
             ((u'fac1', u'fac2', u'Total'),
              self.levels,
-             ((0, 0, 0, 0, 0, 0),
-              (0, 0, 0, 0, 0, 0),
-              (0, 0, 0, 0, 0, 0),)
-             ))
+             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+            ))
         return
 
@@ -73,4 +77,5 @@
         # we can get a table with several students
         self.create_cert(u'fac2', u'dep2', u'CERT2')
+        self.student.sex = 'm'
         result1 = get_student_stats(2010, 'depcode')
         result2 = get_student_stats(2009, 'depcode')
@@ -79,7 +84,7 @@
             ((u'fac1/dep1', u'fac2/dep2', u'Total'),
              self.levels,
-             ((1, 0, 0, 0, 0, 1),
-              (0, 0, 0, 0, 0, 0),
-              (1, 0, 0, 0, 0, 1),)
+             ((1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0))
              ))
         self.assertEqual(
@@ -87,13 +92,15 @@
             ((u'fac1/dep1', u'fac2/dep2', u'Total'),
              self.levels,
-             ((0, 0, 0, 0, 0, 0),
-              (0, 0, 0, 0, 0, 0),
-              (0, 0, 0, 0, 0, 0),)
+             ((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
+              (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
              ))
         return
 
     def test_create_pdf(self):
+        self.student.sex = 'm'
         self.create_cert(u'FAC2', u'dept2', u'CERT2')
-        report = StudentLevelStatisticsReport(2010, 'faccode')
+        self.student['studycourse'].current_level = 220
+        report = StudentLevelStatisticsReport(2010, 'depcode')
         result = report.create_pdf()
         self.assertTrue(result.startswith('%PDF-'))
