Changeset 10443
- Timestamp:
- 31 Jul 2013, 07:13:00 (11 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py
r10280 r10443 55 55 return total 56 56 57 @property 58 def gpa_params(self): 59 weighted_credits = 0.0 60 credits_counted = 0 61 level_gpa = 0.0 62 for ticket in self.values(): 63 if ticket.score: 64 credits_counted += ticket.credits 65 weighted_credits += ticket.credits * ticket.weight 66 if credits_counted: 67 level_gpa = round(weighted_credits/credits_counted, 2) 68 return level_gpa, credits_counted, weighted_credits 69 57 70 CustomStudentStudyLevel = attrs_to_fields( 58 71 CustomStudentStudyLevel, omit=[ -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r10051 r10443 65 65 return 66 66 67 class OfficerUITests(StudentsFullSetup): 68 # Tests for Student class views and pages 69 70 layer = FunctionalLayer 71 72 def test_gpa_calculation(self): 73 studylevel = createObject(u'waeup.StudentStudyLevel') 74 studylevel.level = 100 75 studylevel.level_session = 2005 76 self.student['studycourse'].entry_mode = 'ug_ft' 77 self.student['studycourse'].addStudentStudyLevel( 78 self.certificate, studylevel) 79 # First course has been added automatically. 80 # Set score. 81 studylevel['COURSE1'].score = 55 82 # GPA is 3.0. 83 self.assertEqual(studylevel.gpa_params[0], 3.0) 84 courseticket = createObject('waeup.CourseTicket') 85 courseticket.code = 'ANYCODE' 86 courseticket.title = u'Any TITLE' 87 courseticket.credits = 13 88 courseticket.score = 66 89 courseticket.semester = 1 90 courseticket.dcode = u'ANYDCODE' 91 courseticket.fcode = u'ANYFCODE' 92 studylevel['COURSE2'] = courseticket 93 # total credits 94 self.assertEqual(self.student['studycourse']['100'].gpa_params[1], 23) 95 # weigheted credits = 3 * 10 + 4 * 13 96 self.assertEqual(self.student['studycourse']['100'].gpa_params[2], 82.0) 97 # sgpa = 82 / 23 98 self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.57) 99 return 100 67 101 class StudentUITests(StudentsFullSetup): 68 102 """Tests for customized student class views and pages
Note: See TracChangeset for help on using the changeset viewer.