Changeset 13858
- Timestamp:
- 11 May 2016, 06:37:34 (9 years ago)
- 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 56 56 site = grok.getSite() 57 57 levels = (100, 200, 300, 400, 500) 58 levels = levels + (u'Total',)59 58 if breakdown == 'faccode': 60 59 paths = tuple(sorted([x for x in site['faculties'].keys()], … … 74 73 cat = queryUtility(ICatalog, name="students_catalog") 75 74 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)] 77 76 for stud in result: 78 77 if getattr(stud, breakdown) is None: … … 85 84 row = paths.index(row_name) 86 85 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 88 94 table[row][col] += 1 89 95 table[-1][col] += 1 90 table[row][ -1] += 191 table[-1][ -1] += 196 table[row][total_col] += 1 97 table[-1][total_col] += 1 92 98 # turn lists into tuples 93 99 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') 95 106 paths = paths + (u'Total',) 96 107 return (paths, levels, table) … … 125 136 ('LINEBELOW', (0,-1), (-1,-1), 0.25, colors.black), 126 137 ('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), 129 142 #('LINEABOVE', (0,0), (-1,0), 0.25, colors.black), 130 143 ] … … 150 163 creator = getUtility(IPDFCreator, name='landscape') 151 164 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,] 153 166 pdf_data = [Paragraph('<b>%s</b>' % self.creation_dt_string, 154 167 STYLE["Normal"]), -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py
r13857 r13858 18 18 layer = FunctionalLayer 19 19 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') 21 22 22 23 def test_iface(self): … … 28 29 29 30 def test_get_student_stats_session_simple(self): 31 self.student['studycourse'].current_level = 110 32 self.student.sex = 'm' 30 33 # we can get a table with one student 31 34 result1 = get_student_stats(2010, 'faccode') … … 35 38 ((u'fac1', u'Total',), 36 39 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 )) 40 43 self.assertEqual( 41 44 result2, 42 45 ((u'fac1', u'Total'), 43 46 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 )) 47 50 return 48 51 49 52 def test_get_student_stats_session_multiple(self): 50 # we can get a table with several students53 # we can get a table with several faculties 51 54 self.create_cert(u'fac2', u'dep2', u'CERT2') 55 self.student.sex = 'm' 52 56 result1 = get_student_stats(2010, 'faccode') 53 57 result2 = get_student_stats(2009, 'faccode') … … 56 60 ((u'fac1', u'fac2', u'Total'), 57 61 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 )) 62 66 self.assertEqual( 63 67 result2, 64 68 ((u'fac1', u'fac2', u'Total'), 65 69 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 )) 70 74 return 71 75 … … 73 77 # we can get a table with several students 74 78 self.create_cert(u'fac2', u'dep2', u'CERT2') 79 self.student.sex = 'm' 75 80 result1 = get_student_stats(2010, 'depcode') 76 81 result2 = get_student_stats(2009, 'depcode') … … 79 84 ((u'fac1/dep1', u'fac2/dep2', u'Total'), 80 85 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)) 84 89 )) 85 90 self.assertEqual( … … 87 92 ((u'fac1/dep1', u'fac2/dep2', u'Total'), 88 93 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)) 92 97 )) 93 98 return 94 99 95 100 def test_create_pdf(self): 101 self.student.sex = 'm' 96 102 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') 98 105 result = report.create_pdf() 99 106 self.assertTrue(result.startswith('%PDF-'))
Note: See TracChangeset for help on using the changeset viewer.