Ignore:
Timestamp:
3 Aug 2018, 09:54:07 (6 years ago)
Author:
Henrik Bettermann
Message:

Customize gpa_params and round gpa.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.dspg/trunk/src/kofacustom/dspg/students/studylevel.py

    r14988 r15097  
    3737    grok.implements(ICustomStudentStudyLevel, IStudentNavigation)
    3838    grok.provides(ICustomStudentStudyLevel)
     39
     40    @property
     41    def gpa_params(self):
     42        """Calculate gpa parameters for this level.
     43        """
     44        credits_weighted = 0.0
     45        credits_counted = 0
     46        level_gpa = 0.0
     47        for ticket in self.values():
     48            if ticket.total_score is not None:
     49                credits_counted += ticket.credits
     50                credits_weighted += ticket.credits * ticket.weight
     51        if credits_counted:
     52            level_gpa = round(credits_weighted / credits_counted, 2)
     53        # Override level_gpa if value has been imported
     54        # (not implemented in base package)
     55        imported_gpa = getattr(self, 'imported_gpa', None)
     56        if imported_gpa:
     57            level_gpa = imported_gpa
     58        return level_gpa, credits_counted, credits_weighted
     59
    3960
    4061CustomStudentStudyLevel = attrs_to_fields(
Note: See TracChangeset for help on using the changeset viewer.