fix [P-227]: сдача, несдача тестирования
This commit is contained in:
1 parent
25810b0fcc
commit
c78b427546
2 files changed
+122
-2
No files matched your search
@@ -34,6 +34,9 @@
|
|||||||
:answeredQuestions="answeredQuestions"
|
:answeredQuestions="answeredQuestions"
|
||||||
:totalQuestions="data.question_count"
|
:totalQuestions="data.question_count"
|
||||||
:formattedTime="formattedTime"
|
:formattedTime="formattedTime"
|
||||||
|
:questions="data?.questions"
|
||||||
|
:userAnswers="answers"
|
||||||
|
@restart="startTest"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Диалог подтверждения завершения теста -->
|
<!-- Диалог подтверждения завершения теста -->
|
||||||
@@ -138,11 +141,19 @@ export default {
|
|||||||
const startTest = async () => {
|
const startTest = async () => {
|
||||||
await deactivateOldTestings(testId);
|
await deactivateOldTestings(testId);
|
||||||
|
|
||||||
|
await getTestById(testId);
|
||||||
|
|
||||||
testStarted.value = true;
|
testStarted.value = true;
|
||||||
testFinished.value = false;
|
testFinished.value = false;
|
||||||
|
|
||||||
|
answers.value = Array(data.value.questions.length).fill(null);
|
||||||
|
|
||||||
data.value = { ...data.value, time: data.value.time * 60 };
|
data.value = { ...data.value, time: data.value.time * 60 };
|
||||||
|
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
|
||||||
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 };
|
||||||
|
|||||||
@@ -14,17 +14,35 @@
|
|||||||
<v-icon size="64" color="error" class="shake">mdi-close-circle</v-icon>
|
<v-icon size="64" color="error" class="shake">mdi-close-circle</v-icon>
|
||||||
<div class="text-h6 error--text mt-2 fade-in">Не расстраивайтесь!</div>
|
<div class="text-h6 error--text mt-2 fade-in">Не расстраивайтесь!</div>
|
||||||
<div class="text-body-1 error--text fade-in">Попробуйте еще раз</div>
|
<div class="text-body-1 error--text fade-in">Попробуйте еще раз</div>
|
||||||
|
<v-btn
|
||||||
|
v-if="isPracticeMode"
|
||||||
|
color="teal-darken-4"
|
||||||
|
class="mt-4 px-6"
|
||||||
|
@click="$emit('restart')"
|
||||||
|
>
|
||||||
|
Пройти заново
|
||||||
|
<v-icon class="ml-2">mdi-reload</v-icon>
|
||||||
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<v-row class="mt-2">
|
<v-row class="mt-2">
|
||||||
<v-col cols="12" sm="4">
|
<v-col cols="12" sm="4">
|
||||||
<v-card class="pa-4 text-center result-card" elevation="2" :color="testPassed ? 'success-light' : 'error-light'">
|
<v-card
|
||||||
|
class="pa-4 text-center result-card"
|
||||||
|
elevation="2"
|
||||||
|
:color="testPassed ? 'success-light' : 'error-light'"
|
||||||
|
:class="{ 'cursor-pointer': isPracticeMode }"
|
||||||
|
@click="showAnswersDialog = isPracticeMode"
|
||||||
|
>
|
||||||
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
|
<v-icon size="36" :color="testPassed ? 'success' : 'error'" class="mb-2">
|
||||||
mdi-checkbox-marked-circle
|
mdi-checkbox-marked-circle
|
||||||
</v-icon>
|
</v-icon>
|
||||||
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
|
<p class="text-h5 mb-1">{{ correctAnswers }}/{{ totalQuestions }}</p>
|
||||||
<div class="text-body-2">Правильных ответов</div>
|
<div class="text-body-2">
|
||||||
|
Правильных ответов
|
||||||
|
<v-icon v-if="isPracticeMode" small color="primary">mdi-information</v-icon>
|
||||||
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
@@ -44,11 +62,63 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Модальное окно с правильными ответами -->
|
||||||
|
<v-dialog v-model="showAnswersDialog" max-width="600" v-if="isPracticeMode">
|
||||||
|
<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">
|
||||||
|
<span>Правильные ответы</span>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn icon="mdi-close" variant="text" @click="showAnswersDialog = false" color="white"></v-btn>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text class="pa-4">
|
||||||
|
<v-expansion-panels>
|
||||||
|
<v-expansion-panel
|
||||||
|
v-for="(question, index) in questions"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<v-expansion-panel-title>
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-icon
|
||||||
|
:color="isQuestionCorrect(index) ? 'success' : 'error'"
|
||||||
|
class="mr-2"
|
||||||
|
>
|
||||||
|
{{ isQuestionCorrect(index) ? 'mdi-check-circle' : 'mdi-close-circle' }}
|
||||||
|
</v-icon>
|
||||||
|
<span>Вопрос {{ index + 1 }}</span>
|
||||||
|
</div>
|
||||||
|
</v-expansion-panel-title>
|
||||||
|
<v-expansion-panel-text>
|
||||||
|
<p class="mb-2 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-1">
|
||||||
|
<v-icon
|
||||||
|
:color="answer.right_wrong ? 'success' : ''"
|
||||||
|
size="small"
|
||||||
|
class="mr-1"
|
||||||
|
>
|
||||||
|
{{ answer.right_wrong ? 'mdi-check' : 'mdi-minus' }}
|
||||||
|
</v-icon>
|
||||||
|
<span :class="{ 'font-weight-bold': answer.right_wrong }">
|
||||||
|
{{ answer.name }}
|
||||||
|
</span>
|
||||||
|
<span v-if="answer.right_wrong" class="text-success">(правильный ответ)</span>
|
||||||
|
</div>
|
||||||
|
</v-expansion-panel-text>
|
||||||
|
</v-expansion-panel>
|
||||||
|
</v-expansion-panels>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
emits: ['restart'],
|
||||||
props: {
|
props: {
|
||||||
testFinished: Boolean,
|
testFinished: Boolean,
|
||||||
testPassed: Boolean,
|
testPassed: Boolean,
|
||||||
@@ -56,6 +126,41 @@ export default {
|
|||||||
answeredQuestions: Number,
|
answeredQuestions: Number,
|
||||||
totalQuestions: Number,
|
totalQuestions: Number,
|
||||||
formattedTime: String,
|
formattedTime: String,
|
||||||
|
questions: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
userAnswers: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const route = useRoute();
|
||||||
|
const showAnswersDialog = ref(false);
|
||||||
|
|
||||||
|
const isPracticeMode = computed(() => !route.query.mode || route.query.mode === 'practice');
|
||||||
|
|
||||||
|
const isQuestionCorrect = (questionIndex) => {
|
||||||
|
const question = props.questions[questionIndex];
|
||||||
|
const userAnswer = props.userAnswers[questionIndex];
|
||||||
|
|
||||||
|
if (!userAnswer) return false;
|
||||||
|
|
||||||
|
if (Array.isArray(userAnswer)) {
|
||||||
|
const correctAnswers = question.answers.filter(a => a.right_wrong).map(a => a.name);
|
||||||
|
return userAnswer.length === correctAnswers.length &&
|
||||||
|
userAnswer.every(answer => correctAnswers.includes(answer));
|
||||||
|
}
|
||||||
|
|
||||||
|
return question.answers.find(a => a.name === userAnswer)?.right_wrong || false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
showAnswersDialog,
|
||||||
|
isPracticeMode,
|
||||||
|
isQuestionCorrect
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -88,6 +193,10 @@ export default {
|
|||||||
transform: translateY(-5px);
|
transform: translateY(-5px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.success-light {
|
.success-light {
|
||||||
background-color: #E8F5E9 !important;
|
background-color: #E8F5E9 !important;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user