Merge branch 'dev-denzel' into cja_new

This commit is contained in:
cja committed 2025-06-02 13:16:39 +03:00
commit 4b04d41dbe
7 files changed
+128 -26

No files matched your search

@@ -5,15 +5,40 @@
<v-card :elevation="isDialog ? 0 : 2" class="rounded-lg">
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold">Информация</v-card-title>
<v-card-text :class="[
'd-flex flex-lg-column ga-6',
'd-flex flex-column ga-6',
{ 'border-b-thin': !isDialog, 'pa-0': isDialog }
]">
<p class="text-body-1">
{{ data?.description }}
</p>
<p v-if="!isDialog">
<strong>Время на прохождение — {{ data?.time }} минут</strong>
</p>
<div class="test-info">
<div class="text-body-1 mb-4" v-html="formatDescription(data?.description)"></div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-clock-outline" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
<strong>Время на прохождение:</strong> {{ data?.time }} {{ timeWordDeclension }}
</span>
</div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-format-list-numbered" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
<strong>Количество вопросов:</strong> {{ data?.question_count }}
</span>
</div>
<div class="d-flex align-center mb-3">
<v-icon icon="mdi-refresh" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
<strong>Количество попыток:</strong> {{ data?.attemps_number }}
</span>
</div>
<div class="d-flex align-center">
<v-icon icon="mdi-percent" color="teal-darken-2" class="mr-2" />
<span class="text-body-1">
<strong>Проходной балл:</strong> {{ data?.pass_perc }}%
</span>
</div>
</div>
</v-card-text>
<v-card-actions v-if="!isDialog" class="mx-2 my-4">
<v-btn
@@ -43,13 +68,40 @@ export default {
default: false
}
},
setup() {
setup(props) {
const route = useRoute();
const isExamMode = computed(() => route.query.mode === 'exam');
const timeWordDeclension = computed(() => {
if (!props.data?.time) return 'минут';
const lastDigit = props.data.time % 10;
const lastTwoDigits = props.data.time % 100;
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return 'минут';
if (lastDigit === 1) return 'минута';
if (lastDigit >= 2 && lastDigit <= 4) return 'минуты';
return 'минут';
});
const formatDescription = (text) => {
if (!text) return '';
return text.replace(/\r?\n/g, '<br>');
};
return {
isExamMode
isExamMode,
timeWordDeclension,
formatDescription
};
}
};
</script>
<style scoped>
.test-info {
padding: 16px;
border-radius: 8px;
background-color: rgba(0, 150, 136, 0.05);
}
</style>
@@ -32,9 +32,7 @@
<v-col cols="auto" class="d-flex flex-grow-1">
<div class="d-flex flex-column justify-center flex-grow-1">
<div class="text-h6 font-weight-bold mb-2">{{ cardValue.name }}</div>
<div class="text-body-1 text-grey-darken-1 mb-4" style="max-width: 600px">
{{ cardValue.description }}
</div>
<div class="text-body-1 text-grey-darken-1 mb-4 test-description" style="max-width: 600px" v-html="formatDescription(cardValue.description)"></div>
<div class="d-flex flex-wrap gap-4">
<slot name="results"></slot>
<div v-for="icon in activeTabIcon" class="d-inline-flex align-center test-info-item">
@@ -152,7 +150,13 @@ export default {
return val;
};
return { search, searchTest, momenter, activeTabIcon, baseURL };
const formatDescription = (text) => {
if (!text) return '';
// Заменяем \r\n и \n на <br>
return text.replace(/\r?\n/g, '<br>');
};
return { search, searchTest, momenter, activeTabIcon, baseURL, formatDescription };
},
};
</script>
@@ -197,4 +201,9 @@ export default {
background: rgba(0, 0, 0, 0.02);
border-radius: 8px;
}
.test-description {
white-space: pre-wrap;
word-wrap: break-word;
}
</style>
@@ -33,7 +33,7 @@
:correctAnswers="correctAnswers"
:answeredQuestions="answeredQuestions"
:totalQuestions="data.question_count"
:formattedTime="formattedTime"
:formattedTime="formatSpentTime"
:questions="data?.questions"
:userAnswers="answers"
@restart="startTest"
@@ -81,6 +81,13 @@ export default {
const data = ref(null);
const testingId = ref(null);
const testResults = ref(null);
const spentTime = ref(0);
const formatSpentTime = computed(() => {
const minutes = Math.floor(spentTime.value / 60);
const seconds = spentTime.value % 60;
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
});
const getTestById = async (id) => {
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`);
@@ -131,7 +138,9 @@ export default {
answers.value = Array(data.value.questions.length).fill(null);
data.value = { ...data.value, time: data.value.time * 60 };
const initialTime = data.value.time * 60;
data.value = { ...data.value, time: initialTime };
spentTime.value = 0;
if (timer) {
clearInterval(timer);
@@ -140,6 +149,7 @@ export default {
timer = setInterval(() => {
if (data.value?.time > 0) {
data.value = { ...data.value, time: data.value.time - 1 };
spentTime.value += 1;
} else {
finishTest();
}
@@ -253,6 +263,7 @@ export default {
testStarted,
testFinished,
formattedTime,
formatSpentTime,
startTest,
finishTest,
answers,
@@ -1,7 +1,7 @@
<template>
<v-card
class="mt-4 w-75 mx-auto d-flex flex-lg-column"
style="min-height: 450px; max-height: 700px"
style="min-height: 450px; max-height: 900px"
>
<v-card-title class="text-h6 font-weight-bold">
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
@@ -27,7 +27,8 @@
v-if="option.file"
:src="`http://127.0.0.1:8000${option.file}`"
class="mb-4"
max-height="140"
width="400"
min-width="300"
contain
/>
<span>{{ option.name }}</span>
@@ -52,7 +53,8 @@
v-if="option.file"
:src="`http://127.0.0.1:8000${option.file}`"
class="mb-4"
max-height="140"
width="400"
min-width="300"
contain
/>
<span>{{ option.name }}</span>
@@ -178,5 +180,7 @@ export default {
:deep(.v-img) {
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
margin: 0 auto;
display: block;
}
</style>
@@ -171,9 +171,18 @@ export default {
if (props.fromCompletedTab) {
return 'grey';
}
const hasCorrectAnswers = props.questions[questionIndex].answers.some(a => a.right_wrong === true);
return hasCorrectAnswers ? 'success' : 'grey';
const userAnswer = props.userAnswers?.[questionIndex];
if (!userAnswer) return 'grey';
const correctAnswers = props.questions[questionIndex].answers.filter(a => a.right_wrong === true);
const isCorrect = Array.isArray(userAnswer)
? correctAnswers.length === userAnswer.length &&
correctAnswers.every(a => userAnswer.includes(a.name)) &&
userAnswer.every(ua => correctAnswers.some(ca => ca.name === ua))
: correctAnswers.some(a => a.name === userAnswer);
return isCorrect ? 'success' : 'error';
};
const getQuestionStatusIcon = (questionIndex) => {
@@ -182,9 +191,18 @@ export default {
if (props.fromCompletedTab) {
return '';
}
const hasCorrectAnswers = props.questions[questionIndex].answers.some(a => a.right_wrong === true);
return hasCorrectAnswers ? 'mdi-check-circle' : 'mdi-circle-outline';
const userAnswer = props.userAnswers?.[questionIndex];
if (!userAnswer) return 'mdi-circle-outline';
const correctAnswers = props.questions[questionIndex].answers.filter(a => a.right_wrong === true);
const isCorrect = Array.isArray(userAnswer)
? correctAnswers.length === userAnswer.length &&
correctAnswers.every(a => userAnswer.includes(a.name)) &&
userAnswer.every(ua => correctAnswers.some(ca => ca.name === ua))
: correctAnswers.some(a => a.name === userAnswer);
return isCorrect ? 'mdi-check-circle' : 'mdi-close-circle';
};
const hasUserAnswer = (index) => {
+5 -1
View File
@@ -181,7 +181,11 @@ const routes = [
path: "/test/testdetail/:id",
name: "TestDetail",
component: () =>
import("@/components/testing/DetailCardTest.vue")
import("@/components/testing/DetailCardTest.vue"),
meta: {
title: "Тестирование",
ico: "mdi-account",
},
},
{
path: '/secret',
+5 -1
View File
@@ -247,7 +247,11 @@ export default {
})
.finally(() => {
if (activeTab.value === 0) {
currentTest.value = getAllTests.value.filter(test => test.is_active).length;
currentTest.value = getAllTests.value.filter(test =>
test.is_active &&
test.is_passed !== true &&
test.attemps_number > 0
).length;
}
});
};