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

Fix calculating point-based progress for single user

parent f8f388c0
Branches
Tags
No related merge requests found
......@@ -23,6 +23,8 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import de.thm.arsnova.entities.User;
public class CourseScore implements Iterable<QuestionScore> {
private final Map<String, QuestionScore> scores = new HashMap<String, QuestionScore>();
......@@ -61,6 +63,14 @@ public class CourseScore implements Iterable<QuestionScore> {
return score;
}
public double getTotalUserScore(User user) {
int score = 0;
for (QuestionScore questionScore : this) {
score += questionScore.getTotalUserScore(user);
}
return score;
}
public int getTotalUserCount() {
Set<String> users = new HashSet<String>();
for (QuestionScore questionScore : this) {
......
......@@ -56,7 +56,7 @@ public class PointBasedLearningProgress implements LearningProgress {
int courseProgress = calculateCourseScore(courseScore);
final double courseMaximumValue = courseScore.getMaximumScore();
final double userTotalValue = courseScore.getTotalUserScore();
final double userTotalValue = courseScore.getTotalUserScore(user);
if (courseMaximumValue == 0) {
return new AbstractMap.SimpleEntry<Integer, Integer>(0, courseProgress);
......
......@@ -22,6 +22,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import de.thm.arsnova.entities.User;
public class QuestionScore implements Iterable<UserScore> {
private String questionId;
......@@ -56,6 +58,16 @@ public class QuestionScore implements Iterable<UserScore> {
return totalScore;
}
public int getTotalUserScore(User user) {
int totalScore = 0;
for (UserScore score : userScores) {
if (score.isUser(user)) {
totalScore += score.getScore();
}
}
return totalScore;
}
public int getUserCount() {
return userScores.size();
}
......
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