From 04840193e2d1e4fa4c8942979fcfc907fd0c486b Mon Sep 17 00:00:00 2001 From: Denis Voinovich Date: Fri, 30 May 2025 12:03:57 +0300 Subject: [PATCH] =?UTF-8?q?feat=20[P-227]:=20=D0=B2=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B4=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B2=D0=BE=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=20=D0=B2=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82?= =?UTF-8?q?=D1=80=D1=83=D1=82=D0=BA=D0=BE=D1=80=D0=B5,=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=20=D0=BC=D0=BD=D0=BE=D0=B6=D0=B5=D1=81=D1=82=D0=B2=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=BC=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80=D0=B5=20?= =?UTF-8?q?=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/testing/QuestionBlock.vue | 1 + .../src/components/testing/TestResults.vue | 6 ++- .../src/components/vote/VoteConstructor.vue | 15 +++++++ src/front/src/views/TestHomePage.vue | 40 ++++++++----------- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/front/src/components/testing/QuestionBlock.vue b/src/front/src/components/testing/QuestionBlock.vue index c0a419f33..5d6cd7343 100644 --- a/src/front/src/components/testing/QuestionBlock.vue +++ b/src/front/src/components/testing/QuestionBlock.vue @@ -38,6 +38,7 @@
+

Возможно несколько верных ответов

- + Результаты тестирования @@ -120,6 +120,10 @@ import { useRoute } from 'vue-router'; export default { emits: ['restart'], props: { + hideTitle: { + type: Boolean, + default: false + }, testFinished: Boolean, testPassed: Boolean, correctAnswers: Number, diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index fab353619..0719e40ae 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -425,6 +425,12 @@ export default { const errorMessage = ref(''); const validateAnswers = () => { + if (props.isTest) { + return form.value.questions.some((question) => { + const hasCorrectAnswer = question.answers.some(answer => answer.right_wrong); + return !hasCorrectAnswer || question.answers.some(answer => !answer.text || answer.text.trim() === ''); + }); + } return form.value.questions.some((question) => { if (question.settings.choice === 'free') { return question.answers.some((answer) => !answer.text || answer.text.trim() === ''); @@ -436,6 +442,15 @@ export default { const saveVoting = async () => { try { if (props.isTest) { + const invalidQuestions = form.value.questions.filter(question => + !question.answers.some(answer => answer.right_wrong) + ); + + if (invalidQuestions.length > 0) { + alert('Каждый вопрос должен иметь хотя бы один правильный ответ'); + return; + } + const testData = { name: form.value.title, description: form.value.description, diff --git a/src/front/src/views/TestHomePage.vue b/src/front/src/views/TestHomePage.vue index d5496b267..095728963 100644 --- a/src/front/src/views/TestHomePage.vue +++ b/src/front/src/views/TestHomePage.vue @@ -164,22 +164,22 @@ - - + - +