From a462620999289c4d40bf47dbbc2ae3928f987717 Mon Sep 17 00:00:00 2001 From: Denis Voinovich Date: Tue, 24 Jun 2025 14:28:26 +0300 Subject: [PATCH] =?UTF-8?q?fix=20[P-276]:=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easydockersave | 2 +- easyserver | 2 +- ...alter_answer_name_and_more.cpython-310.pyc | Bin 0 -> 879 bytes .../src/components/testing/DetailCardTest.vue | 31 +++- .../src/components/testing/QuestionBlock.vue | 33 ++-- .../src/components/testing/TestResults.vue | 151 ++++++++++++------ 6 files changed, 149 insertions(+), 70 deletions(-) create mode 100644 src/back/vote/migrations/__pycache__/0004_alter_answer_file_alter_answer_name_and_more.cpython-310.pyc diff --git a/easydockersave b/easydockersave index b72d231e8..0bf5ed16e 120000 --- a/easydockersave +++ b/easydockersave @@ -1 +1 @@ -/home/nukeap/projects/PORTAL_COD2/sys/scripts/easydockersave.sh \ No newline at end of file +/home/denzel/Документы/PORTAL_COD2/sys/scripts/easydockersave.sh \ No newline at end of file diff --git a/easyserver b/easyserver index dd68800b6..24a03aacc 120000 --- a/easyserver +++ b/easyserver @@ -1 +1 @@ -/home/nukeap/projects/PORTAL_COD2/sys/scripts/easyserver.sh \ No newline at end of file +/home/denzel/Документы/PORTAL_COD2/sys/scripts/easyserver.sh \ No newline at end of file diff --git a/src/back/vote/migrations/__pycache__/0004_alter_answer_file_alter_answer_name_and_more.cpython-310.pyc b/src/back/vote/migrations/__pycache__/0004_alter_answer_file_alter_answer_name_and_more.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a5093ad94d79f02981a30be0ea9518d3c662a467 GIT binary patch literal 879 zcmZ`%J#Q015Z%4ov+vG!Fi22Ai{vJ@1O-Kef{=oOM4C`tvs!yL=X37Ex$`BE0);^9 zhLVDwE=Ai`fbx7$)h;uj!6m|bIHkl59ZX5Q?~yqVps)$$3hPd~SZn~adJ+E`wQ zk##)9O%yv)Q1C?p9ekiY^O(!iE%Uxu`dodiPC86E{aB>Cilt>7E3X{KnE*b?RC8bE z{j9+JB9R>%$EHVREWC`Ea&{saL%xD}&(2Yl`q8R4nEhS#es*j|EuQdLrr~6mH_@rw zy;2r>^oLgs!-dJCM1-28zE!=dPOC4oqv~|_e5=z?E;m&+3nPX9lGU`&) zf3Ui?niRGF;O;k*WeZ==gONzXY!&*Z>0CEzoEPlp+6{ClcWpktyHpd @@ -36,6 +37,7 @@ :formattedTime="formatSpentTime" :questions="data?.questions" :userAnswers="answers" + :remainingAttempts="remainingAttempts" @restart="startTest" /> @@ -157,7 +159,11 @@ export default { testStarted.value = true; testFinished.value = false; - answers.value = Array(data.value.questions.length).fill(null); + // Правильно инициализируем ответы в зависимости от типа вопроса + answers.value = data.value.questions.map((question) => { + const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length; + return correctAnswersCount > 1 ? [] : null; + }); const initialTime = data.value.time * 60; data.value = { ...data.value, time: initialTime }; @@ -169,7 +175,7 @@ export default { timer = setInterval(() => { if (data.value?.time > 0) { - data.value = { ...data.value, time: data.value.time - 1 }; + data.value.time = data.value.time - 1; // Обновляем только время, а не весь объект spentTime.value += 1; } else { finishTest(); @@ -231,7 +237,12 @@ export default { () => data.value?.questions, (newQuestions) => { if (newQuestions && Array.isArray(newQuestions)) { - answers.value = newQuestions.map(() => null); + if (!answers.value || answers.value.length === 0) { + answers.value = newQuestions.map((question) => { + const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length; + return correctAnswersCount > 1 ? [] : null; + }); + } } }, { deep: true } @@ -260,7 +271,11 @@ export default { ); const answeredQuestions = computed( - () => answers.value.filter((answer) => answer !== null).length, + () => answers.value.filter((answer) => { + if (answer === null || answer === undefined) return false; + if (Array.isArray(answer)) return answer.length > 0; + return true; + }).length, ); const testPassed = computed(() => testResults.value?.is_passed ?? false); @@ -271,6 +286,13 @@ export default { } }; + const onAnswerChanged = (questionIndex, value) => { + + const newAnswers = [...answers.value]; + newAnswers[questionIndex] = value; + answers.value = newAnswers; + }; + const openFinishDialog = () => { showFinishDialog.value = true; }; @@ -293,6 +315,7 @@ export default { answers, currentQuestion, changeQuestion, + onAnswerChanged, showFinishDialog, openFinishDialog, correctAnswers, diff --git a/src/front/src/components/testing/QuestionBlock.vue b/src/front/src/components/testing/QuestionBlock.vue index 339687127..d61fc1c38 100644 --- a/src/front/src/components/testing/QuestionBlock.vue +++ b/src/front/src/components/testing/QuestionBlock.vue @@ -17,7 +17,7 @@ @@ -97,7 +97,7 @@ @@ -168,10 +169,10 @@ export default { color: rgb(var(--v-theme-text_carous)); } -.v-radio-group :deep(.v-radio:hover), +/* .v-radio-group :deep(.v-radio:hover), .v-checkbox:hover { transform: translateX(4px); -} +} */ .v-btn { text-transform: none; diff --git a/src/front/src/components/testing/TestResults.vue b/src/front/src/components/testing/TestResults.vue index 08913c384..e2b77b213 100644 --- a/src/front/src/components/testing/TestResults.vue +++ b/src/front/src/components/testing/TestResults.vue @@ -17,23 +17,6 @@ - - - - mdi-checkbox-marked-circle - -

{{ correctAnswers }}/{{ totalQuestions }}

-
- {{ isPracticeMode ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }} -
-
-
@@ -43,6 +26,24 @@ + + + + mdi-checkbox-marked-circle + +

{{ correctAnswers }}/{{ totalQuestions }}

+
+ {{ !fromCompletedTab ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }} +
+
+
+ mdi-clock-outline @@ -52,11 +53,11 @@
- - + + - Правильные ответы + {{ isPracticeMode ? 'Правильные ответы' : 'Результаты по вопросам' }} @@ -78,33 +79,46 @@ -

{{ question.name }}

- -
- - {{ getAnswerIcon(index, answer) }} - - - {{ answer.name }} - - - Ваш ответ - -
-
+

{{ question.name }}

+ + +
-
- {{ isQuestionCorrect(index) ? 'Правильно ✓' : 'Неправильно ✗' }} +
+ + {{ getAnswerIcon(index, answer) }} + + + {{ answer.name }} + + + Ваш ответ + +
+
+ + +
+ +
+ + {{ isQuestionCorrect(index) ? 'mdi-check-circle' : 'mdi-close-circle' }} + + {{ isQuestionCorrect(index) ? 'Правильно' : 'Неправильно' }}
@@ -114,9 +128,10 @@ - -
+ +
mdi-refresh Попробовать ещё раз + + + {{ getRetryMessage }} +
@@ -157,6 +182,10 @@ export default { fromCompletedTab: { type: Boolean, default: false + }, + remainingAttempts: { + type: Number, + default: undefined } }, setup(props) { @@ -164,6 +193,29 @@ export default { const showAnswersDialog = ref(false); const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice'); + const isExamMode = computed(() => route.query.mode === 'exam'); + + const canRetry = computed(() => { + if (props.fromCompletedTab) return false; + if (isPracticeMode.value) return true; + if (isExamMode.value) { + // В режиме экзамена можно повторить только если есть попытки и тест не пройден + return props.remainingAttempts > 0 && !props.testPassed; + } + return true; + }); + + const getRetryMessage = computed(() => { + if (isExamMode.value && props.remainingAttempts !== undefined) { + if (props.testPassed) { + return 'Тест успешно пройден. Повторное прохождение недоступно.'; + } + if (props.remainingAttempts <= 0) { + return 'Нет оставшихся попыток для прохождения теста.'; + } + } + return null; + }); const getQuestionStatusColor = (questionIndex) => { if (!props.questions[questionIndex]?.answers) return 'grey'; @@ -301,6 +353,9 @@ export default { return { showAnswersDialog, isPracticeMode, + isExamMode, + canRetry, + getRetryMessage, isQuestionCorrect, hasUserAnswer, showUserAnswer,