Merge branch 'dev-denzel' into cja_new
This commit is contained in:
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 :elevation="isDialog ? 0 : 2" class="rounded-lg">
|
||||||
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold">Информация</v-card-title>
|
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold">Информация</v-card-title>
|
||||||
<v-card-text :class="[
|
<v-card-text :class="[
|
||||||
'd-flex flex-lg-column ga-6',
|
'd-flex flex-column ga-6',
|
||||||
{ 'border-b-thin': !isDialog, 'pa-0': isDialog }
|
{ 'border-b-thin': !isDialog, 'pa-0': isDialog }
|
||||||
]">
|
]">
|
||||||
<p class="text-body-1">
|
<div class="test-info">
|
||||||
{{ data?.description }}
|
<div class="text-body-1 mb-4" v-html="formatDescription(data?.description)"></div>
|
||||||
</p>
|
|
||||||
<p v-if="!isDialog">
|
<div class="d-flex align-center mb-3">
|
||||||
<strong>Время на прохождение — {{ data?.time }} минут</strong>
|
<v-icon icon="mdi-clock-outline" color="teal-darken-2" class="mr-2" />
|
||||||
</p>
|
<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-text>
|
||||||
<v-card-actions v-if="!isDialog" class="mx-2 my-4">
|
<v-card-actions v-if="!isDialog" class="mx-2 my-4">
|
||||||
<v-btn
|
<v-btn
|
||||||
@@ -43,13 +68,40 @@ export default {
|
|||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
setup(props) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const isExamMode = computed(() => route.query.mode === 'exam');
|
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 {
|
return {
|
||||||
isExamMode
|
isExamMode,
|
||||||
|
timeWordDeclension,
|
||||||
|
formatDescription
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</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">
|
<v-col cols="auto" class="d-flex flex-grow-1">
|
||||||
<div class="d-flex flex-column justify-center 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-h6 font-weight-bold mb-2">{{ cardValue.name }}</div>
|
||||||
<div class="text-body-1 text-grey-darken-1 mb-4" style="max-width: 600px">
|
<div class="text-body-1 text-grey-darken-1 mb-4 test-description" style="max-width: 600px" v-html="formatDescription(cardValue.description)"></div>
|
||||||
{{ cardValue.description }}
|
|
||||||
</div>
|
|
||||||
<div class="d-flex flex-wrap gap-4">
|
<div class="d-flex flex-wrap gap-4">
|
||||||
<slot name="results"></slot>
|
<slot name="results"></slot>
|
||||||
<div v-for="icon in activeTabIcon" class="d-inline-flex align-center test-info-item">
|
<div v-for="icon in activeTabIcon" class="d-inline-flex align-center test-info-item">
|
||||||
@@ -152,7 +150,13 @@ export default {
|
|||||||
return val;
|
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>
|
</script>
|
||||||
@@ -197,4 +201,9 @@ export default {
|
|||||||
background: rgba(0, 0, 0, 0.02);
|
background: rgba(0, 0, 0, 0.02);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.test-description {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
:correctAnswers="correctAnswers"
|
:correctAnswers="correctAnswers"
|
||||||
:answeredQuestions="answeredQuestions"
|
:answeredQuestions="answeredQuestions"
|
||||||
:totalQuestions="data.question_count"
|
:totalQuestions="data.question_count"
|
||||||
:formattedTime="formattedTime"
|
:formattedTime="formatSpentTime"
|
||||||
:questions="data?.questions"
|
:questions="data?.questions"
|
||||||
:userAnswers="answers"
|
:userAnswers="answers"
|
||||||
@restart="startTest"
|
@restart="startTest"
|
||||||
@@ -81,6 +81,13 @@ export default {
|
|||||||
const data = ref(null);
|
const data = ref(null);
|
||||||
const testingId = ref(null);
|
const testingId = ref(null);
|
||||||
const testResults = 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 getTestById = async (id) => {
|
||||||
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${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);
|
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) {
|
if (timer) {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
@@ -140,6 +149,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 = { ...data.value, time: data.value.time - 1 };
|
||||||
|
spentTime.value += 1;
|
||||||
} else {
|
} else {
|
||||||
finishTest();
|
finishTest();
|
||||||
}
|
}
|
||||||
@@ -253,6 +263,7 @@ export default {
|
|||||||
testStarted,
|
testStarted,
|
||||||
testFinished,
|
testFinished,
|
||||||
formattedTime,
|
formattedTime,
|
||||||
|
formatSpentTime,
|
||||||
startTest,
|
startTest,
|
||||||
finishTest,
|
finishTest,
|
||||||
answers,
|
answers,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card
|
<v-card
|
||||||
class="mt-4 w-75 mx-auto d-flex flex-lg-column"
|
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">
|
<v-card-title class="text-h6 font-weight-bold">
|
||||||
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
|
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
|
||||||
@@ -27,7 +27,8 @@
|
|||||||
v-if="option.file"
|
v-if="option.file"
|
||||||
:src="`http://127.0.0.1:8000${option.file}`"
|
:src="`http://127.0.0.1:8000${option.file}`"
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
max-height="140"
|
width="400"
|
||||||
|
min-width="300"
|
||||||
contain
|
contain
|
||||||
/>
|
/>
|
||||||
<span>{{ option.name }}</span>
|
<span>{{ option.name }}</span>
|
||||||
@@ -52,7 +53,8 @@
|
|||||||
v-if="option.file"
|
v-if="option.file"
|
||||||
:src="`http://127.0.0.1:8000${option.file}`"
|
:src="`http://127.0.0.1:8000${option.file}`"
|
||||||
class="mb-4"
|
class="mb-4"
|
||||||
max-height="140"
|
width="400"
|
||||||
|
min-width="300"
|
||||||
contain
|
contain
|
||||||
/>
|
/>
|
||||||
<span>{{ option.name }}</span>
|
<span>{{ option.name }}</span>
|
||||||
@@ -178,5 +180,7 @@ export default {
|
|||||||
:deep(.v-img) {
|
:deep(.v-img) {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
margin: 0 auto;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -171,9 +171,18 @@ export default {
|
|||||||
if (props.fromCompletedTab) {
|
if (props.fromCompletedTab) {
|
||||||
return 'grey';
|
return 'grey';
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasCorrectAnswers = props.questions[questionIndex].answers.some(a => a.right_wrong === true);
|
const userAnswer = props.userAnswers?.[questionIndex];
|
||||||
return hasCorrectAnswers ? 'success' : 'grey';
|
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) => {
|
const getQuestionStatusIcon = (questionIndex) => {
|
||||||
@@ -182,9 +191,18 @@ export default {
|
|||||||
if (props.fromCompletedTab) {
|
if (props.fromCompletedTab) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasCorrectAnswers = props.questions[questionIndex].answers.some(a => a.right_wrong === true);
|
const userAnswer = props.userAnswers?.[questionIndex];
|
||||||
return hasCorrectAnswers ? 'mdi-check-circle' : 'mdi-circle-outline';
|
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) => {
|
const hasUserAnswer = (index) => {
|
||||||
|
|||||||
@@ -181,7 +181,11 @@ const routes = [
|
|||||||
path: "/test/testdetail/:id",
|
path: "/test/testdetail/:id",
|
||||||
name: "TestDetail",
|
name: "TestDetail",
|
||||||
component: () =>
|
component: () =>
|
||||||
import("@/components/testing/DetailCardTest.vue")
|
import("@/components/testing/DetailCardTest.vue"),
|
||||||
|
meta: {
|
||||||
|
title: "Тестирование",
|
||||||
|
ico: "mdi-account",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/secret',
|
path: '/secret',
|
||||||
|
|||||||
@@ -247,7 +247,11 @@ export default {
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
if (activeTab.value === 0) {
|
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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user