Changeset 10260 for main/waeup.kofa/trunk
- Timestamp:
- 31 May 2013, 05:21:11 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/studycourse.py
r10250 r10260 126 126 """ 127 127 levels = [] 128 gpa = 0.0129 credits_counted = 0128 cgpa = 0.0 129 total_credits_counted = 0 130 130 for level_key, level_val in self.items(): 131 131 tickets_1 = [] … … 133 133 tickets_3 = [] 134 134 tickets = sorted(level_val.values(), key=lambda ticket: ticket.code) 135 sgpa = 0.0 136 session_credits_counted = 0 135 137 for ticket in tickets: 136 138 if ticket.semester == 1: … … 141 143 tickets_3.append(ticket) 142 144 if ticket.score: 143 credits_counted += ticket.credits 144 gpa += ticket.credits * ticket.weight 145 total_credits_counted += ticket.credits 146 session_credits_counted += ticket.credits 147 cgpa += ticket.credits * ticket.weight 148 sgpa += ticket.credits * ticket.weight 149 if session_credits_counted: 150 sgpa = round(sgpa/session_credits_counted, 2) 145 151 levels.append( 146 152 dict(level_key=level_key, … … 148 154 tickets_1=tickets_1, 149 155 tickets_2=tickets_2, 150 tickets_3=tickets_3)) 151 if credits_counted: 152 gpa = round(gpa/credits_counted, 2) 153 return sorted(levels, key=lambda level: level['level_key']), gpa 156 tickets_3=tickets_3, 157 sgpa=sgpa)) 158 if total_credits_counted: 159 cgpa = round(cgpa/total_credits_counted, 2) 160 return sorted(levels, key=lambda level: level['level_key']), cgpa 154 161 155 162 StudentStudyCourse = attrs_to_fields(StudentStudyCourse) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r10259 r10260 1835 1835 td = self.student['studycourse'].getTranscriptData() 1836 1836 self.assertEqual(td[0][0]['level_key'], '100') 1837 self.assertEqual(td[0][0]['sgpa'], 3.57) 1837 1838 self.assertEqual(td[0][0]['level'].level, 100) 1838 1839 self.assertEqual(td[0][0]['level'].level_session, 2005)
Note: See TracChangeset for help on using the changeset viewer.