Fixes validation of answers. Fixes kick member modal text content

parent b13e9f19
......@@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with ARSnova Click. If not, see <http://www.gnu.org/licenses/>.*/
import { LeaderboardConfiguration } from '../../enums/LeaderboardConfiguration';
import { ISessionConfigurationEntity } from '../../interfaces/session_configuration/ISessionConfigurationEntity';
import { ISessionConfigurationSerialized } from '../../interfaces/session_configuration/ISessionConfigurationSerialized';
import { IMusicSessionConfigurationEntity } from '../../interfaces/session_configuration/music/IMusicSessionConfigurationEntity';
......@@ -83,8 +84,18 @@ export abstract class AbstractSessionConfigurationEntity implements ISessionConf
this._confidenceSliderEnabled = value;
}
private _leaderboardAlgorithm: LeaderboardConfiguration;
get leaderboardAlgorithm(): LeaderboardConfiguration {
return this._leaderboardAlgorithm;
}
set leaderboardAlgorithm(value: LeaderboardConfiguration) {
this._leaderboardAlgorithm = value;
}
protected constructor({
music, nicks, theme, readingConfirmationEnabled, showResponseProgress, confidenceSliderEnabled,
music, nicks, theme, readingConfirmationEnabled, showResponseProgress, confidenceSliderEnabled, leaderboardAlgorithm,
}) {
this.music = new MusicSessionConfigurationEntity(music);
this.nicks = new NickSessionConfigurationEntity(nicks);
......@@ -92,6 +103,7 @@ export abstract class AbstractSessionConfigurationEntity implements ISessionConf
this.readingConfirmationEnabled = readingConfirmationEnabled;
this.showResponseProgress = showResponseProgress;
this.confidenceSliderEnabled = confidenceSliderEnabled;
this.leaderboardAlgorithm = leaderboardAlgorithm;
}
public serialize(): ISessionConfigurationSerialized {
......@@ -102,12 +114,13 @@ export abstract class AbstractSessionConfigurationEntity implements ISessionConf
readingConfirmationEnabled: this.readingConfirmationEnabled,
showResponseProgress: this.showResponseProgress,
confidenceSliderEnabled: this.confidenceSliderEnabled,
leaderboardAlgorithm: this.leaderboardAlgorithm,
};
}
public equals(value: ISessionConfigurationEntity): boolean {
return this.music.equals(value.music) && this.nicks.equals(value.nicks) && this.theme === value.theme && this.readingConfirmationEnabled
=== value.readingConfirmationEnabled && this.showResponseProgress === value.showResponseProgress && this.confidenceSliderEnabled
=== value.confidenceSliderEnabled;
=== value.confidenceSliderEnabled && value.leaderboardAlgorithm === this.leaderboardAlgorithm;
}
}
import { LeaderboardConfiguration } from '../../enums/LeaderboardConfiguration';
import { ISessionConfigurationSerialized } from './ISessionConfigurationSerialized';
import { IMusicSessionConfigurationEntity } from './music/IMusicSessionConfigurationEntity';
import { INickSessionConfigurationEntity } from './nicks/INickSessionConfigurationEntity';
......@@ -5,6 +6,7 @@ import { INickSessionConfigurationEntity } from './nicks/INickSessionConfigurati
export interface ISessionConfigurationEntity extends ISessionConfigurationSerialized {
music: IMusicSessionConfigurationEntity;
nicks: INickSessionConfigurationEntity;
leaderboardAlgorithm: LeaderboardConfiguration;
serialize(): ISessionConfigurationSerialized;
......
import { LeaderboardConfiguration } from '../../enums/LeaderboardConfiguration';
import { IMusicSessionConfigurationSerialized } from './music/IMusicSessionConfigurationSerialized';
import { INickSessionConfigurationSerialized } from './nicks/INickSessionConfigurationSerialized';
......@@ -8,4 +9,5 @@ export interface ISessionConfigurationSerialized {
readingConfirmationEnabled: boolean;
showResponseProgress: boolean;
confidenceSliderEnabled: boolean;
leaderboardAlgorithm: LeaderboardConfiguration;
}
......@@ -14,15 +14,19 @@ import { PointBasedLeaderboardScore } from './PointBasedLeaderboardScore';
import { TimeBasedLeaderboardScore } from './TimeBasedLeaderboardScore';
export class Leaderboard {
private leaderboardConfigurator: AbstractLeaderboardScore;
private readonly _timebasedLeaderboard: AbstractLeaderboardScore = new TimeBasedLeaderboardScore;
private readonly _pointbasedLeaderboard: AbstractLeaderboardScore = new PointBasedLeaderboardScore;
private readonly _defaultLeaderboard: AbstractLeaderboardScore;
constructor() {
switch (staticStatistics.leaderboardAlgorithm) {
case LeaderboardConfiguration.TimeBased:
this.leaderboardConfigurator = new TimeBasedLeaderboardScore();
this._defaultLeaderboard = this._timebasedLeaderboard;
break;
case LeaderboardConfiguration.PointBased:
this.leaderboardConfigurator = new PointBasedLeaderboardScore();
this._defaultLeaderboard = this._pointbasedLeaderboard;
break;
default:
}
}
......@@ -63,6 +67,15 @@ export class Leaderboard {
}
public buildLeaderboard(activeQuiz: IQuizEntity, questionIndex: number): any {
let scoringLeaderboard: AbstractLeaderboardScore;
if (activeQuiz.sessionConfig.leaderboardAlgorithm === LeaderboardConfiguration.TimeBased) {
scoringLeaderboard = this._timebasedLeaderboard;
} else if (activeQuiz.sessionConfig.leaderboardAlgorithm === LeaderboardConfiguration.PointBased) {
scoringLeaderboard = this._pointbasedLeaderboard;
} else {
scoringLeaderboard = this._defaultLeaderboard;
}
const questionAmount: number = activeQuiz.questionList.length;
const endIndex: number = isNaN(questionIndex) || questionIndex < 0 || questionIndex > questionAmount ? questionAmount : questionIndex + 1;
......@@ -98,7 +111,7 @@ export class Leaderboard {
correctResponses[attendee.name].correctQuestions.push(i);
correctResponses[attendee.name].confidenceValue += <number>attendee.responses[i].confidence;
correctResponses[attendee.name].responseTime += <number>attendee.responses[i].responseTime;
correctResponses[attendee.name].score += this.leaderboardConfigurator.getScoreForCorrect(attendee.responses[i].responseTime);
correctResponses[attendee.name].score += scoringLeaderboard.getScoreForCorrect(attendee.responses[i].responseTime);
memberGroupResults[memberGroup.name].correctQuestions.push(i);
memberGroupResults[memberGroup.name].responseTime += <number>attendee.responses[i].responseTime;
......@@ -116,8 +129,7 @@ export class Leaderboard {
partiallyCorrectResponses[attendee.name].correctQuestions.push(i);
partiallyCorrectResponses[attendee.name].confidenceValue += <number>attendee.responses[i].confidence;
partiallyCorrectResponses[attendee.name].responseTime += <number>attendee.responses[i].responseTime;
partiallyCorrectResponses[attendee.name].score += this.leaderboardConfigurator.getScoreForPartiallyCorrect(
attendee.responses[i].responseTime);
partiallyCorrectResponses[attendee.name].score += scoringLeaderboard.getScoreForPartiallyCorrect(attendee.responses[i].responseTime);
} else {
......@@ -130,7 +142,7 @@ export class Leaderboard {
});
if (orderByGroups) {
this.leaderboardConfigurator.getScoreForGroup({
scoringLeaderboard.getScoreForGroup({
memberGroupResults,
correctResponses,
partiallyCorrectResponses,
......
import { prop, Typegoose } from 'typegoose';
import { LeaderboardConfiguration } from '../../enums/LeaderboardConfiguration';
import { ISessionConfigurationSerialized } from '../../interfaces/session_configuration/ISessionConfigurationSerialized';
import { MusicSessionConfigurationModelItem } from './MusicSessionConfigurationModelItem';
import { NickSessionConfigurationModelItem } from './NickSessionConfigurationModelItem';
......@@ -10,4 +11,5 @@ export class SessionConfigurationModelItem extends Typegoose implements ISession
@prop() public readingConfirmationEnabled: boolean;
@prop() public showResponseProgress: boolean;
@prop() public theme: string;
@prop({ enum: LeaderboardConfiguration }) public leaderboardAlgorithm: LeaderboardConfiguration;
}
......@@ -4,6 +4,7 @@ import { DefaultAnswerEntity } from '../entities/answer/DefaultAnswerEntity';
import { SingleChoiceQuestionEntity } from '../entities/question/SingleChoiceQuestionEntity';
import { QuizEntity } from '../entities/quiz/QuizEntity';
import { SessionConfigurationEntity } from '../entities/session-configuration/SessionConfigurationEntity';
import { LeaderboardConfiguration } from '../enums/LeaderboardConfiguration';
export class LoadTester {
private static readonly QUIZ_AMOUNT = 1000;
......@@ -61,6 +62,7 @@ export class LoadTester {
adminToken: 'test',
privateKey: 'test',
sessionConfig: new SessionConfigurationEntity({
leaderboardAlgorithm: LeaderboardConfiguration.TimeBased,
music: {
enabled: {
lobby: true,
......
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