From 571c1cf74c3a2225cf25ed5099a3b836db3b42a8 Mon Sep 17 00:00:00 2001 From: Nukeap <53114367+Nukeap@users.noreply.github.com> Date: Wed, 15 Jan 2025 15:19:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B9=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/back/vote/admin.py | 1 + src/front/src/components/vote/CurrentVote.vue | 53 +++++++++++-------- src/front/src/components/vote/VoteCard.vue | 2 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/back/vote/admin.py b/src/back/vote/admin.py index 529e46caa..19a39c4cc 100644 --- a/src/back/vote/admin.py +++ b/src/back/vote/admin.py @@ -3,3 +3,4 @@ from .models import * admin.site.register(Vote) admin.site.register(Question) +admin.site.register(Answer) \ No newline at end of file diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index 5c5732f6d..e87dba85f 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -3,39 +3,40 @@ {{ data.name }} {{ data.description }} - + {{ data }} - Вопрос {{ index + 1 }} + Вопрос {{ question.numb }} {{ question.question }} + + {{ result }}-- - + @@ -94,9 +95,15 @@ export default { const isVoteSubmitted = ref(false); const isCurrentQuestionAnswered = computed(() => { - return !!answers.value[activeStep.value]; + let q = props.data.questions.find(e=>e.numb==activeStep.value+1) + return result.value[q.id].length>0; }); - + const getres=()=>{ + return props.data.questions.reduce((acc,item)=> {acc[item.id]=[] + return acc + },{}) + } + const result=ref(getres()) const nextStep = () => { if (activeStep.value < props.data.questions.length - 1) { activeStep.value++; @@ -110,14 +117,15 @@ export default { }; const submitVote = () => { - const voteData = props.data.questions.map((question, index) => ({ - question: question.question, - answer: answers.value[index], - })); - console.log("Отправляем данные голосования:", voteData); + // const voteData = props.data.questions.map((question, index) => ({ + // question: question.id, + // answer: answers.value[index], + // })); + result.value + console.log("Отправляем данные голосования:", result.value); - isVoteSubmitted.value = true; - emit("submit", voteData); + // isVoteSubmitted.value = true; + // emit("submit", voteData); }; return { @@ -128,6 +136,7 @@ export default { prevStep, submitVote, isVoteSubmitted, + result }; }, }; diff --git a/src/front/src/components/vote/VoteCard.vue b/src/front/src/components/vote/VoteCard.vue index b8e528c64..fdb5b9bd9 100644 --- a/src/front/src/components/vote/VoteCard.vue +++ b/src/front/src/components/vote/VoteCard.vue @@ -17,7 +17,7 @@ {{ voteCard.description }} - +