From 2745617a509a4751caff60885594ffb8f5df9926 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Victor=20L=C3=B6fgren?= <viclo211@student.liu.se>
Date: Tue, 8 Jun 2021 12:49:12 +0200
Subject: [PATCH] Fix problem with multiple and single choice questions

---
 .../components/answerComponents/AnswerMultiple.tsx            | 2 +-
 .../components/answerComponents/AnswerSingle.tsx              | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx
index d95c7355..ac59cc7f 100644
--- a/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx
+++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx
@@ -53,7 +53,7 @@ const AnswerMultiple = ({ variant, activeSlide, competitionId }: AnswerMultipleP
     }
     const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}`
     const payload = {
-      answer: checked ? 1 : 0,
+      answer: checked ? '1' : '0',
     }
     await axios
       .put(url, payload)
diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx
index 901e37c3..13c40a29 100644
--- a/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx
+++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx
@@ -58,12 +58,12 @@ const AnswerSingle = ({ variant, activeSlide, competitionId }: AnswerSingleProps
     const alternatives = activeSlide.questions[0].alternatives
     for (const alt of alternatives) {
       const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alt.id}`
-      await axios.put(url, { answer: 0 })
+      await axios.put(url, { answer: '0' })
     }
     // Update selected alternative
     const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}`
     await axios
-      .put(url, { answer: 1 })
+      .put(url, { answer: '1' })
       .then(() => {
         if (variant === 'editor') {
           dispatch(getEditorCompetition(competitionId))
-- 
GitLab