Fixes bugs in the quiz flow

parent 696bba30
......@@ -17,6 +17,9 @@ import { FileUploadService } from '../../service/file-upload/file-upload.service
import { FooterBarService } from '../../service/footer-bar/footer-bar.service';
import { SettingsService } from '../../service/settings/settings.service';
import { SharedService } from '../../service/shared/shared.service';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../service/websocket/websocket.mock.service';
......@@ -47,7 +50,10 @@ describe('FooterBarComponent', () => {
}),
],
providers: [
FooterBarService, SharedService, {
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, FooterBarService, SharedService, {
provide: CurrentQuizService,
useClass: CurrentQuizMockService,
}, SettingsService, {
......
......@@ -11,6 +11,9 @@ import { FooterBarService } from '../../service/footer-bar/footer-bar.service';
import { HeaderLabelService } from '../../service/header-label/header-label.service';
import { CasLoginService } from '../../service/login/cas-login.service';
import { ModalOrganizerService } from '../../service/modal-organizer/modal-organizer.service';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
import { KeyOutputComponent } from '../key-output/key-output.component';
......@@ -39,7 +42,10 @@ describe('I18nManagerOverviewComponent', () => {
}),
],
providers: [
UserService, CasLoginService, FooterBarService, HeaderLabelService, ModalOrganizerService,
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, UserService, CasLoginService, FooterBarService, HeaderLabelService, ModalOrganizerService,
],
declarations: [KeyOutputComponent, I18nManagerOverviewComponent],
})
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PipesModule } from '../../pipes/pipes.module';
import { CasLoginService } from '../../service/login/cas-login.service';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
......@@ -15,7 +18,10 @@ describe('KeyOutputComponent', () => {
imports: [SharedModule, PipesModule],
declarations: [KeyOutputComponent],
providers: [
CasLoginService, UserService,
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, CasLoginService, UserService,
],
})
.compileComponents();
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NgbActiveModal, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { UserService } from '../../service/user/user.service';
import { SharedModule } from '../../shared/shared.module';
......@@ -15,7 +18,10 @@ describe('AddModeComponent', () => {
SharedModule, NgbModalModule.forRoot(),
],
providers: [
NgbActiveModal, UserService,
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, UserService,
],
declarations: [AddModeComponent],
})
......
......@@ -20,6 +20,9 @@ import { FileUploadService } from '../../service/file-upload/file-upload.service
import { FooterBarService } from '../../service/footer-bar/footer-bar.service';
import { SettingsService } from '../../service/settings/settings.service';
import { SharedService } from '../../service/shared/shared.service';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../service/websocket/websocket.mock.service';
......@@ -50,7 +53,10 @@ describe('AvailableQuizzesComponent', () => {
}),
],
providers: [
NgbActiveModal, LobbyApiService, QuizApiService, {
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, LobbyApiService, QuizApiService, {
provide: TrackingService,
useClass: TrackingMockService,
}, {
......@@ -131,24 +137,20 @@ describe('AvailableQuizzesComponent', () => {
));
it('#editQuiz', (
inject([CurrentQuizService, TrackingService, ActiveQuestionGroupService, Router], (
currentQuizService: CurrentQuizService,
trackingService: TrackingService,
activeQuestionGroupService: ActiveQuestionGroupService,
router: Router,
) => {
const quiz = currentQuizService.quiz;
inject([CurrentQuizService, TrackingService, ActiveQuestionGroupService, Router],
(currentQuizService: CurrentQuizService, trackingService: TrackingService, activeQuestionGroupService: ActiveQuestionGroupService, router: Router) => {
const quiz = currentQuizService.quiz;
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
spyOn(component, 'next').and.callThrough();
spyOn(router, 'navigate').and.callFake(() => {});
spyOn(trackingService, 'trackClickEvent').and.callFake(() => {});
spyOn(component, 'next').and.callThrough();
spyOn(router, 'navigate').and.callFake(() => {});
component.editQuiz(quiz);
component.editQuiz(quiz);
expect(trackingService.trackClickEvent).toHaveBeenCalled();
expect(activeQuestionGroupService.activeQuestionGroup).toEqual(quiz);
expect(router.navigate).toHaveBeenCalled();
expect(component.next).toHaveBeenCalled();
})
expect(trackingService.trackClickEvent).toHaveBeenCalled();
expect(activeQuestionGroupService.activeQuestionGroup).toEqual(quiz);
expect(router.navigate).toHaveBeenCalled();
expect(component.next).toHaveBeenCalled();
})
));
});
......@@ -3,6 +3,7 @@ import { async, TestBed } from '@angular/core/testing';
import { I18nManagerApiService } from '../../service/api/i18n-manager/i18n-manager-api.service';
import { LanguageLoaderService } from '../../service/language-loader/language-loader.service';
import { ProjectLoaderService } from '../../service/project-loader/project-loader.service';
import { IndexedDbService } from '../../service/storage/indexed.db.service';
import { StorageService } from '../../service/storage/storage.service';
import { StorageServiceMock } from '../../service/storage/storage.service.mock';
import { UserService } from '../../service/user/user.service';
......@@ -17,7 +18,7 @@ describe('FilterKeysPipe', () => {
HttpClientTestingModule,
],
providers: [
LanguageLoaderService, I18nManagerApiService, ProjectLoaderService, UserService, {
LanguageLoaderService, I18nManagerApiService, ProjectLoaderService, UserService, IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
},
......
......@@ -16,6 +16,9 @@ import { FooterBarService } from '../../../service/footer-bar/footer-bar.service
import { HeaderLabelService } from '../../../service/header-label/header-label.service';
import { SettingsService } from '../../../service/settings/settings.service';
import { SharedService } from '../../../service/shared/shared.service';
import { IndexedDbService } from '../../../service/storage/indexed.db.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { WebsocketMockService } from '../../../service/websocket/websocket.mock.service';
import { WebsocketService } from '../../../service/websocket/websocket.service';
import { SharedModule } from '../../../shared/shared.module';
......@@ -43,7 +46,10 @@ describe('QuizFlow: ConfidenceRateComponent', () => {
}),
],
providers: [
{
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, {
provide: ConnectionService,
useClass: ConnectionMockService,
}, {
......
......@@ -20,6 +20,9 @@ import { HeaderLabelService } from '../../../service/header-label/header-label.s
import { I18nService } from '../../../service/i18n/i18n.service';
import { SettingsService } from '../../../service/settings/settings.service';
import { SharedService } from '../../../service/shared/shared.service';
import { IndexedDbService } from '../../../service/storage/indexed.db.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../../service/websocket/websocket.mock.service';
......@@ -50,7 +53,10 @@ describe('LeaderboardComponent', () => {
}),
],
providers: [
NgbActiveModal, {
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, {
provide: TrackingService,
useClass: TrackingMockService,
}, {
......
......@@ -78,7 +78,7 @@ export class LeaderboardComponent implements OnInit {
this._leaderBoardCorrect = [];
this._leaderBoardPartiallyCorrect = [];
this.currentQuizService.isOwner.then(value => {
this.currentQuizService.isOwner.subscribe(value => {
if (value) {
this.footerBarService.replaceFooterElements([
this.footerBarService.footerElemBack, this.footerBarService.footerElemFullscreen, this.footerBarService.footerElemExport,
......@@ -136,53 +136,51 @@ export class LeaderboardComponent implements OnInit {
);
}
public async ngOnInit(): Promise<void> {
await this.connectionService.initConnection();
this.connectionService.authorizeWebSocket(this.currentQuizService.quiz.hashtag);
this.handleMessages();
const params = await this.route.params.toPromise();
this._questionIndex = +params['questionIndex'];
this._isGlobalRanking = isNaN(this._questionIndex);
if (this._isGlobalRanking) {
this.headerLabelService.headerLabel = 'component.leaderboard.global_header';
this._questionIndex = null;
if (params['questionIndex']) {
this.router.navigate(['/quiz', 'flow', 'leaderboard']);
return;
}
} else {
this.headerLabelService.headerLabel = 'component.leaderboard.header';
const questionType = this.currentQuizService.quiz.questionList[this.questionIndex].TYPE;
this._hasMultipleAnswersAvailable = questionType === 'MultipleChoiceQuestion';
}
const lederboardData = await this.getLeaderboardFromBackend();
this._leaderBoardCorrect = lederboardData.payload.correctResponses;
this._leaderBoardPartiallyCorrect = lederboardData.payload.partiallyCorrectResponses;
this._memberGroupResults = lederboardData.payload.memberGroupResults;
public ngOnInit(): void {
this.connectionService.initConnection().then(() => {
this.connectionService.authorizeWebSocket(this.currentQuizService.quiz.hashtag);
this.handleMessages();
});
this._leaderBoardPartiallyCorrect.forEach(partiallyCorrectLeaderboardElement => {
this._leaderBoardCorrect.forEach((allLeaderboardElements, index) => {
if (partiallyCorrectLeaderboardElement.name === allLeaderboardElements.name) {
this._leaderBoardCorrect.splice(index, 1);
this.route.params.subscribe(params => {
this._questionIndex = +params['questionIndex'];
this._isGlobalRanking = isNaN(this._questionIndex);
if (this._isGlobalRanking) {
this.headerLabelService.headerLabel = 'component.leaderboard.global_header';
this._questionIndex = null;
if (params['questionIndex']) {
this.router.navigate(['/quiz', 'flow', 'leaderboard']);
return;
}
});
});
} else {
this.headerLabelService.headerLabel = 'component.leaderboard.header';
const questionType = this.currentQuizService.quiz.questionList[this.questionIndex].TYPE;
this._hasMultipleAnswersAvailable = questionType === 'MultipleChoiceQuestion';
}
this._memberGroupResults = this._memberGroupResults.filter(memberGroupResult => {
return memberGroupResult.correctQuestions.length > 0;
});
}
this.leaderboardApiService.getLeaderboardData(this._hashtag, this.questionIndex).subscribe(lederboardData => {
this._leaderBoardCorrect = lederboardData.payload.correctResponses;
this._leaderBoardPartiallyCorrect = lederboardData.payload.partiallyCorrectResponses;
this._memberGroupResults = lederboardData.payload.memberGroupResults;
this._leaderBoardPartiallyCorrect.forEach(partiallyCorrectLeaderboardElement => {
this._leaderBoardCorrect.forEach((allLeaderboardElements, index) => {
if (partiallyCorrectLeaderboardElement.name === allLeaderboardElements.name) {
this._leaderBoardCorrect.splice(index, 1);
}
});
});
public async formatResponseTime(responseTime: number): Promise<string> {
return await this.i18nService.formatNumber(this.roundResponseTime(responseTime, 2)).toPromise();
this._memberGroupResults = this._memberGroupResults.filter(memberGroupResult => {
return memberGroupResult.correctQuestions.length > 0;
});
});
}
private async getLeaderboardFromBackend(): Promise<IMessage> {
return this.leaderboardApiService.getLeaderboardData(this._hashtag, this.questionIndex).toPromise();
public formatResponseTime(responseTime: number): string {
return this.i18nService.formatNumber(this.roundResponseTime(responseTime, 2));
}
private handleMessages(): void {
......
......@@ -3,7 +3,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { DomSanitizer } from '@angular/platform-browser';
import { RouterTestingModule } from '@angular/router/testing';
import { NgbActiveModal, NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateCompiler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { NgxQRCodeModule } from '@techiediaries/ngx-qrcode';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
......@@ -23,6 +23,9 @@ import { HeaderLabelService } from '../../../service/header-label/header-label.s
import { I18nService } from '../../../service/i18n/i18n.service';
import { SettingsService } from '../../../service/settings/settings.service';
import { SharedService } from '../../../service/shared/shared.service';
import { IndexedDbService } from '../../../service/storage/indexed.db.service';
import { StorageService } from '../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../service/storage/storage.service.mock';
import { ThemesMockService } from '../../../service/themes/themes.mock.service';
import { ThemesService } from '../../../service/themes/themes.service';
import { TrackingMockService } from '../../../service/tracking/tracking.mock.service';
......@@ -40,16 +43,12 @@ describe('QuizLobbyComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
HttpClientModule,
HttpClientTestingModule,
SharedModule,
NgxQRCodeModule,
NgbModule.forRoot(),
TranslateModule.forRoot({
RouterTestingModule, HttpClientModule, HttpClientTestingModule, SharedModule, NgxQRCodeModule, NgbModule.forRoot(), TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
useFactory: (
createTranslateLoader
),
deps: [HttpClient],
},
compiler: {
......@@ -59,21 +58,31 @@ describe('QuizLobbyComponent', () => {
}),
],
providers: [
NgbActiveModal,
{ provide: TrackingService, useClass: TrackingMockService },
{ provide: CurrentQuizService, useClass: CurrentQuizMockService },
FooterBarService,
SettingsService,
{ provide: ConnectionService, useClass: ConnectionMockService },
{ provide: WebsocketService, useClass: WebsocketMockService },
SharedService,
{ provide: ActiveQuestionGroupService, useClass: ActiveQuestionGroupMockService },
I18nService,
HeaderLabelService,
{ provide: AttendeeService, useClass: AttendeeMockService },
{ provide: ThemesService, useClass: ThemesMockService },
MemberApiService,
QuizApiService,
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbModal, {
provide: TrackingService,
useClass: TrackingMockService,
}, {
provide: CurrentQuizService,
useClass: CurrentQuizMockService,
}, FooterBarService, SettingsService, {
provide: ConnectionService,
useClass: ConnectionMockService,
}, {
provide: WebsocketService,
useClass: WebsocketMockService,
}, SharedService, {
provide: ActiveQuestionGroupService,
useClass: ActiveQuestionGroupMockService,
}, I18nService, HeaderLabelService, {
provide: AttendeeService,
useClass: AttendeeMockService,
}, {
provide: ThemesService,
useClass: ThemesMockService,
}, MemberApiService, QuizApiService,
],
declarations: [QuizLobbyComponent],
}).compileComponents();
......@@ -101,29 +110,50 @@ describe('QuizLobbyComponent', () => {
component.openKickMemberModal(modalContent, nickToRemove);
expect(modalService.open).toHaveBeenCalled();
expect(component['_kickMemberModalRef']).not.toBeNull();
}));
it('#kickMember', inject([CurrentQuizService], (currentQuizService: CurrentQuizService) => {
it('#kickMember', inject([NgbModal], (modalService: NgbModal) => {
const modalContent = '<div></div>';
const nickToRemove = 'TestNick';
spyOn(modalService, 'open').and.callFake(() => {});
spyOn(component, 'kickMember').and.callThrough();
component.openKickMemberModal(modalContent, nickToRemove);
((async () => await component.kickMember(nickToRemove))());
(
(
async () => await component.kickMember(nickToRemove)
)()
);
expect(component.kickMember).toHaveBeenCalled();
}));
it('#hexToRgb', () => {
expect(component.hexToRgb('#ffffff')).toEqual({ r: 255, g: 255, b: 255 });
expect(component.hexToRgb('#000000')).toEqual({ r: 0, g: 0, b: 0 });
expect(component.hexToRgb('#ffffff')).toEqual({
r: 255,
g: 255,
b: 255,
});
expect(component.hexToRgb('#000000')).toEqual({
r: 0,
g: 0,
b: 0,
});
});
it('#transformForegroundColor', () => {
expect(component.transformForegroundColor({ r: 0, g: 0, b: 0 })).toEqual('ffffff');
expect(component.transformForegroundColor({ r: 255, g: 255, b: 255 })).toEqual('000000');
expect(component.transformForegroundColor({
r: 0,
g: 0,
b: 0,
})).toEqual('ffffff');
expect(component.transformForegroundColor({
r: 255,
g: 255,
b: 255,
})).toEqual('000000');
});
it('#sanitizeHTML', inject([DomSanitizer], (sanitizer: DomSanitizer) => {
......
......@@ -80,7 +80,9 @@ export class QuizLobbyComponent implements OnDestroy {
(
async () => {
this._ownsQuiz = await this.currentQuizService.isOwner;
this._ownsQuiz = !!(
await this.currentQuizService.isOwner.toPromise()
);
await this.connectionService.initConnection();
if (this._ownsQuiz) {
this.trackingService.trackConversionEvent({ action: QuizLobbyComponent.TYPE });
......
......@@ -20,6 +20,9 @@ import { HeaderLabelService } from '../../../../service/header-label/header-labe
import { I18nService } from '../../../../service/i18n/i18n.service';
import { SettingsService } from '../../../../service/settings/settings.service';
import { SharedService } from '../../../../service/shared/shared.service';
import { IndexedDbService } from '../../../../service/storage/indexed.db.service';
import { StorageService } from '../../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../../../service/websocket/websocket.mock.service';
......@@ -50,7 +53,10 @@ describe('QuizResults: ConfidenceRateComponent', () => {
}),
],
providers: [
NgbActiveModal, {
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, {
provide: TrackingService,
useClass: TrackingMockService,
}, {
......
......@@ -2,7 +2,6 @@ import { Component, Input } from '@angular/core';
import { DomSanitizer, SafeStyle } from '@angular/platform-browser';
import { parseGithubFlavoredMarkdown } from '../../../../../lib/markdown/markdown';
import { I18nService } from '../../../../service/i18n/i18n.service';
import { NUMBER_TYPE } from '../../../../shared/enums';
@Component({
selector: 'app-confidence-rate',
......@@ -36,7 +35,7 @@ export class ConfidenceRateComponent {
@Input() set data(value: any) {
this._data = value;
this.i18nService.formatNumber(value.percent, NUMBER_TYPE.PERCENT).toPromise().then(val => this.percent = val);
this.percent = value.percent;
this.base = value.base;
this.absolute = value.absolute;
}
......
......@@ -6,6 +6,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateCompiler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { IQuestionChoice } from 'arsnova-click-v2-types/src/questions/interfaces';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
import { Attendee } from '../../../../../lib/attendee/attendee';
import { createTranslateLoader } from '../../../../../lib/translation.factory';
import { ActiveQuestionGroupMockService } from '../../../../service/active-question-group/active-question-group.mock.service';
import { ActiveQuestionGroupService } from '../../../../service/active-question-group/active-question-group.service';
......@@ -21,6 +22,9 @@ import { I18nService } from '../../../../service/i18n/i18n.service';
import { QuestionTextService } from '../../../../service/question-text/question-text.service';
import { SettingsService } from '../../../../service/settings/settings.service';
import { SharedService } from '../../../../service/shared/shared.service';
import { IndexedDbService } from '../../../../service/storage/indexed.db.service';
import { StorageService } from '../../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../../../service/websocket/websocket.mock.service';
......@@ -56,7 +60,10 @@ describe('ProgressBarComponent', () => {
}),
],
providers: [
NgbActiveModal, {
IndexedDbService, {
provide: StorageService,
useClass: StorageServiceMock,
}, NgbActiveModal, {
provide: TrackingService,
useClass: TrackingMockService,
}, {
......@@ -108,6 +115,15 @@ describe('ProgressBarComponent', () => {
(currentQuizService: CurrentQuizService, attendeeService: AttendeeService, questionTextService: QuestionTextService) => {
component.questionIndex = 0;
const question = <IQuestionChoice>currentQuizService.quiz.questionList[component.questionIndex];
attendeeService.addMember(new Attendee({
id: 0,
name: 'testNickname',
groupName: 'Default',
colorCode: '#00000',
responses: [],
}));
questionTextService.changeMultiple(question.answerOptionList.map(answer => answer.answerText));
questionTextService.eventEmitter.subscribe((value) => {
if (value instanceof Array) {
......
......@@ -61,12 +61,21 @@ export class ProgressBarComponent {
if (typeof value.responses[this.questionIndex] === 'undefined') {
return false;
}
const responseValue = value.responses[this.questionIndex].value;
return responseValue === answerIndex || (
responseValue instanceof Array && (
<Array<number>>responseValue
).indexOf(answerIndex) > -1
);
const responseValue: any = value.responses[this.questionIndex].value;
if (responseValue instanceof Array) {
if (isNaN(responseValue[0])) {
return (
<any>responseValue.indexOf(question.answerOptionList[answerIndex].answerText)
) > -1;
} else {
return (
<any>responseValue.indexOf(answerIndex)
) > -1;
}
} else {
return responseValue === answerIndex;
}
});
if (answerIndex > question.answerOptionList.length - 1) {
// Race condition with the Mathjax / Markdown parsing in the quiz results component
......@@ -75,7 +84,7 @@ export class ProgressBarComponent {
result.isCorrect = question.answerOptionList[answerIndex].isCorrect ? 1 : -1;
}
result.absolute = matches.length;
result.percent = await this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT).toPromise();
result.percent = this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT);
}
private async updateResultSetForRangedQuestions(result, question): Promise<void> {
......@@ -98,7 +107,7 @@ export class ProgressBarComponent {
result.isCorrect = result.label === 'guessed_correct' ? 1 : result.label === 'guessed_in_range' ? 0 : -1;
result.label = this.translate.instant(`component.liveResults.${result.label}`);
result.absolute = matches.length;
result.percent = await this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT).toPromise();
result.percent = this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT);
}
private async updateResultSetForFreetextQuestions(result, question): Promise<void> {
......@@ -120,6 +129,6 @@ export class ProgressBarComponent {
result.isCorrect = result.label === 'correct_answer' ? 1 : -1;
result.label = this.translate.instant(`component.liveResults.${result.label}`);
result.absolute = matches.length;
result.percent = await this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT).toPromise();
result.percent = this.i18nService.formatNumber(matches.length / this.attendeeService.attendees.length, NUMBER_TYPE.PERCENT);
}
}
......@@ -7,6 +7,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateCompiler, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateMessageFormatCompiler } from 'ngx-translate-messageformat-compiler';
import { Observable } from 'rxjs';
import { createTranslateLoader } from '../../../../../lib/translation.factory';
import { ActiveQuestionGroupMockService } from '../../../../service/active-question-group/active-question-group.mock.service';
import { ActiveQuestionGroupService } from '../../../../service/active-question-group/active-question-group.service';
......@@ -22,6 +23,9 @@ import { I18nService } from '../../../../service/i18n/i18n.service';
import { QuestionTextService } from '../../../../service/question-text/question-text.service';
import { SettingsService } from '../../../../service/settings/settings.service';
import { SharedService } from '../../../../service/shared/shared.service';
import { IndexedDbService } from '../../../../service/storage/indexed.db.service';
import { StorageService } from '../../../../service/storage/storage.service';
import { StorageServiceMock } from '../../../../service/storage/storage.service.mock';
import { TrackingMockService } from '../../../../service/tracking/tracking.mock.service';
import { TrackingService } from '../../../../service/tracking/tracking.service';
import { WebsocketMockService } from '../../../../service/websocket/websocket.mock.service';
......@@ -37,6 +41,11 @@ class MockRouter {
questionIndex: 0,
};
},
subscribe: () => {
return new Observable(subscriber => subscriber.next({
questionIndex: 0,
}));