diff --git a/src/controllers/PostsController.ts b/src/controllers/PostsController.ts index 251a316..fcb7948 100644 --- a/src/controllers/PostsController.ts +++ b/src/controllers/PostsController.ts @@ -267,7 +267,8 @@ export class PostsController { survey = new NewSurvey({ question: h.postString("question"), userID: h.getUserId(), - choices: h.postString("answers").split("<>") + choices: h.postString("answers").split("<>"), + allowNewChoices: h.postBool("allowNewAnswers", false), }) if(survey.choices.length < 2) diff --git a/src/entities/NewSurvey.ts b/src/entities/NewSurvey.ts index c8e840e..489b01f 100644 --- a/src/entities/NewSurvey.ts +++ b/src/entities/NewSurvey.ts @@ -8,7 +8,8 @@ export interface NewSurveyBuilder { postID?: number, userID: number, question: string, - choices: Array + choices: Array, + allowNewChoices: boolean } export class NewSurvey implements NewSurveyBuilder { @@ -16,6 +17,7 @@ export class NewSurvey implements NewSurveyBuilder { userID: number; question: string; choices: string[]; + allowNewChoices: boolean; public constructor(info: NewSurveyBuilder) { for (const key in info) { diff --git a/src/helpers/SurveyHelper.ts b/src/helpers/SurveyHelper.ts index c674fa3..257e391 100644 --- a/src/helpers/SurveyHelper.ts +++ b/src/helpers/SurveyHelper.ts @@ -42,7 +42,8 @@ export class SurveyHelper { ID_utilisateurs: survey.userID, ID_texte: survey.postID, date_creation: mysql_date(), - question: survey.question + question: survey.question, + allow_new_choices: survey.allowNewChoices ? 1 : 0, }) // Process choices