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

Fix for #15354: Count unique users who answered questions

parent afd8ba1c
No related merge requests found
......@@ -1080,11 +1080,14 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
try {
final View statsView = new View("statistics/statistics");
final View creatorView = new View("statistics/unique_session_creators");
final View studentUserView = new View("statistics/active_student_users");
statsView.setGroup(true);
creatorView.setGroup(true);
studentUserView.setGroup(true);
final ViewResults statsResults = getDatabase().view(statsView);
final ViewResults creatorResults = getDatabase().view(creatorView);
final ViewResults studentUserResults = getDatabase().view(studentUserView);
if (!isEmptyResults(statsResults)) {
final JSONArray rows = statsResults.getJSONArray("rows");
......@@ -1125,6 +1128,15 @@ public class CouchDBDao implements IDatabaseDao, ApplicationEventPublisherAware
}
stats.setCreators(creators.size());
}
if (!isEmptyResults(studentUserResults)) {
final JSONArray rows = studentUserResults.getJSONArray("rows");
Set<String> students = new HashSet<String>();
for (int i = 0; i < rows.size(); i++) {
final JSONObject row = rows.getJSONObject(i);
students.add(row.getString("key"));
}
stats.setActiveStudents(students.size());
}
return stats;
} catch (final Exception e) {
LOGGER.error("Error while retrieving session count", e);
......
......@@ -26,6 +26,7 @@ public class Statistics {
private int closedSessions;
private int creators;
private int activeUsers;
private int activeStudents;
private int loggedinUsers;
private int interposedQuestions;
private int conceptQuestions;
......@@ -118,6 +119,14 @@ public class Statistics {
this.conceptQuestions = conceptQuestions;
}
public int getActiveStudents() {
return activeStudents;
}
public void setActiveStudents(int activeStudents) {
this.activeStudents = activeStudents;
}
@Override
public int hashCode() {
return (this.getClass().getName()
......
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