Changeset 14048 for main/waeup.aaue/trunk/src/waeup/aaue/students/reports
- Timestamp:
- 3 Aug 2016, 09:07:57 (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
r14043 r14048 40 40 creation_dt_string = Attribute('Human readable report creation datetime') 41 41 42 def get_courses(faccode, depcode, level): 43 """Get certificate courses of a certain department at a certain level. 42 def get_courses_1(faccode, depcode, session, level): 43 """Method 1: Get certificate courses of a 44 certain department at a certain level. 44 45 """ 45 46 site = grok.getSite() … … 50 51 if certcourse.level == level: 51 52 course_codes.append(certcourse.getCourseCode()) 53 return course_codes 54 55 def get_courses_2(faccode, depcode, session, level): 56 """Method 2: Get all courses students of a certain 57 department have registered at a certain level. 58 """ 59 cat = queryUtility(ICatalog, name="students_catalog") 60 result = cat.searchResults( 61 depcode = (depcode, depcode), faccode = (faccode, faccode) 62 ) 63 course_codes = [] 64 for stud in result: 65 if not stud['studycourse'].has_key(str(level)): 66 continue 67 level_obj = stud['studycourse'][str(level)] 68 if level_obj.level_session != session: 69 continue 70 for ticket in level_obj.values(): 71 course_codes.append(ticket.code) 72 course_codes = sorted(list(set(course_codes))) 52 73 return course_codes 53 74 … … 104 125 def draw(self): 105 126 canvas = self.canv 106 canvas.rotate( 45)127 canvas.rotate(60) 107 128 canvas.drawString( 0, -1, self.text) 108 129 … … 121 142 for code in course_codes: 122 143 course = list(catalog.searchResults(code=(code, code)))[0] 123 col_names += (TTR('%s (%s)' % (course.title, code)),)144 col_names += (TTR('%s - %s' % (code, course.title)),) 124 145 table = [col_names] 125 146 sn = 1 … … 177 198 self.creation_dt_string = self.creation_dt.astimezone( 178 199 getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z") 179 self.course_codes = get_courses (faccode, depcode, level)200 self.course_codes = get_courses_2(faccode, depcode, session, level) 180 201 self.data = get_students( 181 202 faccode, depcode, session, level, self.course_codes) -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py
r14041 r14048 10 10 11 11 from waeup.aaue.students.reports.raw_score_report import ( 12 get_students, get_courses, RawScoreReport, IRawScoreReport) 12 get_students, RawScoreReport, IRawScoreReport, 13 get_courses_2 as get_courses) 13 14 from waeup.aaue.testing import FunctionalLayer 14 15 … … 35 36 def test_get_courses(self): 36 37 # we can get a list with one course code 37 result = get_courses('fac1', 'dep1', 100)38 result = get_courses('fac1', 'dep1', 2010, 100) 38 39 self.assertEqual(result, [(u'Course1')]) 39 40 return … … 41 42 def test_get_students(self): 42 43 # we can get a table with one student 43 course_codes = get_courses('fac1', 'dep1', 100)44 course_codes = get_courses('fac1', 'dep1', 2010, 100) 44 45 result = get_students('fac1', 'dep1', 2010, 100, course_codes) 45 46 self.assertEqual(result,
Note: See TracChangeset for help on using the changeset viewer.