fix [P-276]: изменения

This commit is contained in:
Denis Voinovich committed 2025-06-24 14:28:26 +03:00
1 parent 892bf1b1d7
commit a462620999
6 files changed
+149 -70

No files matched your search

+1 -1
View File
@@ -1 +1 @@
/home/nukeap/projects/PORTAL_COD2/sys/scripts/easydockersave.sh /home/denzel/Документы/PORTAL_COD2/sys/scripts/easydockersave.sh
+1 -1
View File
@@ -1 +1 @@
/home/nukeap/projects/PORTAL_COD2/sys/scripts/easyserver.sh /home/denzel/Документы/PORTAL_COD2/sys/scripts/easyserver.sh
@@ -23,6 +23,7 @@
:answers="answers" :answers="answers"
:finishTest="openFinishDialog" :finishTest="openFinishDialog"
@change-question="changeQuestion" @change-question="changeQuestion"
@answer-changed="onAnswerChanged"
/> />
<!-- Результаты теста --> <!-- Результаты теста -->
@@ -36,6 +37,7 @@
:formattedTime="formatSpentTime" :formattedTime="formatSpentTime"
:questions="data?.questions" :questions="data?.questions"
:userAnswers="answers" :userAnswers="answers"
:remainingAttempts="remainingAttempts"
@restart="startTest" @restart="startTest"
/> />
@@ -157,7 +159,11 @@ export default {
testStarted.value = true; testStarted.value = true;
testFinished.value = false; 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; const initialTime = data.value.time * 60;
data.value = { ...data.value, time: initialTime }; data.value = { ...data.value, time: initialTime };
@@ -169,7 +175,7 @@ export default {
timer = setInterval(() => { timer = setInterval(() => {
if (data.value?.time > 0) { if (data.value?.time > 0) {
data.value = { ...data.value, time: data.value.time - 1 }; data.value.time = data.value.time - 1; // Обновляем только время, а не весь объект
spentTime.value += 1; spentTime.value += 1;
} else { } else {
finishTest(); finishTest();
@@ -231,7 +237,12 @@ export default {
() => data.value?.questions, () => data.value?.questions,
(newQuestions) => { (newQuestions) => {
if (newQuestions && Array.isArray(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 } { deep: true }
@@ -260,7 +271,11 @@ export default {
); );
const answeredQuestions = computed( 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); 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 = () => { const openFinishDialog = () => {
showFinishDialog.value = true; showFinishDialog.value = true;
}; };
@@ -293,6 +315,7 @@ export default {
answers, answers,
currentQuestion, currentQuestion,
changeQuestion, changeQuestion,
onAnswerChanged,
showFinishDialog, showFinishDialog,
openFinishDialog, openFinishDialog,
correctAnswers, correctAnswers,
@@ -17,7 +17,7 @@
<!-- Одиночный выбор --> <!-- Одиночный выбор -->
<v-radio-group <v-radio-group
v-if="!isMultipleChoice" v-if="!isMultipleChoice"
v-model="answers[currentQuestion]" v-model="currentAnswer"
> >
<v-radio <v-radio
v-for="(option, index) in question.answers" v-for="(option, index) in question.answers"
@@ -48,7 +48,7 @@
<v-checkbox <v-checkbox
v-for="(option, index) in question.answers" v-for="(option, index) in question.answers"
:key="index" :key="index"
v-model="answers[currentQuestion]" v-model="currentAnswer"
:value="option.name" :value="option.name"
class="mb-n6" class="mb-n6"
> >
@@ -97,7 +97,7 @@
</template> </template>
<script> <script>
import { computed, watch } from 'vue'; import { computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { baseURL } from '@/utils/axios-api'; import { baseURL } from '@/utils/axios-api';
@@ -109,7 +109,7 @@ export default {
finishTest: Function, finishTest: Function,
answers: Array, answers: Array,
}, },
setup(props) { setup(props, { emit }) {
const route = useRoute(); const route = useRoute();
const isPracticeMode = computed( const isPracticeMode = computed(
() => !route.query.mode || route.query.mode === "practice", () => !route.query.mode || route.query.mode === "practice",
@@ -121,23 +121,24 @@ export default {
); );
}); });
watch( const currentAnswer = computed({
() => props.currentQuestion, get() {
(newVal) => { const answer = props.answers[props.currentQuestion];
if (isMultipleChoice.value && !Array.isArray(props.answers[newVal])) { return answer;
props.answers[newVal] = [];
}
}, },
{ immediate: true }, set(value) {
); emit('answer-changed', props.currentQuestion, value);
}
});
return { return {
isMultipleChoice, isMultipleChoice,
isPracticeMode, isPracticeMode,
baseURL baseURL,
currentAnswer
}; };
}, },
emits: ["change-question"], emits: ["change-question", "answer-changed"],
}; };
</script> </script>
@@ -168,10 +169,10 @@ export default {
color: rgb(var(--v-theme-text_carous)); color: rgb(var(--v-theme-text_carous));
} }
.v-radio-group :deep(.v-radio:hover), /* .v-radio-group :deep(.v-radio:hover),
.v-checkbox:hover { .v-checkbox:hover {
transform: translateX(4px); transform: translateX(4px);
} } */
.v-btn { .v-btn {
text-transform: none; text-transform: none;
+103 -48
View File
@@ -17,23 +17,6 @@
</div> </div>
<v-row class="mt-2"> <v-row class="mt-2">
<v-col cols="12" sm="4">
<v-card
class="pa-4 text-center result-card"
:class="{ 'cursor-pointer': isPracticeMode }"
elevation="2"
:color="testPassed ? 'success-light' : 'error-light'"
@click="isPracticeMode && (showAnswersDialog = true)"
>
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
mdi-checkbox-marked-circle
</v-icon>
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
<div class="text-body-2">
{{ isPracticeMode ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }}
</div>
</v-card>
</v-col>
<v-col cols="12" sm="4"> <v-col cols="12" sm="4">
<v-card class="pa-4 text-center result-card" elevation="2"> <v-card class="pa-4 text-center result-card" elevation="2">
@@ -43,6 +26,24 @@
</v-card> </v-card>
</v-col> </v-col>
<v-col cols="12" sm="4">
<v-card
class="pa-4 text-center result-card"
:class="{ 'cursor-pointer': !fromCompletedTab }"
elevation="2"
:color="testPassed ? 'success-light' : 'error-light'"
@click="!fromCompletedTab && (showAnswersDialog = true)"
>
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
mdi-checkbox-marked-circle
</v-icon>
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
<div class="text-body-2">
{{ !fromCompletedTab ? 'Правильных ответов (нажмите чтобы увидеть детали)' : 'Правильных ответов' }}
</div>
</v-card>
</v-col>
<v-col cols="12" sm="4"> <v-col cols="12" sm="4">
<v-card class="pa-4 text-center result-card" elevation="2"> <v-card class="pa-4 text-center result-card" elevation="2">
<v-icon size="36" color="primary" class="mb-2">mdi-clock-outline</v-icon> <v-icon size="36" color="primary" class="mb-2">mdi-clock-outline</v-icon>
@@ -52,11 +53,11 @@
</v-col> </v-col>
</v-row> </v-row>
<!-- Модальное окно с правильными ответами (только для тренировочного режима) --> <!-- Модальное окно с правильными ответами -->
<v-dialog v-if="isPracticeMode" v-model="showAnswersDialog" max-width="600"> <v-dialog v-model="showAnswersDialog" max-width="600">
<v-card> <v-card>
<v-card-title class="d-flex align-center text-h6 font-weight-bold px-4 py-3 bg-teal-darken-4 text-white"> <v-card-title class="d-flex align-center text-h6 font-weight-bold px-4 py-3 bg-teal-darken-4 text-white">
<span>Правильные ответы</span> <span>{{ isPracticeMode ? 'Правильные ответы' : 'Результаты по вопросам' }}</span>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn icon="mdi-close" variant="text" @click="showAnswersDialog = false" color="white"></v-btn> <v-btn icon="mdi-close" variant="text" @click="showAnswersDialog = false" color="white"></v-btn>
</v-card-title> </v-card-title>
@@ -78,33 +79,46 @@
</div> </div>
</v-expansion-panel-title> </v-expansion-panel-title>
<v-expansion-panel-text> <v-expansion-panel-text>
<p class="mb-2 font-weight-bold">{{ question.name }}</p> <p class="mb-4 font-weight-bold">{{ question.name }}</p>
<v-divider class="mb-2"></v-divider>
<div v-for="answer in question.answers" :key="answer.id" class="mb-2 d-flex align-center"> <!-- Показываем варианты ответов только в тренировочном режиме -->
<v-icon <div v-if="isPracticeMode">
:color="getAnswerColor(index, answer)"
size="small"
class="mr-2"
>
{{ getAnswerIcon(index, answer) }}
</v-icon>
<span :class="{ 'font-weight-bold': isAnswerCorrect(index, answer) }">
{{ answer.name }}
</span>
<v-chip
v-if="answer.isUserAnswer"
size="small"
class="ml-2"
:color="answer.right_wrong === true ? 'success' : 'error'"
variant="outlined"
>
Ваш ответ
</v-chip>
</div>
<div v-if="hasUserAnswer(index)" class="mt-4">
<v-divider class="mb-2"></v-divider> <v-divider class="mb-2"></v-divider>
<div class="text-caption"> <div v-for="answer in question.answers" :key="answer.id" class="mb-2 d-flex align-center">
{{ isQuestionCorrect(index) ? 'Правильно ✓' : 'Неправильно ✗' }} <v-icon
:color="getAnswerColor(index, answer)"
size="small"
class="mr-2"
>
{{ getAnswerIcon(index, answer) }}
</v-icon>
<span :class="{ 'font-weight-bold': isAnswerCorrect(index, answer) }">
{{ answer.name }}
</span>
<v-chip
v-if="answer.isUserAnswer"
size="small"
class="ml-2"
:color="answer.right_wrong === true ? 'success' : 'error'"
variant="outlined"
>
Ваш ответ
</v-chip>
</div>
</div>
<!-- В режиме экзамена показываем только статус ответа -->
<div v-if="hasUserAnswer(index)">
<v-divider v-if="isPracticeMode" class="mb-2"></v-divider>
<div class="text-body-2 font-weight-medium d-flex align-center">
<v-icon
:color="isQuestionCorrect(index) ? 'success' : 'error'"
class="mr-2"
size="small"
>
{{ isQuestionCorrect(index) ? 'mdi-check-circle' : 'mdi-close-circle' }}
</v-icon>
{{ isQuestionCorrect(index) ? 'Правильно' : 'Неправильно' }}
</div> </div>
</div> </div>
</v-expansion-panel-text> </v-expansion-panel-text>
@@ -114,9 +128,10 @@
</v-card> </v-card>
</v-dialog> </v-dialog>
<!-- Кнопка "Попробовать ещё раз" для тренировочного режима --> <!-- Кнопка "Попробовать ещё раз" или информационное сообщение -->
<div v-if="isPracticeMode && !fromCompletedTab" class="d-flex justify-center mt-6"> <div class="d-flex justify-center mt-6">
<v-btn <v-btn
v-if="canRetry"
color="teal-darken-1" color="teal-darken-1"
@click="$emit('restart')" @click="$emit('restart')"
class="px-6" class="px-6"
@@ -125,6 +140,16 @@
<v-icon start>mdi-refresh</v-icon> <v-icon start>mdi-refresh</v-icon>
Попробовать ещё раз Попробовать ещё раз
</v-btn> </v-btn>
<v-alert
v-else-if="getRetryMessage"
type="info"
variant="tonal"
class="text-center"
:icon="testPassed ? 'mdi-check-circle' : 'mdi-information'"
>
{{ getRetryMessage }}
</v-alert>
</div> </div>
</v-card> </v-card>
</template> </template>
@@ -157,6 +182,10 @@ export default {
fromCompletedTab: { fromCompletedTab: {
type: Boolean, type: Boolean,
default: false default: false
},
remainingAttempts: {
type: Number,
default: undefined
} }
}, },
setup(props) { setup(props) {
@@ -164,6 +193,29 @@ export default {
const showAnswersDialog = ref(false); const showAnswersDialog = ref(false);
const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice'); 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) => { const getQuestionStatusColor = (questionIndex) => {
if (!props.questions[questionIndex]?.answers) return 'grey'; if (!props.questions[questionIndex]?.answers) return 'grey';
@@ -301,6 +353,9 @@ export default {
return { return {
showAnswersDialog, showAnswersDialog,
isPracticeMode, isPracticeMode,
isExamMode,
canRetry,
getRetryMessage,
isQuestionCorrect, isQuestionCorrect,
hasUserAnswer, hasUserAnswer,
showUserAnswer, showUserAnswer,