fix(exam-bonus): avoid divide by zero if all sheets are bonus
Fixes #671
This commit is contained in:
parent
1cd79d35e2
commit
0fd7e86695
@ -170,6 +170,7 @@ examResultBonus bonusRule bonusPossible bonusAchieved = case bonusRule of
|
|||||||
scalePasses :: Integer -> Rational
|
scalePasses :: Integer -> Rational
|
||||||
-- ^ Rescale passes so count of all sheets with pass is worth as many points as sum of all sheets with points
|
-- ^ Rescale passes so count of all sheets with pass is worth as many points as sum of all sheets with points
|
||||||
scalePasses passes
|
scalePasses passes
|
||||||
|
| pointsPossible <= 0, passesPossible <= 0 = 1 -- This arbitrarily identifies a pass as being worth one point if all sheets are `Bonus`; maybe weird
|
||||||
| pointsPossible <= 0 = toRational mPoints / fromInteger passesPossible
|
| pointsPossible <= 0 = toRational mPoints / fromInteger passesPossible
|
||||||
| passesPossible <= 0 = 0
|
| passesPossible <= 0 = 0
|
||||||
| otherwise = fromInteger passes / fromInteger passesPossible * toRational pointsPossible
|
| otherwise = fromInteger passes / fromInteger passesPossible * toRational pointsPossible
|
||||||
|
|||||||
Reference in New Issue
Block a user