From 9c864528b88abd374ab35ecbc3d739839e508358 Mon Sep 17 00:00:00 2001
From: Mehdi Benouhoud <mehdi.benouhoud@polymtl.ca>
Date: Thu, 8 Feb 2024 15:48:15 -0500
Subject: [PATCH 1/3] added addQuiz if update returns 404

---
 .../pages/creating-quiz-page/creating-quiz-page.component.ts  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
index 3b23d164..7786270d 100644
--- a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
+++ b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
@@ -67,6 +67,10 @@ export class CreatingQuizPageComponent implements OnInit {
                 this.router.navigate(['/admin']);
             },
             error: (response) => {
+                if (response.status === 404) {
+                    this.addQuiz();
+                    return;
+                }
                 const message = String(response.error.message);
                 this.snackbar.open(`Erreur lors de la mise à jour du quiz : \n${message.replace(/,/g, '\n')}`, 'Fermer');
             },
-- 
GitLab


From a40a613f0265dac093342fe1cf5c482f8b41ece4 Mon Sep 17 00:00:00 2001
From: Mehdi Benouhoud <mehdi.benouhoud@polymtl.ca>
Date: Thu, 8 Feb 2024 15:55:50 -0500
Subject: [PATCH 2/3] solved lint

---
 client/src/app/constants/quiz-creation.constants.ts           | 2 ++
 .../pages/creating-quiz-page/creating-quiz-page.component.ts  | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/src/app/constants/quiz-creation.constants.ts b/client/src/app/constants/quiz-creation.constants.ts
index e3a8eab6..d8fea6ea 100644
--- a/client/src/app/constants/quiz-creation.constants.ts
+++ b/client/src/app/constants/quiz-creation.constants.ts
@@ -1,5 +1,7 @@
 import { QuestionType } from '@common/question';
 
+export const NOT_FOUND = 404;
+
 export const MAX_NUMBER_OF_CHOICES = 4;
 export const MIN_NUMBER_OF_CHOICES = 2;
 
diff --git a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
index 7786270d..a87bcbed 100644
--- a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
+++ b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
 import { GameCreationSettingsComponent } from '@app/components/game-creation-settings/game-creation-settings.component';
 import { PreviewQuestionAreaComponent } from '@app/components/preview-question-area/preview-question-area.component';
 import { SidebarComponent } from '@app/components/sidebar/sidebar.component';
-import { DEFAULT_QUIZ, DELETE_CONFIRMATION_DURATION_MS } from '@app/constants/quiz-creation.constants';
+import { DEFAULT_QUIZ, DELETE_CONFIRMATION_DURATION_MS, NOT_FOUND } from '@app/constants/quiz-creation.constants';
 import { CommunicationService } from '@app/services/communication.service';
 import { UtilService } from '@app/services/util/util.service';
 import { CreateQuiz } from '@common/quiz';
@@ -67,7 +67,7 @@ export class CreatingQuizPageComponent implements OnInit {
                 this.router.navigate(['/admin']);
             },
             error: (response) => {
-                if (response.status === 404) {
+                if (response.status === NOT_FOUND) {
                     this.addQuiz();
                     return;
                 }
-- 
GitLab


From e759ed61a1981d971fb2b7e291db7403eb2eb0a0 Mon Sep 17 00:00:00 2001
From: Mehdi Benouhoud <mehdi.benouhoud@polymtl.ca>
Date: Thu, 8 Feb 2024 16:21:53 -0500
Subject: [PATCH 3/3] solved connerie

---
 client/src/app/constants/quiz-creation.constants.ts          | 2 --
 .../pages/creating-quiz-page/creating-quiz-page.component.ts | 5 +++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/client/src/app/constants/quiz-creation.constants.ts b/client/src/app/constants/quiz-creation.constants.ts
index d8fea6ea..e3a8eab6 100644
--- a/client/src/app/constants/quiz-creation.constants.ts
+++ b/client/src/app/constants/quiz-creation.constants.ts
@@ -1,7 +1,5 @@
 import { QuestionType } from '@common/question';
 
-export const NOT_FOUND = 404;
-
 export const MAX_NUMBER_OF_CHOICES = 4;
 export const MIN_NUMBER_OF_CHOICES = 2;
 
diff --git a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
index a87bcbed..1361352a 100644
--- a/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
+++ b/client/src/app/pages/creating-quiz-page/creating-quiz-page.component.ts
@@ -1,3 +1,4 @@
+import { HttpStatusCode } from '@angular/common/http';
 import { Component, OnInit } from '@angular/core';
 import { MatButtonModule } from '@angular/material/button';
 import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
@@ -5,7 +6,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
 import { GameCreationSettingsComponent } from '@app/components/game-creation-settings/game-creation-settings.component';
 import { PreviewQuestionAreaComponent } from '@app/components/preview-question-area/preview-question-area.component';
 import { SidebarComponent } from '@app/components/sidebar/sidebar.component';
-import { DEFAULT_QUIZ, DELETE_CONFIRMATION_DURATION_MS, NOT_FOUND } from '@app/constants/quiz-creation.constants';
+import { DEFAULT_QUIZ, DELETE_CONFIRMATION_DURATION_MS } from '@app/constants/quiz-creation.constants';
 import { CommunicationService } from '@app/services/communication.service';
 import { UtilService } from '@app/services/util/util.service';
 import { CreateQuiz } from '@common/quiz';
@@ -67,7 +68,7 @@ export class CreatingQuizPageComponent implements OnInit {
                 this.router.navigate(['/admin']);
             },
             error: (response) => {
-                if (response.status === NOT_FOUND) {
+                if (response.status === HttpStatusCode.NotFound) {
                     this.addQuiz();
                     return;
                 }
-- 
GitLab