Skip to content
Snippets Groups Projects
Commit 315b2002 authored by D3B1RUM4N's avatar D3B1RUM4N
Browse files

fix: create a quiz

parent bf843774
1 merge request!52Fix/53 last min fixes
Pipeline #303728 passed with stages
in 1 minute and 6 seconds
......@@ -3,6 +3,7 @@ import { FormQuizService } from '../../../../services/form-quiz.service';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { MatDialogRef } from '@angular/material/dialog';
import { QuestionService } from '../../../../services/question.service';
@Component({
selector: 'app-form-create-quiz',
......@@ -17,7 +18,7 @@ export class FormCreateQuizComponent implements OnInit {
difficultyCtrl: any;
form: any;
constructor(private formQuizService: FormQuizService, private fb: FormBuilder, private router: Router) { }
constructor(private questionService: QuestionService, private formQuizService: FormQuizService, private fb: FormBuilder, private router: Router) { }
categories: { id: number; name: string }[] = [];
ngOnInit(): void {
this.categoryCtrl = this.fb.control(null, []);
......@@ -39,11 +40,16 @@ export class FormCreateQuizComponent implements OnInit {
submitForm(): void {
if (this.form?.valid) {
this.router.navigate(['/play-quiz'], {
queryParams: {
category: this.form.value.category,
nbQuestions: this.form.value.nbQuestion,
difficulty: this.form.value.difficulty,
this.formQuizService.getCategory().subscribe({
next: (data: any) => {
const categories = this.form.value.category;
const difficulty = this.form.value.difficulty;
const NbQuestion = this.form.value.nbQuestion;
this.questionService.createQuiz(NbQuestion, categories.id, difficulty).subscribe({
next: (data: any) => {
this.router.navigate(['/play-quiz'], { queryParams: { idQuiz: data.id } });
},
});
},
});
}
......
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