Merge branch 'Vit' into dev-denzel

This commit is contained in:
Nukeap committed 2025-01-15 15:22:18 +03:00
commit 5478986520
3 files changed
+33 -23

No files matched your search

+1
View File
@@ -3,3 +3,4 @@ from .models import *
admin.site.register(Vote) admin.site.register(Vote)
admin.site.register(Question) admin.site.register(Question)
admin.site.register(Answer)
+31 -22
View File
@@ -3,39 +3,40 @@
<v-stepper v-model="activeStep"> <v-stepper v-model="activeStep">
<v-card-title>{{ data.name }}</v-card-title> <v-card-title>{{ data.name }}</v-card-title>
<v-card-subtitle>{{ data.description }}</v-card-subtitle> <v-card-subtitle>{{ data.description }}</v-card-subtitle>
{{ data }}
<!-- Шаги голосования --> <!-- Шаги голосования -->
<v-stepper-header> <v-stepper-header>
<v-stepper-item <v-stepper-item
v-for="(question, index) in data.questions" v-for="question in data.questions"
:key="index" :key="question.numb"
:complete="index < activeStep" :complete="question.numb < activeStep"
:step="index + 1" :step="question.numb"
> >
Вопрос {{ index + 1 }} Вопрос {{ question.numb }}
</v-stepper-item> </v-stepper-item>
</v-stepper-header> </v-stepper-header>
<v-stepper-window> <v-stepper-window>
<v-stepper-window-item <v-stepper-window-item
v-for="(question, index) in data.questions" v-for="(question, index) in data.questions"
:key="index" :key="question.numb"
:step="index + 1" :step="question.numb"
> >
<v-card flat> <v-card flat>
<v-card-title>{{ question.question }}</v-card-title> <v-card-title>{{ question.question }}</v-card-title>
<v-card-text> <v-card-text>
<!-- Ответы на вопрос --> <!-- Ответы на вопрос -->
{{ result }}--
<v-row v-for="(answer, id) in question.answers" :key="id"> <v-row v-for="(answer, id) in question.answers" :key="id">
<v-checkbox <v-checkbox
v-model="answers[index]" v-model="result[question.id]"
:value="answer.answer" :label="answer.answer"
:value="answer.id"
color="teal-darken-4" color="teal-darken-4"
hide-details hide-details
> >
<template #label>
<span class="text-black">{{ answer.answer }}</span>
</template>
</v-checkbox> </v-checkbox>
</v-row> </v-row>
</v-card-text> </v-card-text>
@@ -94,9 +95,15 @@ export default {
const isVoteSubmitted = ref(false); const isVoteSubmitted = ref(false);
const isCurrentQuestionAnswered = computed(() => { 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 = () => { const nextStep = () => {
if (activeStep.value < props.data.questions.length - 1) { if (activeStep.value < props.data.questions.length - 1) {
activeStep.value++; activeStep.value++;
@@ -110,14 +117,15 @@ export default {
}; };
const submitVote = () => { const submitVote = () => {
const voteData = props.data.questions.map((question, index) => ({ // const voteData = props.data.questions.map((question, index) => ({
question: question.question, // question: question.id,
answer: answers.value[index], // answer: answers.value[index],
})); // }));
console.log("Отправляем данные голосования:", voteData); result.value
console.log("Отправляем данные голосования:", result.value);
isVoteSubmitted.value = true; // isVoteSubmitted.value = true;
emit("submit", voteData); // emit("submit", voteData);
}; };
return { return {
@@ -128,6 +136,7 @@ export default {
prevStep, prevStep,
submitVote, submitVote,
isVoteSubmitted, isVoteSubmitted,
result
}; };
}, },
}; };
+1 -1
View File
@@ -17,7 +17,7 @@
</v-col> </v-col>
</v-row> </v-row>
<v-card-text class="">{{ voteCard.description }}</v-card-text> <v-card-text class="">{{ voteCard.description }}</v-card-text>
<TimerUI :voteTime="{dateend:voteCard.dateend,datestart:voteCard.datestart}" @changeBtn="(time) => timeChange = time"/> <Timer :voteTime="{dateend:voteCard.dateend,datestart:voteCard.datestart}" @changeBtn="(time) => timeChange = time"/>
<v-card-actions class="justify-space-between mt-4 pb-2"> <v-card-actions class="justify-space-between mt-4 pb-2">
<v-btn <v-btn
:disabled="voteCard.is_passed || timeChange" :disabled="voteCard.is_passed || timeChange"