Ignore:
Timestamp:
10 Feb 2017, 13:53:40 (8 years ago)
Author:
Henrik Bettermann
Message:

Move getGradeWeightFromScore into StudentStudyLevel? class in order to ease customization.

File:
1 edited

Legend:

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

    r14530 r14531  
    4747    return co_ticket
    4848
    49 def getGradeWeightFromScore(score, ticket):
    50     """Nigerian Course Grading System
    51     """
    52     if score == -1:
    53         return ('-',0) # core course but result not yet available (used by AAUE)
    54     if score is None:
    55         return (None, None)
    56     if score >= 70:
    57         return ('A',5)
    58     if score >= 60:
    59         return ('B',4)
    60     if score >= 50:
    61         return ('C',3)
    62     if score >= 45:
    63         return ('D',2)
    64     if score >= ticket.passmark: # passmark changed in 2013 from 40 to 45
    65         return ('E',1)
    66     return ('F',0)
    67 
    6849class StudentStudyLevel(grok.Container):
    6950    """This is a container for course tickets.
     
    384365
    385366    @property
     367    def _getGradeWeightFromScore(self):
     368        """Nigerian Course Grading System
     369        """
     370        if self.total_score is None:
     371            return (None, None)
     372        if self.total_score >= 70:
     373            return ('A',5)
     374        if self.total_score >= 60:
     375            return ('B',4)
     376        if self.total_score >= 50:
     377            return ('C',3)
     378        if self.total_score >= 45:
     379            return ('D',2)
     380        if self.total_score >= self.passmark: # passmark changed in 2013 from 40 to 45
     381            return ('E',1)
     382        return ('F',0)
     383
     384    @property
    386385    def grade(self):
    387386        """Returns the grade calculated from total score.
    388387        """
    389         return getGradeWeightFromScore(self.total_score, self)[0]
     388        return self._getGradeWeightFromScore[0]
    390389
    391390    @property
     
    393392        """Returns the weight calculated from total score.
    394393        """
    395         return getGradeWeightFromScore(self.total_score, self)[1]
     394        return self._getGradeWeightFromScore[1]
    396395
    397396CourseTicket = attrs_to_fields(CourseTicket)
Note: See TracChangeset for help on using the changeset viewer.