Skip to content
Snippets Groups Projects
Commit d7be6167 authored by Victor Löfgren's avatar Victor Löfgren
Browse files

Fix answer route

parent a87a0dec
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp ...@@ -58,7 +58,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp
(alt) => alternative.alternative_order === alt.correct_order (alt) => alternative.alternative_order === alt.correct_order
) )
axios 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}`, answer: `${alternative.alternative} - ${answer?.correct}`,
}) })
.then(() => { .then(() => {
...@@ -89,7 +89,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp ...@@ -89,7 +89,7 @@ const AnswerMatch = ({ variant, activeSlide, competitionId }: AnswerMultipleProp
const answeredText = answersCopy[index].correct const answeredText = answersCopy[index].correct
if (!activeSlide) return if (!activeSlide) return
axios 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}`, answer: `${alternative.alternative} - ${answeredText}`,
}) })
.catch(console.log) .catch(console.log)
......
...@@ -51,7 +51,7 @@ const AnswerMultiple = ({ variant, activeSlide, competitionId }: AnswerMultipleP ...@@ -51,7 +51,7 @@ const AnswerMultiple = ({ variant, activeSlide, competitionId }: AnswerMultipleP
if (!activeSlide || (activeSlide?.timer !== null && !timer.enabled)) { if (!activeSlide || (activeSlide?.timer !== null && !timer.enabled)) {
return 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 = { const payload = {
answer: checked ? 1 : 0, answer: checked ? 1 : 0,
} }
......
...@@ -57,11 +57,11 @@ const AnswerSingle = ({ variant, activeSlide, competitionId }: AnswerSingleProps ...@@ -57,11 +57,11 @@ const AnswerSingle = ({ variant, activeSlide, competitionId }: AnswerSingleProps
// Unselect each radio button to only allow one selected alternative // Unselect each radio button to only allow one selected alternative
const alternatives = activeSlide.questions[0].alternatives const alternatives = activeSlide.questions[0].alternatives
for (const alt of 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 }) await axios.put(url, { answer: 0 })
} }
// Update selected alternative // 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 await axios
.put(url, { answer: 1 }) .put(url, { answer: 1 })
.then(() => { .then(() => {
......
...@@ -50,7 +50,7 @@ const AnswerText = ({ activeSlide, competitionId }: AnswerTextProps) => { ...@@ -50,7 +50,7 @@ const AnswerText = ({ activeSlide, competitionId }: AnswerTextProps) => {
return return
} }
const alternative = activeSlide.questions[0].alternatives[0] 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 await axios
.put(url, { answer }) .put(url, { answer })
.then(() => { .then(() => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment