refactor [P-36 УМТ]: страница конкретного теста

This commit is contained in:
Denzel committed 2025-02-18 13:55:59 +03:00
1 parent e6327bfcb0
commit aed9a39a2f
5 files changed
+51 -14

No files matched your search

@@ -22,7 +22,9 @@
<v-col cols="auto" class="d-flex flex-grow-1">
<div class="d-flex flex-column justify-center flex-grow-1">
<div class="text-body-1 font-weight-medium mb-2">{{ cardValue.name }}</div>
<div class="text-body-1 text-disabled mb-2">{{ cardValue.description }}</div>
<div class="text-body-1 text-disabled mb-2" style="max-width: 600px">
{{ cardValue.description }}
</div>
<div class="d-flex ga-4">
<slot name="results"></slot>
<div v-for="icon in activeTabIcon">
@@ -33,7 +35,7 @@
</div>
</v-col>
<v-col cols="auto" class="align-self-center">
<slot name="buttons"></slot>
<slot name="buttons" :cardValue="cardValue"></slot>
</v-col>
</v-row>
</v-card>
@@ -57,10 +57,16 @@ import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
import QuestionBlock from '@/components/testing/QuestionBlock.vue';
import TestResults from '@/components/testing/TestResults.vue';
import { axiosApiInstance } from '@/utils/axios-api';
import { useRoute } from 'vue-router';
import { useAccountStore } from '../../store/AccountStore';
// import fernet from 'fernet';
export default {
components: { BodyDetailTesting, HeaderDetailTesting, QuestionBlock, TestResults },
setup() {
const route = useRoute();
const accountStore = useAccountStore();
const testId = route.params.id;
const testStarted = ref(false);
const testFinished = ref(false);
const showFinishDialog = ref(false);
@@ -74,6 +80,35 @@ export default {
console.log(data.value);
};
// const userLogin = accountStore.user;
// const encryptedData =
// 'gAAAAABntEv1Gi_kxhY4EJTyxFetzeiNaE5uu4w43lzljCw9_2xJzLkFM7Gj08cS5eZ0ULw_s_eLAI_Jxf2nVYh_fK4Z5EAhVA==';
//
// async function decryptData(encryptedData, userLogin) {
// const encoder = new TextEncoder();
// const userKeyBuffer = await crypto.subtle.digest('SHA-256', encoder.encode(userLogin));
//
// // Конвертация ArrayBuffer в Base64
// const userKeyArray = Array.from(new Uint8Array(userKeyBuffer));
// const base64Key = btoa(String.fromCharCode(...userKeyArray));
//
// // Создаём секретный ключ
// const secret = new fernet.Secret(base64Key);
//
// // Расшифровываем данные
// const token = new fernet.Token({
// secret: secret,
// token: encryptedData,
// ttl: 0,
// });
//
// return token.decode();
// }
//
// decryptData(encryptedData, userLogin)
// .then((decrypted) => console.log('Расшифрованное значение:', decrypted))
// .catch((err) => console.error('Ошибка расшифровки:', err));
const formattedTime = computed(() => {
if (!data.value?.time) return '00:00';
@@ -147,7 +182,7 @@ export default {
});
onMounted(() => {
getTestById(1);
getTestById(testId);
});
return {
@@ -4,7 +4,7 @@
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
</v-card-title>
<v-card-text>
<h3>{{ question.name }}</h3>
<h3 class="mb-4">{{ question.name }}</h3>
<v-img
v-if="question.file"
:src="`http://127.0.0.1:8000${question.file}`"
@@ -12,10 +12,10 @@
/>
<v-radio-group v-model="answers[currentQuestion]">
<v-radio
v-for="(option, index) in question.settings.options"
v-for="(option, index) in question.answers"
:key="index"
:label="option"
:value="option"
:label="option.name"
:value="option.name"
/>
</v-radio-group>
</v-card-text>
+3 -3
View File
@@ -30,12 +30,12 @@
<!-- Вкладка каталога -->
<v-tabs-window-item class="w-75 mx-auto h-100">
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Каталог">
<template #buttons>
<template #buttons="{ cardValue }">
<v-btn
class="mr-2 text-teal-darken-1"
color="#00897B1F"
elevation="0"
@click="goToTest"
@click="goToTest(cardValue.id)"
>
Тренироваться
</v-btn>
@@ -92,7 +92,7 @@ export default {
{ value: 2, title: 'Каталог' },
]);
const goToTest = () => router.push('/test/testdetail/:id');
const goToTest = (id) => router.push(`/test/testdetail/${id}`);
return {
activeTab,
+4 -4
View File
@@ -12,7 +12,7 @@
<v-col class="pa-0 overflow-hidden">
<v-window v-model="currentTab" class="h-100">
<!-- Текущие голосования -->
<v-tabs-window-item
<v-window-item
v-for="x in ['active', 'completed']"
:value="x"
class="h-100 overflow-auto"
@@ -29,15 +29,15 @@
</v-col>
</v-row>
<NoneVote v-else :current="currentTab === 'active' ? 'Текущих' : 'Завершенных'" />
</v-tabs-window-item>
</v-window-item>
<!-- Конструктор -->
<v-tabs-window-item
<v-window-item
v-if="accountStore.user.is_staff"
class="h-100 overflow-auto"
value="constructor"
>
<VoteConstructor @updating="updating" ref="constructor" />
</v-tabs-window-item>
</v-window-item>
</v-window>
<!-- Модальные окна -->