From d7be6167bd9ce7f97903817ff184f4c9d02bbd36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20L=C3=B6fgren?= <viclo211@student.liu.se> Date: Sun, 23 May 2021 19:01:23 +0200 Subject: [PATCH] Fix answer route --- .../components/answerComponents/AnswerMatch.tsx | 4 ++-- .../components/answerComponents/AnswerMultiple.tsx | 2 +- .../components/answerComponents/AnswerSingle.tsx | 4 ++-- .../components/answerComponents/AnswerText.tsx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerMatch.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerMatch.tsx index 3d854b87..df79a37d 100644 --- a/client/src/pages/presentationEditor/components/answerComponents/AnswerMatch.tsx +++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerMatch.tsx @@ -58,7 +58,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp (alt) => alternative.alternative_order === alt.correct_order ) axios - .put(`/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alternative.id}`, { + .put(`/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}`, { answer: `${alternative.alternative} - ${answer?.correct}`, }) .then(() => { @@ -89,7 +89,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp const answeredText = answersCopy[index].correct if (!activeSlide) return axios - .put(`/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alternative.id}`, { + .put(`/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}`, { answer: `${alternative.alternative} - ${answeredText}`, }) .catch(console.log) diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx index 039d9dfb..d95c7355 100644 --- a/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx +++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerMultiple.tsx @@ -51,7 +51,7 @@ const AnswerMultiple = ({ variant, activeSlide, competitionId }: AnswerMultipleP if (!activeSlide || (activeSlide?.timer !== null && !timer.enabled)) { return } - const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alternative.id}` + const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}` const payload = { answer: checked ? 1 : 0, } diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx index 1ff4b7cf..901e37c3 100644 --- a/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx +++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerSingle.tsx @@ -57,11 +57,11 @@ const AnswerSingle = ({ variant, activeSlide, competitionId }: AnswerSingleProps // Unselect each radio button to only allow one selected alternative const alternatives = activeSlide.questions[0].alternatives for (const alt of alternatives) { - const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alt.id}` + const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alt.id}` await axios.put(url, { answer: 0 }) } // Update selected alternative - const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alternative.id}` + const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}` await axios .put(url, { answer: 1 }) .then(() => { diff --git a/client/src/pages/presentationEditor/components/answerComponents/AnswerText.tsx b/client/src/pages/presentationEditor/components/answerComponents/AnswerText.tsx index b8048c75..55fa6d8c 100644 --- a/client/src/pages/presentationEditor/components/answerComponents/AnswerText.tsx +++ b/client/src/pages/presentationEditor/components/answerComponents/AnswerText.tsx @@ -50,7 +50,7 @@ const AnswerText = ({ activeSlide, competitionId }: AnswerTextProps) => { return } const alternative = activeSlide.questions[0].alternatives[0] - const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/question_alternatives/${alternative.id}` + const url = `/api/competitions/${competitionId}/teams/${teamId}/answers/${alternative.id}` await axios .put(url, { answer }) .then(() => { -- GitLab