Ignore:
Timestamp:
31 Jul 2018, 08:16:59 (6 years ago)
Author:
Henrik Bettermann
Message:

Irrespective of the CGPA of a student, if the He/She? has
3rd Extension, such student will be graduated with a "Pass".

Part 2

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

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_utils.py

    r14958 r15095  
    2222from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    2323from waeup.kofa.students.interfaces import IStudentsUtils
     24from waeup.kofa.students.studylevel import StudentStudyLevel
    2425from waeup.aaue.testing import FunctionalLayer
    2526
     
    250251        self.assertEqual(msg, 'No certificate assigned.')
    251252        return
     253
     254    def test_getClassFromCGPA(self):
     255        site = grok.getSite()
     256        utils = getUtility(IStudentsUtils)
     257        gpaclass, gpaboundary = utils.getClassFromCGPA(4.6, self.student)
     258        self.assertEqual(gpaclass, 5)
     259        self.assertEqual(gpaboundary, '1st Class Honours')
     260        self.certificate.study_mode = 'dp_ft'
     261        gpaclass, gpaboundary = utils.getClassFromCGPA(4.6, self.student)
     262        self.assertEqual(gpaclass, 4)
     263        self.assertEqual(gpaboundary, 'Distinction')
     264        studylevel = StudentStudyLevel()
     265        studylevel.level = 520
     266        self.student['studycourse'].addStudentStudyLevel(self.certificate,
     267            studylevel)
     268        gpaclass, gpaboundary = utils.getClassFromCGPA(4.6, self.student)
     269        self.assertEqual(gpaclass, 1)
     270        self.assertEqual(gpaboundary, 'Pass')
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r15050 r15095  
    7575    def getClassFromCGPA(self, gpa, student):
    7676        gpa_boundaries = self.GPABoundaries(student=student)
     77
     78        try:
     79            certificate = getattr(student['studycourse'],'certificate',None)
     80            end_level = getattr(certificate, 'end_level', None)
     81            final_level = max([studylevel.level for studylevel in student['studycourse'].values()])
     82            if end_level and final_level >= end_level:
     83                dummy, repeat = divmod(final_level, 100)
     84                if gpa <= 5.1 and repeat == 20:
     85                    # Irrespective of the CGPA of a student, if the He/She has
     86                    # 3rd Extension, such student will be graduated with a "Pass".
     87                    return 1, gpa_boundaries[1][1]
     88        except ValueError:
     89            pass
     90
    7791        if gpa < gpa_boundaries[0][0]:
    7892            # FRNS / Fail
     
    90104                return 0, gpa_boundaries[0][1]
    91105        if gpa < gpa_boundaries[2][0]:
    92             # 3rd / Pass
     106            # 3rd / Merit
    93107            return 2, gpa_boundaries[2][1]
    94108        if gpa < gpa_boundaries[3][0]:
    95             # 2nd L / Merit
     109            # 2nd L / Credit
    96110            return 3, gpa_boundaries[3][1]
    97111        if gpa < gpa_boundaries[4][0]:
    98             # 2nd U / Credit
     112            # 2nd U / Distinction
    99113            return 4, gpa_boundaries[4][1]
    100114        if gpa <= gpa_boundaries[5][0]:
    101             # 1st / Distinction
     115            # 1st
    102116            return 5, gpa_boundaries[5][1]
    103         return 'N/A'
     117        return
    104118
    105119    def getDegreeClassNumber(self, level_obj):
Note: See TracChangeset for help on using the changeset viewer.