mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2024-12-04 22:40:30 +00:00
Avoid rounding two times
This commit is contained in:
parent
dd91e12fba
commit
7f3797719d
1 changed files with 7 additions and 3 deletions
|
@ -113,7 +113,7 @@ class PartStudent(db.Model):
|
||||||
Return True if final_part_mark changed, False otherwise.
|
Return True if final_part_mark changed, False otherwise.
|
||||||
"""
|
"""
|
||||||
finalWeightingSum = 0
|
finalWeightingSum = 0
|
||||||
finalMark = 0
|
finalMarkSum = 0
|
||||||
groupExperiments = []
|
groupExperiments = []
|
||||||
|
|
||||||
for experimentMark in self.experiment_marks:
|
for experimentMark in self.experiment_marks:
|
||||||
|
@ -138,7 +138,11 @@ class PartStudent(db.Model):
|
||||||
finalWeighting = semesterExperiment.final_weighting
|
finalWeighting = semesterExperiment.final_weighting
|
||||||
finalWeightingSum += finalWeighting
|
finalWeightingSum += finalWeighting
|
||||||
|
|
||||||
finalMark += finalWeighting * experimentMark.final_experiment_mark
|
# Not using final_experiment_mark to avoid rounding two times
|
||||||
|
finalMarkSum += finalWeighting * (
|
||||||
|
semesterExperiment.protocol_weighting * experimentMark.protocol_mark
|
||||||
|
+ semesterExperiment.oral_weighting * experimentMark.oral_mark
|
||||||
|
)
|
||||||
|
|
||||||
if set(groupExperiments) != set(self.group.group_experiments):
|
if set(groupExperiments) != set(self.group.group_experiments):
|
||||||
flash(f"{self} does not have an experiment mark for every group experiment in his group!", "warning")
|
flash(f"{self} does not have an experiment mark for every group experiment in his group!", "warning")
|
||||||
|
@ -147,7 +151,7 @@ class PartStudent(db.Model):
|
||||||
oldFinalPartMark = self.final_part_mark
|
oldFinalPartMark = self.final_part_mark
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.final_part_mark = roundHalfUpToInt(finalMark / finalWeightingSum)
|
self.final_part_mark = roundHalfUpToInt(finalMarkSum / finalWeightingSum)
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|
Loading…
Reference in a new issue