Commit 3f80b31f authored by LammLukas's avatar LammLukas
Browse files

Added bonus to evaluation

parent fb7c04eb
...@@ -20,7 +20,8 @@ class Evaluator: ...@@ -20,7 +20,8 @@ class Evaluator:
for participant in self.Exam.Participants: for participant in self.Exam.Participants:
if not self.is_grade_note(participant.Grade): if not self.is_grade_note(participant.Grade):
pts_total_part = sum(participant.Points) pts_total_part = sum(participant.Points)
grade = self.get_grade(pts_total_part, pt_limits) bonus = participant.Bonus
grade = self.get_grade(pts_total_part, bonus, pt_limits)
participant.Grade = grade participant.Grade = grade
def set_pt_limits(self, lower_bound_pct, upper_bound_pct, mode): def set_pt_limits(self, lower_bound_pct, upper_bound_pct, mode):
...@@ -53,11 +54,12 @@ class Evaluator: ...@@ -53,11 +54,12 @@ class Evaluator:
return array return array
@staticmethod @staticmethod
def get_grade(self, pts, pts_array): def get_grade(self, pts, bonus, pts_array):
"""Calculate grade from points""" """Calculate grade from points"""
if pts < pts_array[0]: if pts < pts_array[0]:
return 5.0 return 5.0
elif pts_array[0] <= pts < pts_array[1]: if not bonus:
if pts_array[0] <= pts < pts_array[1]:
return 4.0 return 4.0
elif pts_array[1] <= pts < pts_array[2]: elif pts_array[1] <= pts < pts_array[2]:
return 3.7 return 3.7
...@@ -79,6 +81,27 @@ class Evaluator: ...@@ -79,6 +81,27 @@ class Evaluator:
return 1.0 return 1.0
else: else:
raise PointsOutOfScope() raise PointsOutOfScope()
else:
if pts_array[0] <= pts < pts_array[1]:
return 3.7
elif pts_array[1] <= pts < pts_array[2]:
return 3.3
elif pts_array[2] <= pts < pts_array[3]:
return 3.0
elif pts_array[3] <= pts < pts_array[4]:
return 2.7
elif pts_array[4] <= pts < pts_array[5]:
return 2.3
elif pts_array[5] <= pts < pts_array[6]:
return 2.0
elif pts_array[6] <= pts < pts_array[7]:
return 1.7
elif pts_array[7] <= pts < pts_array[8]:
return 1.3
elif pts_array[8] <= pts:
return 1.0
else:
raise PointsOutOfScope()
@staticmethod @staticmethod
def is_grade_note(grade): def is_grade_note(grade):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment