Skip to content
Snippets Groups Projects
Commit 2244bbe8 authored by HUSS THEOPHILE's avatar HUSS THEOPHILE
Browse files

feat: Add idQuiz on play-quiz page

parent efd692db
Branches
1 merge request!56style: fix css in profile
Pipeline #304162 failed with stages
in 10 seconds
<div *ngIf="!isLoading" class="main"> <div *ngIf="!isLoading" class="main">
<div class="header"> <div class="header">
<mat-icon (click)="goHome()">home</mat-icon> <mat-icon (click)="goHome()">home</mat-icon>
<p>ID Quiz {{ idQuiz }}</p>
<div class="title"> <div class="title">
<h4>Question {{ actualQuestionIndex + 1 }}/{{ quiz.questions.length }}</h4> <h4>Question {{ actualQuestionIndex + 1 }}/{{ quiz.questions.length }}</h4>
<h5>Score : {{ score }}/{{ quiz.questions.length }}</h5> <h5>Score : {{ score }}/{{ quiz.questions.length }}</h5>
...@@ -13,9 +14,8 @@ ...@@ -13,9 +14,8 @@
</div> </div>
<div class="next-question"> <div class="next-question">
<button *ngIf="showNextQuestion" (click)="nextQuestion()" class="btnNext"> <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 } @else { Next question }
</button> </button>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -15,9 +15,10 @@ export class PlayQuizComponent implements OnInit { ...@@ -15,9 +15,10 @@ export class PlayQuizComponent implements OnInit {
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router, private router: Router,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef
) { } ) {}
isLoading: boolean = false; isLoading: boolean = false;
quiz: any = []; quiz: any = [];
idQuiz: any;
actualQuestion: any; actualQuestion: any;
actualQuestionIndex: number = -1; actualQuestionIndex: number = -1;
score: number = 0; score: number = 0;
...@@ -25,8 +26,8 @@ export class PlayQuizComponent implements OnInit { ...@@ -25,8 +26,8 @@ export class PlayQuizComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.isLoading = true; this.isLoading = true;
this.activatedRoute.queryParams.subscribe((params) => { this.activatedRoute.queryParams.subscribe((params) => {
const idQuiz = params['idQuiz']; this.idQuiz = params['idQuiz'];
this.questionSerivce.getQuiz(idQuiz).subscribe({ this.questionSerivce.getQuiz(this.idQuiz).subscribe({
next: (data: any) => { next: (data: any) => {
this.quiz = data; this.quiz = data;
this.quiz.Question; this.quiz.Question;
...@@ -43,7 +44,6 @@ export class PlayQuizComponent implements OnInit { ...@@ -43,7 +44,6 @@ export class PlayQuizComponent implements OnInit {
return textArea.value; return textArea.value;
} }
nextQuestion() { nextQuestion() {
if (this.actualQuestionIndex === this.quiz.questionIndex - 1 + this.quiz.questions.length - 1) { if (this.actualQuestionIndex === this.quiz.questionIndex - 1 + this.quiz.questions.length - 1) {
Swal.fire({ Swal.fire({
......
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