feat [P-227]: результаты тестирования в завершенных
This commit is contained in:
1 parent
b43620988a
commit
dd3e4ff5e5
2 files changed
+75
-60
No files matched your search
@@ -20,19 +20,9 @@
|
||||
v-for="(option, index) in question.answers"
|
||||
:key="index"
|
||||
:value="option.name"
|
||||
:color="isPracticeMode && answers[currentQuestion] ? (option.right_wrong ? 'success' : 'error') : undefined"
|
||||
:class="{
|
||||
'font-weight-bold': answers[currentQuestion] === option.name && isPracticeMode
|
||||
}"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div
|
||||
class="text-center"
|
||||
:class="{
|
||||
'text-success': isPracticeMode && answers[currentQuestion] && option.right_wrong,
|
||||
'text-error': isPracticeMode && answers[currentQuestion] && !option.right_wrong
|
||||
}"
|
||||
>
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
@@ -53,20 +43,10 @@
|
||||
:key="index"
|
||||
v-model="answers[currentQuestion]"
|
||||
:value="option.name"
|
||||
:color="shouldShowMultipleChoiceFeedback ? (option.right_wrong ? 'success' : 'error') : undefined"
|
||||
:class="{
|
||||
'font-weight-bold': answers[currentQuestion]?.includes(option.name) && isPracticeMode && shouldShowMultipleChoiceFeedback,
|
||||
'mb-n6': true
|
||||
}"
|
||||
class="mb-n6"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div
|
||||
class="text-center"
|
||||
:class="{
|
||||
'text-success': isPracticeMode && shouldShowMultipleChoiceFeedback && option.right_wrong,
|
||||
'text-error': isPracticeMode && shouldShowMultipleChoiceFeedback && !option.right_wrong
|
||||
}"
|
||||
>
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
@@ -128,17 +108,6 @@ export default {
|
||||
return props.question.answers.filter(answer => answer.right_wrong).length > 1;
|
||||
});
|
||||
|
||||
const correctAnswersCount = computed(() => {
|
||||
return props.question.answers.filter(answer => answer.right_wrong).length;
|
||||
});
|
||||
|
||||
const shouldShowMultipleChoiceFeedback = computed(() => {
|
||||
if (!isPracticeMode.value || !isMultipleChoice.value || !props.answers[props.currentQuestion]) {
|
||||
return false;
|
||||
}
|
||||
return props.answers[props.currentQuestion].length === correctAnswersCount.value;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.currentQuestion,
|
||||
(newVal) => {
|
||||
@@ -151,8 +120,7 @@ export default {
|
||||
|
||||
return {
|
||||
isMultipleChoice,
|
||||
isPracticeMode,
|
||||
shouldShowMultipleChoiceFeedback
|
||||
isPracticeMode
|
||||
};
|
||||
},
|
||||
emits: ['change-question'],
|
||||
@@ -160,14 +128,6 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.text-success {
|
||||
color: #4CAF50 !important;
|
||||
}
|
||||
|
||||
.text-error {
|
||||
color: #FF5252 !important;
|
||||
}
|
||||
|
||||
.v-card {
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
|
||||
|
||||
@@ -45,23 +45,13 @@
|
||||
<template #buttons="{ cardValue }">
|
||||
<v-btn
|
||||
class="mr-2"
|
||||
color="teal-lighten-5"
|
||||
color="teal-darken-1"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="showResults(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-chart-bar" class="text-teal-darken-1" />
|
||||
<span class="text-teal-darken-1">Результаты</span>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="cardValue.remaining_attempts > 0"
|
||||
color="teal-darken-1"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="retryTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-refresh" />
|
||||
<span>Пересдать ({{ cardValue.remaining_attempts }})</span>
|
||||
<v-icon start icon="mdi-chart-bar" />
|
||||
<span>Результаты</span>
|
||||
</v-btn>
|
||||
</template>
|
||||
</CatalogTest>
|
||||
@@ -165,11 +155,36 @@
|
||||
@unassign="unassignEmployee"
|
||||
:class="{'w-100': $vuetify.display.smAndDown}"
|
||||
/>
|
||||
|
||||
<!-- Модальное окно результатов теста -->
|
||||
<v-dialog v-model="showResultsDialog" :max-width="$vuetify.display.smAndDown ? '90%' : '800'" persistent>
|
||||
<v-card class="rounded-lg">
|
||||
<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>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn icon="mdi-close" variant="text" @click="showResultsDialog = false" color="white"></v-btn>
|
||||
</v-card-title>
|
||||
<v-card-text class="pa-4">
|
||||
<TestResults
|
||||
v-if="testResults"
|
||||
:testFinished="true"
|
||||
:testPassed="testResults.passed"
|
||||
:correctAnswers="testResults.correct_answers"
|
||||
:answeredQuestions="testResults.total_answers"
|
||||
:totalQuestions="testResults.total_questions"
|
||||
:formattedTime="testResults.time_spent"
|
||||
:questions="testResults.questions"
|
||||
:userAnswers="testResults.user_answers"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CatalogTest from '@/components/testing/CatalogTest.vue';
|
||||
import TestResults from '@/components/testing/TestResults.vue';
|
||||
import { axiosApiInstance, deleteTest as apiDeleteTest, assignTest, getTestToUser, deleteTestingRecord } from '@/utils/axios-api';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -182,6 +197,7 @@ export default {
|
||||
VoteConstructor,
|
||||
CatalogTest,
|
||||
AssignTestDialog,
|
||||
TestResults,
|
||||
},
|
||||
setup() {
|
||||
const accountStore = useAccountStore();
|
||||
@@ -194,6 +210,8 @@ export default {
|
||||
const selectedTestId = ref(null);
|
||||
const assignedEmployees = ref([]);
|
||||
const assignedEmployeesDetails = ref([]);
|
||||
const showResultsDialog = ref(false);
|
||||
const testResults = ref(null);
|
||||
|
||||
const getTestById = () => {
|
||||
const status = activeTab.value === 2 ? '' :
|
||||
@@ -339,8 +357,28 @@ export default {
|
||||
};
|
||||
|
||||
// Показать результаты теста
|
||||
const showResults = (id) => {
|
||||
router.push(`/test/results/${id}`);
|
||||
const showResults = async (id) => {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/tests/testdetail/${id}/`);
|
||||
|
||||
// Преобразуем данные теста в формат, ожидаемый компонентом TestResults
|
||||
testResults.value = {
|
||||
passed: true, // В данном случае всегда true, так как это завершенный тест
|
||||
total_questions: response.data.question_count,
|
||||
total_answers: response.data.question_count, // В завершенном тесте все ответы даны
|
||||
correct_answers: Math.ceil((response.data.pass_perc / 100) * response.data.question_count), // Минимальное количество правильных ответов для прохождения
|
||||
time_spent: `${response.data.time} мин`,
|
||||
questions: response.data.questions,
|
||||
user_answers: response.data.questions.map(q =>
|
||||
q.answers.find(a => a.right_wrong)?.name || []
|
||||
)
|
||||
};
|
||||
|
||||
showResultsDialog.value = true;
|
||||
} catch (error) {
|
||||
console.error('Ошибка при получении данных теста:', error);
|
||||
alert('Произошла ошибка при загрузке данных теста');
|
||||
}
|
||||
};
|
||||
|
||||
// Попытка пересдачи теста
|
||||
@@ -364,7 +402,8 @@ export default {
|
||||
getTestById,
|
||||
startTest,
|
||||
showResults,
|
||||
retryTest,
|
||||
showResultsDialog,
|
||||
testResults,
|
||||
assignedEmployees,
|
||||
assignedEmployeesDetails,
|
||||
assignedEmployeesCount
|
||||
@@ -372,3 +411,19 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.results-dialog .v-card {
|
||||
width: 100%;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.results-dialog .v-card-title {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.results-dialog .v-card-text {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user