Ignore:
Timestamp:
20 Dec 2012, 06:59:26 (12 years ago)
Author:
Henrik Bettermann
Message:

Round gpa.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/studylevel.py

    r9698 r9812  
    8282    @property
    8383    def gpa(self):
    84         gpa = 0
     84        gpa = 0.0
    8585        credits_counted = 0
    8686        for ticket in self.values():
     
    8989                gpa += ticket.credits * ticket.weight
    9090        if credits_counted:
    91             gpa = 100*gpa/credits_counted
    92         return float(gpa)/100
     91            gpa = round(gpa/credits_counted, 2)
     92        return gpa
    9393
    9494    @property
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9795 r9812  
    764764        self.browser.getLink("COURSE1").click()
    765765        self.browser.getLink("Manage").click()
    766         #self.browser.getControl(name="form.score").value = '10'
    767766        self.browser.getControl("Save").click()
    768767        self.assertTrue('Form has been saved' in self.browser.contents)
     
    777776        self.assertEqual(self.student['studycourse']['100']['COURSE1'].grade, 'C')
    778777        self.assertEqual(self.student['studycourse']['100']['COURSE1'].weight, 3)
    779         # GPA has been properly calculated and is shown on the page
     778        # We add another ticket to check if GPA will be correctly calculated
     779        # (and rounded)
     780        courseticket = createObject('waeup.CourseTicket')
     781        courseticket.code = 'ANYCODE'
     782        courseticket.title = u'Any TITLE'
     783        courseticket.credits = 13
     784        courseticket.score = 66
     785        courseticket.semester = 1
     786        courseticket.dcode = u'ANYDCODE'
     787        courseticket.fcode = u'ANYFCODE'
     788        self.student['studycourse']['100']['COURSE2'] = courseticket
    780789        self.browser.open(self.student_path + '/studycourse/100')
    781         self.assertTrue('3.0' in self.browser.contents)
    782         self.assertEqual(self.student['studycourse']['100'].gpa, 3.0)
     790        self.assertTrue('<div>3.57</div>' in self.browser.contents)
     791        self.assertEqual(self.student['studycourse']['100'].gpa, 3.57)
    783792        # Carry-over courses will be collected when next level is created
    784793        self.browser.open(self.student_path + '/studycourse/manage')
Note: See TracChangeset for help on using the changeset viewer.