Changeset 14643 for main/waeup.kofa/trunk
- Timestamp:
- 22 Mar 2017, 10:25:56 (8 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students/reports
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/raw_score_report.py
r14625 r14643 55 55 canvas.drawString( 0, -1, self.text) 56 56 57 def tbl_data_to_table(data, c ourse_codes):57 def tbl_data_to_table(data, certcourses): 58 58 col_names = ( 59 59 #'Student Id', … … 62 62 'Name', 63 63 ) 64 catalog = getUtility(ICatalog, name='courses_catalog') 65 for code in course_codes: 66 course = list(catalog.searchResults(code=(code, code)))[0] 67 col_names += (TTR('%s (%s)' % (code, course.credits)),) 64 #catalog = getUtility(ICatalog, name='courses_catalog') 65 for certcourse in certcourses: 66 course = certcourse.course 67 if certcourse.course_category: 68 col_names += (TTR('%s (%s, %s)' % ( 69 course.code, course.credits, certcourse.course_category)),) 70 else: 71 col_names += (TTR('%s (%s)' % (course.code, course.credits)),) 68 72 table = [col_names] 69 73 sn = 1 … … 71 75 scores = tuple() 72 76 composed_line = (sn,) + line[:-1] 73 for c ode in course_codes:74 result = line[-1].get(c ode)77 for certcourse in certcourses: 78 result = line[-1].get(certcourse.course.code) 75 79 if not result: 76 80 scores += ('N/R',) … … 136 140 """ 137 141 site = grok.getSite() 138 course_codes = [] 142 #course_codes = [] 143 certcourses = [] 139 144 department = site['faculties'][faccode][depcode] 140 145 if certcode == 'all': … … 142 147 for certcourse in cert.values(): 143 148 if certcourse.level == level: 144 course_codes.append(certcourse.getCourseCode()) 149 #course_codes.append(certcourse.getCourseCode()) 150 certcourses.append(certcourse) 145 151 else: 146 152 certificate = site['faculties'][faccode][depcode].certificates[certcode] 147 153 for certcourse in certificate.values(): 148 154 if certcourse.level == level: 149 course_codes.append(certcourse.getCourseCode()) 150 return course_codes 151 152 def _get_students(self, faccode, depcode, certcode, session, level, course_codes): 155 #course_codes.append(certcourse.getCourseCode()) 156 certcourses.append(certcourse) 157 return certcourses 158 159 def _get_students(self, faccode, depcode, certcode, session, level, certcourses): 153 160 """Get students in a certain department/certificate who registered courses 154 161 in a certain session at a certain level. … … 176 183 scores = dict() 177 184 for ticket in level_obj.values(): 178 if ticket.code in course_codes:185 if ticket.code in [i.course.code for i in certcourses]: 179 186 if ticket.total_score is not None: 180 187 scores[ticket.code] = (ticket.total_score, ticket.grade) … … 224 231 getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z") 225 232 self.past_levels = range(int(level/100)*100, 0, -100) 226 self.course_codes = dict() 233 #self.course_codes = dict() 234 self.certcourses = dict() 227 235 self.data = dict() 228 236 for level in self.past_levels: 229 c ourse_codes = self._get_courses(237 certcourses = self._get_courses( 230 238 faccode, depcode, certcode, session, level) 231 self.course_codes[level] = course_codes 239 self.certcourses[level] = certcourses 240 #course_codes = [i.getCourseCode() for i in certcourses] 241 #self.course_codes[level] = course_codes 232 242 self.data[level] = self._get_students( 233 243 faccode, depcode, certcode, session, 234 self.levelcode, c ourse_codes)244 self.levelcode, certcourses) 235 245 236 246 def create_pdf(self, job_id): … … 239 249 for level in self.past_levels: 240 250 table_data[level] = tbl_data_to_table( 241 self.data[level], self.c ourse_codes[level])242 col_widths = [1*cm, 4*cm, 5*cm] + [1*cm] * len(self.c ourse_codes)251 self.data[level], self.certcourses[level]) 252 col_widths = [1*cm, 4*cm, 5*cm] + [1*cm] * len(self.certcourses) 243 253 pdf_data = [Paragraph('<b>%s - Report %s</b>' 244 254 % (self.creation_dt_string, job_id), -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_raw_score_report.py
r14605 r14643 38 38 rsr = RawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100) 39 39 result = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100) 40 self.assertEqual(result, [(u'Course1')]) 40 self.assertEqual(result, [self.certificate.values()[0]]) 41 self.assertEqual( 42 result, 43 [self.app['faculties']['fac1']['dep1'].certificates[ 44 'CERT1']['Course1_100']]) 41 45 return 42 46 … … 57 61 58 62 def test_create_pdf(self): 63 self.app['faculties']['fac1']['dep1'].certificates[ 64 'CERT1']['Course1_100'].course_category = 'xyz' 59 65 self.course = createObject('waeup.Course') 60 66 self.course.code = 'Course2'
Note: See TracChangeset for help on using the changeset viewer.