Changeset 14076
- Timestamp:
- 15 Aug 2016, 16:55:04 (8 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/raw_score_report.py
r14049 r14076 54 54 55 55 def get_courses_2(faccode, depcode, session, level): 56 """Method 2 : Get all courses students of a certain56 """Method 2 (not used): Get all courses students of a certain 57 57 department have registered at a certain level. 58 58 """ … … 96 96 scores[ticket.code] = (ticket.score, ticket.grade) 97 97 else: 98 scores[ticket.code] = (' N/A', '')98 scores[ticket.code] = ('0', '') 99 99 line = ( 100 100 stud.matric_number, … … 125 125 def draw(self): 126 126 canvas = self.canv 127 canvas.rotate( 60)127 canvas.rotate(25) 128 128 canvas.drawString( 0, -1, self.text) 129 129 … … 142 142 for code in course_codes: 143 143 course = list(catalog.searchResults(code=(code, code)))[0] 144 col_names += (TTR('%s - %s' % (code, course.title)),)144 col_names += (TTR('%s (%s)' % (code, course.credits)),) 145 145 table = [col_names] 146 146 sn = 1 … … 199 199 self.creation_dt_string = self.creation_dt.astimezone( 200 200 getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z") 201 self.course_codes = get_courses_2(faccode, depcode, session, level) 202 self.data = get_students( 203 faccode, depcode, session, level, self.course_codes) 201 self.past_levels = range(level, 0, -100)[:3] 202 self.course_codes = dict() 203 self.data = dict() 204 for level in self.past_levels: 205 course_codes = get_courses_1(faccode, depcode, session, level) 206 self.course_codes[level] = course_codes 207 self.data[level] = get_students( 208 faccode, depcode, session, self.levelcode, course_codes) 204 209 205 210 def create_pdf(self): 206 211 creator = getUtility(IPDFCreator, name='landscape') 207 table_data = tbl_data_to_table(self.data, self.course_codes) 212 table_data = dict() 213 for level in self.past_levels: 214 table_data[level] = tbl_data_to_table( 215 self.data[level], self.course_codes[level]) 208 216 col_widths = [1*cm, 4*cm, 5*cm] + [1*cm] * len(self.course_codes) 209 217 pdf_data = [Paragraph('<b>%s</b>' % self.creation_dt_string, … … 219 227 STYLE["Normal"]), 220 228 Spacer(1, 12),] 221 pdf_data += [ 222 Table(table_data, style=TABLE_STYLE, colWidths=col_widths)] 229 230 for level in self.past_levels: 231 pdf_data.append(Spacer(1, 40)) 232 pdf_data += [Paragraph('<b>Level %s Courses</b>' % level, 233 STYLE["Normal"]), Spacer(1, 20),] 234 pdf_data += [ 235 Table(table_data[level], 236 style=TABLE_STYLE, 237 colWidths=col_widths)] 223 238 doc_title = translate(_('Raw Score Report')) 224 225 239 pdf_data.append(Spacer(1, 40)) 226 240 signatures = [ -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py
r14048 r14076 11 11 from waeup.aaue.students.reports.raw_score_report import ( 12 12 get_students, RawScoreReport, IRawScoreReport, 13 get_courses_ 2as get_courses)13 get_courses_1 as get_courses) 14 14 from waeup.aaue.testing import FunctionalLayer 15 15 … … 49 49 50 50 def test_create_pdf(self): 51 report = RawScoreReport('fac1', 'dep1', 2010, 100)51 report = RawScoreReport('fac1', 'dep1', 2010, 200) 52 52 result = report.create_pdf() 53 53 self.assertTrue(result.startswith('%PDF-'))
Note: See TracChangeset for help on using the changeset viewer.