Skip to content
Snippets Groups Projects
Commit 5b993f6b authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Attempt to get more accurate numerator values

parent 561c1b31
Branches
Tags
No related merge requests found
...@@ -33,12 +33,15 @@ public class QuestionBasedLearningProgress extends VariantLearningProgress { ...@@ -33,12 +33,15 @@ public class QuestionBasedLearningProgress extends VariantLearningProgress {
@Override @Override
protected LearningProgressValues createCourseProgress() { protected LearningProgressValues createCourseProgress() {
final int courseProgress = calculateCourseProgress();
final int numerator = courseScore.getQuestionCount()*courseProgress/100;
final int denominator = courseScore.getQuestionCount();
LearningProgressValues lpv = new LearningProgressValues(); LearningProgressValues lpv = new LearningProgressValues();
lpv.setCourseProgress(calculateCourseProgress()); lpv.setCourseProgress(courseProgress);
lpv.setNumQuestions(courseScore.getQuestionCount()); lpv.setNumQuestions(courseScore.getQuestionCount());
lpv.setNumUsers(courseScore.getTotalUserCount()); lpv.setNumUsers(courseScore.getTotalUserCount());
lpv.setNumerator(countCorrectAnswers()/courseScore.getTotalUserCount()); lpv.setNumerator(numerator);
lpv.setDenominator(courseScore.getQuestionCount()); lpv.setDenominator(denominator);
return lpv; return lpv;
} }
...@@ -67,17 +70,6 @@ public class QuestionBasedLearningProgress extends VariantLearningProgress { ...@@ -67,17 +70,6 @@ public class QuestionBasedLearningProgress extends VariantLearningProgress {
return numAnswersCorrect; return numAnswersCorrect;
} }
private int countCorrectAnswers() {
int answers = 0;
for (QuestionScore questionScore : courseScore) {
if (!questionScore.hasScores()) {
continue;
}
answers += countCorrectAnswers(questionScore);
}
return answers;
}
@Override @Override
protected LearningProgressValues createMyProgress(User user) { protected LearningProgressValues createMyProgress(User user) {
final int numerator = numQuestionsCorrectForUser(user); final int numerator = numQuestionsCorrectForUser(user);
......
...@@ -212,17 +212,17 @@ public class QuestionBasedLearningProgressTest { ...@@ -212,17 +212,17 @@ public class QuestionBasedLearningProgressTest {
// six answers // six answers
this.addAnswer(q1, u1, 10); this.addAnswer(q1, u1, 10);
this.addAnswer(q2, u1, -100); this.addAnswer(q2, u1, -100);
this.addAnswer(q1, u2, 10); this.addAnswer(q1, u2, -100);
this.addAnswer(q2, u2, -100); this.addAnswer(q2, u2, -100);
this.addAnswer(q1, u3, 10); this.addAnswer(q1, u3, -100);
this.addAnswer(q2, u3, -100); this.addAnswer(q2, u3, -100);
int numerator = lp.getCourseProgress(null).getNumerator(); int numerator = lp.getCourseProgress(null).getNumerator();
int denominator = lp.getCourseProgress(null).getDenominator(); int denominator = lp.getCourseProgress(null).getDenominator();
// If the percentage is wrong, then we need to adapt this test case! // If the percentage is wrong, then we need to adapt this test case!
assertEquals("Precondition failed -- The underlying calculation has changed", 50, lp.getCourseProgress(null).getCourseProgress()); assertEquals("Precondition failed -- The underlying calculation has changed", 17, lp.getCourseProgress(null).getCourseProgress());
assertEquals(1, numerator); assertEquals(0, numerator);
assertEquals(2, denominator); assertEquals(2, denominator);
} }
......
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