diff --git a/src/app/modules/home/play-quiz/play-quiz.component.html b/src/app/modules/home/play-quiz/play-quiz.component.html index d2897dada9e4c04ce983cc926e74023f5d643eb0..5fdd8c7228b90579981bca6a28b5118a75a590f9 100644 --- a/src/app/modules/home/play-quiz/play-quiz.component.html +++ b/src/app/modules/home/play-quiz/play-quiz.component.html @@ -1,6 +1,7 @@ <div *ngIf="!isLoading" class="main"> <div class="header"> <mat-icon (click)="goHome()">home</mat-icon> + <p>ID Quiz {{ idQuiz }}</p> <div class="title"> <h4>Question {{ actualQuestionIndex + 1 }}/{{ quiz.questions.length }}</h4> <h5>Score : {{ score }}/{{ quiz.questions.length }}</h5> @@ -13,9 +14,8 @@ </div> <div class="next-question"> <button *ngIf="showNextQuestion" (click)="nextQuestion()" class="btnNext"> - @if (actualQuestionIndex === this.quiz.questionIndex - 1 + this.quiz.questions.length - 1) { Finish quiz - } + @if (actualQuestionIndex === this.quiz.questionIndex - 1 + this.quiz.questions.length - 1) { Finish quiz } @else { Next question } </button> </div> -</div> \ No newline at end of file +</div> diff --git a/src/app/modules/home/play-quiz/play-quiz.component.ts b/src/app/modules/home/play-quiz/play-quiz.component.ts index 71067f09389030b51a29319cfcf2c988eb3c57cc..65d4c37abce20776e4460a9b75df8b92c1c6b1e8 100644 --- a/src/app/modules/home/play-quiz/play-quiz.component.ts +++ b/src/app/modules/home/play-quiz/play-quiz.component.ts @@ -15,9 +15,10 @@ export class PlayQuizComponent implements OnInit { private activatedRoute: ActivatedRoute, private router: Router, private cdr: ChangeDetectorRef - ) { } + ) {} isLoading: boolean = false; quiz: any = []; + idQuiz: any; actualQuestion: any; actualQuestionIndex: number = -1; score: number = 0; @@ -25,8 +26,8 @@ export class PlayQuizComponent implements OnInit { ngOnInit(): void { this.isLoading = true; this.activatedRoute.queryParams.subscribe((params) => { - const idQuiz = params['idQuiz']; - this.questionSerivce.getQuiz(idQuiz).subscribe({ + this.idQuiz = params['idQuiz']; + this.questionSerivce.getQuiz(this.idQuiz).subscribe({ next: (data: any) => { this.quiz = data; this.quiz.Question; @@ -43,7 +44,6 @@ export class PlayQuizComponent implements OnInit { return textArea.value; } - nextQuestion() { if (this.actualQuestionIndex === this.quiz.questionIndex - 1 + this.quiz.questions.length - 1) { Swal.fire({