Commit 8e15965b authored by Tom Käsler's avatar Tom Käsler

Merge branch 'div-by-zero-fix-2.7' into 2.x

parents b29fef5d ca5ba6d1
Pipeline #36001 passed with stages
in 1 minute and 45 seconds
......@@ -36,7 +36,11 @@ public class PointBasedLearningProgress extends VariantLearningProgress {
lpv.setCourseProgress(coursePercentage());
lpv.setNumQuestions(courseScore.getQuestionCount());
lpv.setNumUsers(courseScore.getTotalUserCount());
lpv.setNumerator(courseScore.getTotalUserScore() / courseScore.getTotalUserCount());
if (courseScore.getTotalUserCount() == 0) {
lpv.setNumerator(0);
} else {
lpv.setNumerator(courseScore.getTotalUserScore() / courseScore.getTotalUserCount());
}
lpv.setDenominator(courseScore.getMaximumScore());
return lpv;
}
......
......@@ -154,4 +154,9 @@ public class PointBasedLearningProgressTest {
assertEquals(10, numerator);
assertEquals(20, denominator);
}
@Test
public void shouldNotDivideByZeroInNumerator() {
assertEquals(0, lp.getCourseProgress(null).getNumerator());
}
}
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