Changeset 14914 for main


Ignore:
Timestamp:
30 Nov 2017, 07:39:20 (7 years ago)
Author:
Henrik Bettermann
Message:

Replace gpa_boundaries utility attribute by GPABoundaries method
which may return different values in custom packages depending on faculty
or department code (requested by AAU Ekpoma).

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r14804 r14914  
    441.6.dev0 (unreleased)
    55=======================
     6
     7* Replace `gpa_boundaries` utility attribute by `GPABoundaries` method
     8  which may return different values in custom packages depending on faculty
     9  or department code (requested by AAU Ekpoma).
    610
    711* Allow `ApplicantOnlinePaymentProcessor` to import records without
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/session_results_presentation.py

    r14625 r14914  
    107107        students_utils = getUtility(IStudentsUtils)
    108108        table = list()
    109         for i in range(len(students_utils.gpa_boundaries)+1):
     109        for i in range(len(students_utils.GPABoundaries())+1):
    110110            # The last list is reserved for students with more than one
    111111            # level in the same session.
     
    137137                if itemcount > 1:
    138138                    # Error: more than one level registered in this session
    139                     table[len(students_utils.gpa_boundaries)].append(line)
     139                    table[len(students_utils.GPABoundaries())].append(line)
    140140                    continue
    141141            gpaclass = students_utils.getDegreeClassNumber(level_obj)
    142142            table[gpaclass].append(line)
    143             for i in range(len(students_utils.gpa_boundaries)+1):
     143            for i in range(len(students_utils.GPABoundaries())+1):
    144144                if len(table[i]):
    145145                    table[i] = sorted([value for value in table[i]],
     
    211211        students_utils = getUtility(IStudentsUtils)
    212212        # Print classes in reverse order
    213         for gpa_class in range(len(students_utils.gpa_boundaries)-1,-1,-1):
     213        for gpa_class in range(len(students_utils.GPABoundaries())-1,-1,-1):
    214214            pdf_data.append(Spacer(1, 20))
    215             gpa_class_name = students_utils.gpa_boundaries[gpa_class][1]
     215            gpa_class_name = students_utils.GPABoundaries(
     216                faccode=self.faccode, depcode=self.depcode)[gpa_class][1]
    216217            pdf_data += [Paragraph('<strong>%s</strong>' % gpa_class_name,
    217218                         STYLE["Normal"])]
     
    238239        total_count = 0
    239240        table_data = list()
    240         for gpa_class in range(len(students_utils.gpa_boundaries)-1,-1,-1):
    241             gpa_class_name = students_utils.gpa_boundaries[gpa_class][1]
     241        for gpa_class in range(len(students_utils.GPABoundaries())-1,-1,-1):
     242            gpa_class_name = students_utils.GPABoundaries(
     243                faccode=self.faccode, depcode=self.depcode)[gpa_class][1]
    242244            gpa_count = len(self.data[gpa_class])
    243245            total_count += gpa_count
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r14709 r14914  
    817817        return pdf_stream
    818818
    819     gpa_boundaries = ((1, 'Fail'),
    820                       (1.5, 'Pass'),
    821                       (2.4, '3rd Class'),
    822                       (3.5, '2nd Class Lower'),
    823                       (4.5, '2nd Class Upper'),
    824                       (5, '1st Class'))
     819    def GPABoundaries(self, faccode=None, depcode=None):
     820        return ((1, 'Fail'),
     821               (1.5, 'Pass'),
     822               (2.4, '3rd Class'),
     823               (3.5, '2nd Class Lower'),
     824               (4.5, '2nd Class Upper'),
     825               (5, '1st Class'))
    825826
    826827    def getClassFromCGPA(self, gpa, student):
     
    829830        base package, it does not.
    830831        """
    831         if gpa < self.gpa_boundaries[0][0]:
    832             return 0, self.gpa_boundaries[0][1]
    833         if gpa < self.gpa_boundaries[1][0]:
    834             return 1, self.gpa_boundaries[1][1]
    835         if gpa < self.gpa_boundaries[2][0]:
    836             return 2, self.gpa_boundaries[2][1]
    837         if gpa < self.gpa_boundaries[3][0]:
    838             return 3, self.gpa_boundaries[3][1]
    839         if gpa < self.gpa_boundaries[4][0]:
    840             return 4, self.gpa_boundaries[4][1]
    841         if gpa <= self.gpa_boundaries[5][0]:
    842             return 5, self.gpa_boundaries[5][1]
     832        if gpa < self.GPABoundaries()[0][0]:
     833            return 0, self.GPABoundaries()[0][1]
     834        if gpa < self.GPABoundaries()[1][0]:
     835            return 1, self.GPABoundaries()[1][1]
     836        if gpa < self.GPABoundaries()[2][0]:
     837            return 2, self.GPABoundaries()[2][1]
     838        if gpa < self.GPABoundaries()[3][0]:
     839            return 3, self.GPABoundaries()[3][1]
     840        if gpa < self.GPABoundaries()[4][0]:
     841            return 4, self.GPABoundaries()[4][1]
     842        if gpa <= self.GPABoundaries()[5][0]:
     843            return 5, self.GPABoundaries()[5][1]
    843844        return 'N/A'
    844845
Note: See TracChangeset for help on using the changeset viewer.