Fixes a bunch of errors

parent b043e7dd
Pipeline #16242 failed with stages
in 1 minute and 36 seconds
......@@ -35,7 +35,9 @@ export class AdditionalDataComponent {
private trackingService: TrackingService,
) {
this.questionGroupItem = activeQuestionGroupService.activeQuestionGroup;
this._quizUrl = encodeURI(`${document.location.origin}/quiz/${this.questionGroupItem.hashtag}`);
if (this.questionGroupItem) {
this._quizUrl = encodeURI(`${document.location.origin}/quiz/${this.questionGroupItem.hashtag}`);
}
}
public switchShowMoreOrLess(): void {
......
......@@ -9,6 +9,7 @@ import { questionGroupReflection } from 'arsnova-click-v2-types/src/questions/qu
import { DefaultSettings } from '../../../lib/default.settings';
import { ActiveQuestionGroupService } from '../../service/active-question-group/active-question-group.service';
import { CurrentQuizService } from '../../service/current-quiz/current-quiz.service';
import { FileUploadService } from '../../service/file-upload/file-upload.service';
import { TrackingService } from '../../service/tracking/tracking.service';
@Component({
......@@ -33,6 +34,7 @@ export class AvailableQuizzesComponent implements OnInit, IModal {
private currentQuizService: CurrentQuizService,
private activeQuestionGroupService: ActiveQuestionGroupService,
private trackingService: TrackingService,
private fileUploadService: FileUploadService,
) {
const sessions = JSON.parse(window.localStorage.getItem('config.owned_quizzes')) || [];
sessions.sort((a, b) => a > b);
......@@ -69,6 +71,15 @@ export class AvailableQuizzesComponent implements OnInit, IModal {
quizName: session.hashtag,
privateKey: window.localStorage.getItem('config.private_key'),
}).toPromise();
} else if (quizStatusData.step === 'QUIZ:AVAILABLE') {
const blob = new Blob([JSON.stringify(session.serialize())], { type: 'application/json' });
this.fileUploadService.renameFilesQueue.set('uploadFiles[]', blob, session.hashtag);
this.fileUploadService.uploadFile(this.fileUploadService.renameFilesQueue);
this.next();
resolve();
return;
}
if (!session.isValid()) {
......
......@@ -136,7 +136,6 @@ export class QuizLobbyComponent implements OnDestroy {
this.footerBarService.footerElemEditQuiz,
this.footerBarService.footerElemStartQuiz,
this.footerBarService.footerElemProductTour,
this.footerBarService.footerElemSound,
this.footerBarService.footerElemReadingConfirmation,
this.footerBarService.footerElemTheme,
this.footerBarService.footerElemFullscreen,
......@@ -156,7 +155,7 @@ export class QuizLobbyComponent implements OnDestroy {
return;
}
const target = this.currentQuizService.quiz.sessionConfig.readingConfirmationEnabled ?
'reading-confirmation' : 'start';
'reading-confirmation' : 'start';
this.http.post(`${DefaultSettings.httpApiEndpoint}/quiz/${target}`, {
quizName: this.currentQuizService.quiz.hashtag,
}).subscribe((data: IMessage) => {
......
......@@ -118,8 +118,8 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
});
const hasConfidenceSet = typeof this.currentQuizService.quiz.sessionConfig.confidenceSliderEnabled !== 'undefined';
const isConfidenceEnabled = typeof hasConfidenceSet ?
this.currentQuizService.quiz.sessionConfig.confidenceSliderEnabled :
false;
this.currentQuizService.quiz.sessionConfig.confidenceSliderEnabled :
false;
return hasConfidenceSet ? matches.length > 0 || isConfidenceEnabled : matches.length > 0;
}
......@@ -154,7 +154,7 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
return value.responses[questionIndex] ? value.responses[questionIndex].readingConfirmation : false;
}).length;
const isReadingConfirmationEnabled = typeof this.currentQuizService.quiz.sessionConfig.readingConfirmationEnabled === 'undefined' ?
false : this.currentQuizService.quiz.sessionConfig.readingConfirmationEnabled;
false : this.currentQuizService.quiz.sessionConfig.readingConfirmationEnabled;
return matchCount > 0 || isReadingConfirmationEnabled;
}
......@@ -232,7 +232,6 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
this.footerBarService.footerElemConfidenceSlider,
this.footerBarService.footerElemResponseProgress,
this.footerBarService.footerElemFullscreen,
this.footerBarService.footerElemSound,
];
}
this.footerBarService.footerElemBack.onClickCallback = async () => {
......@@ -275,8 +274,8 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
this.attendeeService.modifyResponse(data.payload.nickname);
if (this.attendeeService.attendees.filter(attendee => {
return attendee.responses[this.currentQuizService.questionIndex] ?
attendee.responses[this.currentQuizService.questionIndex].value :
false;
attendee.responses[this.currentQuizService.questionIndex].value :
false;
}).length === this.attendeeService.attendees.length && this.countdown) {
this.countdown.stop();
}
......@@ -321,8 +320,8 @@ export class QuizResultsComponent implements OnInit, OnDestroy {
private async startQuiz(): Promise<void> {
const target = this.currentQuizService.quiz.sessionConfig.readingConfirmationEnabled &&
!this.currentQuizService.readingConfirmationRequested ?
'reading-confirmation' : 'start';
!this.currentQuizService.readingConfirmationRequested ?
'reading-confirmation' : 'start';
const startQuizData = await this.http.post<IMessage>(`${DefaultSettings.httpApiEndpoint}/quiz/${target}`, {
quizName: this.currentQuizService.quiz.hashtag,
......
......@@ -30,24 +30,15 @@ export class QuizJoinComponent implements OnInit {
) {
}
public ngOnInit(): Observable<void> {
return new Observable(subscriber => {
(async () => {
const queryParams = await this.route.queryParams.toPromise();
if (queryParams && queryParams.ticket) {
this.casService.ticket = queryParams.ticket;
}
const params = await this.route.params.toPromise();
const quizname = params.quizName;
this.queryQuizStatus(quizname).subscribe(quizStatusData => this.resolveQuizStatusData(quizStatusData, quizname));
return;
})().then(() => subscriber.next());
},
);
public ngOnInit(): void {
this.route.queryParams.subscribe(queryParams => {
this.casService.ticket = queryParams.ticket;
});
this.route.params.subscribe(params => {
const quizname = params.quizName;
this.queryQuizStatus(quizname).subscribe(quizStatusData => this.resolveQuizStatusData(quizStatusData, quizname));
});
}
private queryQuizStatus(quizname): Observable<IMessage> {
......
......@@ -6,8 +6,9 @@
[title]="'component.nickname_categories.filter' | translate"
(input)="filterForKeyword($event)"/>
</div>
<div class="col-12 col-md-6 nickCategoryWrapper"
[class.col-sm-4]="hasSelectedCategory()">
<div class="col-12 nickCategoryWrapper"
[class.col-sm-4]="hasSelectedCategory()"
[class.col-md-6]="hasSelectedCategory()">
<div class="row">
<div *ngFor="let cat of availableNickCategories()"
class="nickCategory pointer col-6"
......@@ -25,15 +26,17 @@
</div>
</div>
<div *ngIf="hasSelectedCategory()"
class="col-12 col-md-8">
class="col-12 col-sm-8 col-md-6">
<div class="nickNameWrapper pt-2 mt-2 mt-sm-0">
<button class="btn btn-block pointer"
[class.btn-warning]="hasSelectedAllNicks()"
[class.btn-success]="!hasSelectedAllNicks()"
(click)="toggleAllNicks()">
<span *ngIf="hasSelectedAllNicks()">{{'component.nickname_categories.remove_all' | translate}}</span>
<span *ngIf="!hasSelectedAllNicks()">{{'component.nickname_categories.choose_all' | translate}}</span>
</button>
<div class="mx-2">
<button class="btn btn-block pointer"
[class.btn-warning]="hasSelectedAllNicks()"
[class.btn-success]="!hasSelectedAllNicks()"
(click)="toggleAllNicks()">
<span *ngIf="hasSelectedAllNicks()">{{'component.nickname_categories.remove_all' | translate}}</span>
<span *ngIf="!hasSelectedAllNicks()">{{'component.nickname_categories.choose_all' | translate}}</span>
</button>
</div>
<div *ngFor="let nick of availableNicks[selectedCategory]"
(click)="selectNick(nick)"
class="nickStyle nickName pointer"
......
......@@ -96,7 +96,10 @@ export class NicknameManagerComponent implements OnInit, OnDestroy {
this.activeQuestionGroupService.activeQuestionGroup.sessionConfig.nicks.toggleSelectedNick(name.toString());
}
public parseAvailableNick(name: string): SafeHtml {
public parseAvailableNick(name: any): SafeHtml {
if (this.selectedCategory === 'emojis') {
name = name.changingThisBreaksApplicationSecurity.match(/:[\w\+\-]+:/g)[0];
}
return name.match(/:[\w\+\-]+:/g) ? this.sanitizeHTML(parseGithubFlavoredMarkdown(name)) : name;
}
......
......@@ -52,6 +52,7 @@ export class QuizManagerComponent implements OnDestroy {
this.footerBarService.footerElemProductTour,
this.footerBarService.footerElemNicknames,
this.footerBarService.footerElemMemberGroup,
this.footerBarService.footerElemSound,
]);
this.footerBarService.footerElemStartQuiz.isActive = activeQuestionGroupService.activeQuestionGroup.isValid();
......
......@@ -4,7 +4,7 @@ import { TranslateService } from '@ngx-translate/core';
import { ISong } from 'arsnova-click-v2-types/src/common';
import { IMusicSessionConfiguration } from 'arsnova-click-v2-types/src/session_configuration/interfaces';
import { DefaultSettings } from '../../../../lib/default.settings';
import { CurrentQuizService } from '../../../service/current-quiz/current-quiz.service';
import { ActiveQuestionGroupService } from '../../../service/active-question-group/active-question-group.service';
import { FooterBarService } from '../../../service/footer-bar/footer-bar.service';
@Component({
......@@ -44,7 +44,7 @@ export class SoundManagerComponent implements OnDestroy {
@Inject(PLATFORM_ID) private platformId: Object,
private translateService: TranslateService,
private footerBarService: FooterBarService,
private currentQuizService: CurrentQuizService,
private activeQuestionGroupService: ActiveQuestionGroupService,
) {
this.footerBarService.TYPE_REFERENCE = SoundManagerComponent.TYPE;
......@@ -52,7 +52,7 @@ export class SoundManagerComponent implements OnDestroy {
this.footerBarService.footerElemBack,
]);
this._config = this.currentQuizService.quiz.sessionConfig.music;
this._config = this.activeQuestionGroupService.activeQuestionGroup.sessionConfig.music;
this.setRandomKey();
this.setLobbySongs();
......@@ -82,8 +82,8 @@ export class SoundManagerComponent implements OnDestroy {
}
public ngOnDestroy(): void {
this.currentQuizService.quiz.sessionConfig.music = this._config;
this.currentQuizService.persistToSessionStorage();
this.activeQuestionGroupService.activeQuestionGroup.sessionConfig.music = this._config;
this.activeQuestionGroupService.persist();
}
private initConfig(): void {
......
......@@ -19,7 +19,6 @@ export class QuizRenameComponent implements OnInit {
private readonly footerBarService: FooterBarService,
private readonly router: Router,
) {
this.footerBarService.TYPE_REFERENCE = QuizRenameComponent.TYPE;
this.footerBarService.replaceFooterElements([this.footerBarService.footerElemBack]);
}
......
......@@ -169,7 +169,7 @@ export class HomeComponent implements OnInit, OnDestroy {
}
}
public autoJoinToSession(quizname): Observable<any> {
public autoJoinToSession(quizname): Subscription {
return new Observable<void>(subscriber => {
of(this.selectQuizByList(quizname)).subscribe(() => subscriber.complete());
......@@ -185,7 +185,7 @@ export class HomeComponent implements OnInit, OnDestroy {
}
document.getElementById('joinSession').click();
}, 10);
});
}).subscribe();
}
public showQuiznameDatalist(): void {
......
......@@ -36,6 +36,10 @@ export class AttendeeService implements OnDestroy {
}
public getMemberGroups(): Array<string> {
if (!this.currentQuizService.quiz) {
return [];
}
return this.currentQuizService.quiz.sessionConfig.nicks.memberGroups;
}
......
......@@ -26,6 +26,7 @@ export class FileUploadService {
private router: Router,
private activeQuestionGroupService: ActiveQuestionGroupService,
) {
this._renameFilesQueue = new FormData();
}
public uploadFile(formData: FormData): void {
......@@ -51,9 +52,16 @@ export class FileUploadService {
}
const reader = new FileReader();
reader.onload = () => {
const parsedFile = JSON.parse(reader.result);
this.activeQuestionGroupService.activeQuestionGroup = questionGroupReflection[parsedFile.TYPE](parsedFile);
this.activeQuestionGroupService.persist();
window.localStorage.removeItem(file.name);
const questionList = JSON.parse(window.localStorage.getItem('config.owned_quizzes')) || [];
questionList.splice(questionList.indexOf(file.name), 1);
window.localStorage.setItem('config.owned_quizzes', JSON.stringify(questionList));
this.router.navigate(['/']);
};
reader.readAsText(file);
......
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