Changeset 15095 for main/waeup.aaue/trunk/src/waeup
- Timestamp:
- 31 Jul 2018, 08:16:59 (6 years ago)
- 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 22 22 from waeup.kofa.students.tests.test_browser import StudentsFullSetup 23 23 from waeup.kofa.students.interfaces import IStudentsUtils 24 from waeup.kofa.students.studylevel import StudentStudyLevel 24 25 from waeup.aaue.testing import FunctionalLayer 25 26 … … 250 251 self.assertEqual(msg, 'No certificate assigned.') 251 252 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 75 75 def getClassFromCGPA(self, gpa, student): 76 76 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 77 91 if gpa < gpa_boundaries[0][0]: 78 92 # FRNS / Fail … … 90 104 return 0, gpa_boundaries[0][1] 91 105 if gpa < gpa_boundaries[2][0]: 92 # 3rd / Pass106 # 3rd / Merit 93 107 return 2, gpa_boundaries[2][1] 94 108 if gpa < gpa_boundaries[3][0]: 95 # 2nd L / Merit109 # 2nd L / Credit 96 110 return 3, gpa_boundaries[3][1] 97 111 if gpa < gpa_boundaries[4][0]: 98 # 2nd U / Credit112 # 2nd U / Distinction 99 113 return 4, gpa_boundaries[4][1] 100 114 if gpa <= gpa_boundaries[5][0]: 101 # 1st / Distinction115 # 1st 102 116 return 5, gpa_boundaries[5][1] 103 return 'N/A'117 return 104 118 105 119 def getDegreeClassNumber(self, level_obj):
Note: See TracChangeset for help on using the changeset viewer.