Commit f31d7612 authored by Christopher Fullarton's avatar Christopher Fullarton

Fixes initializing the groups

parent 410b9c93
......@@ -97,16 +97,11 @@ class MemberDAO extends AbstractDAO<Array<MemberEntity>> {
DbDAO.deleteMany(DbCollection.Members, { currentQuizName: removedQuiz.name });
}
public getMemberAmountPerQuizGroup(name: string): object {
public getMemberAmountPerQuizGroup(name: string, groups: Array<string>): object {
const result = {};
groups.forEach(g => result[g] = 0);
this.getMembersOfQuiz(name).forEach(member => {
const targetResult = result[member.groupName];
if (!targetResult) {
result[member.groupName] = 1;
return;
}
result[member.groupName]++;
});
......
......@@ -699,8 +699,10 @@ export class QuizRouter extends AbstractRouter {
let groupName = 'Default';
if (activeQuiz.sessionConfig.nicks.memberGroups.length > 1) {
const memberGroupLoad = MemberDAO.getMemberAmountPerQuizGroup(activeQuiz.name);
groupName = Object.entries(memberGroupLoad).sort((a, b) => a[1] - b[1])[0][0];
const memberGroupLoad = MemberDAO.getMemberAmountPerQuizGroup(activeQuiz.name, activeQuiz.sessionConfig.nicks.memberGroups);
if (memberGroupLoad) {
groupName = Object.entries(memberGroupLoad).sort((a, b) => a[1] - b[1])[0][0];
}
}
return {
......
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