Merge branch 'Alex' into develop

This commit is contained in:
Nukeap committed 2025-01-31 13:40:00 +03:00
commit f99d7463a9
6 files changed
+141 -202

No files matched your search

+5 -1
View File
@@ -55,8 +55,12 @@ class GetTests(generics.ListAPIView):
return status_filters.get(status, Test.objects.none()).order_by('dateend') return status_filters.get(status, Test.objects.none()).order_by('dateend')
def set_attemps_number(self, user, tests): def set_attemps_number(self, user, tests):
test_ids = [test.id for test in tests]
attempt_counts = TestAttempt.objects.filter(user=user, test__id__in=test_ids).values('test').annotate(count=Count('test'))
attempt_counts = {item['test']: item['count'] for item in attempt_counts}
for test in tests: for test in tests:
test.attemps_number = get_attempt_count(user=user, test=test) test.attemps_number = test.attemps_number - attempt_counts.get(test.id, 0)
class TestDetail(generics.RetrieveUpdateDestroyAPIView): class TestDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = Test.objects.all() queryset = Test.objects.all()
@@ -0,0 +1,18 @@
<template>
<v-container>
<HeaderDetailTesting />
</v-container>
</template>
<script>
import HeaderDetailTesting from './HeaderDetailTesting.vue';
export default {
components: {
HeaderDetailTesting,
}
}
</script>
@@ -0,0 +1,36 @@
<template>
<v-row class="ma-0 border-b-thin">
<v-col cols="auto" class="flex-grow-1">
<div class="text-subtitle-1 text-grey-lighten-1">Тест</div>
<div class="text-h5">{{ title }}</div>
</v-col>
<v-col cols="auto" class="d-flex flex-column">
<div class="align-self-end text-grey-lighten-1">!!!</div>
<div class="text-h4 text-grey-lighten-1">{{ time }}Таймер сюдаааа!!!</div>
</v-col>
</v-row>
<v-row class="ma-0 border-b-thin">
<v-col cols="auto" class="flex-grow-1">
<v-btn elevation="1" color="teal-darken-1" size="x-small" rounded icon="mdi-information-outline"/>
</v-col>
<v-col cols="auto" class="align-self-center">
<v-btn elevation="0" color="#0000001F" rounded="1">Выйти</v-btn>
</v-col>
</v-row>
</template>
<script>
export default {
props: {
title: {
type: String,
default: 'Название теста здесь',
},
time: {
}
}
}
</script>
+6
View File
@@ -177,6 +177,12 @@ const routes = [
ico: "mdi-account", ico: "mdi-account",
}, },
}, },
{
path: "/test/testdetail/:id",
name: "TestDetail",
component: () =>
import("@/components/testing/DetailCardTest.vue")
},
{ {
path: '/secret', path: '/secret',
name: 'Secret Page', name: 'Secret Page',
+73 -198
View File
@@ -1,223 +1,98 @@
<template> <template>
<v-container> <v-container :fluid="true">
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4"> <v-tabs v-model="activeTab" class="mb-2 text-teal-darken-4">
<v-tab>Назначенные ({{ scheduledTests.length }})</v-tab> <v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
<v-tab>Завершенные ({{ completedTests.length }})</v-tab>
<v-tab>Каталог</v-tab>
</v-tabs> </v-tabs>
<v-tabs-window v-model="activeTab" class="border-t-thin">
<v-tabs-window v-model="activeTab"> <!-- Вкладка назначенные -->
<!-- Назначенные --> <v-tabs-window-item class="my-2 ">
<v-tabs-window-item> <CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
<v-card outlined> <template #buttons>
<v-card-title> <v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Назначенные Тренироваться
</v-card-title>
<v-text-field
v-model="search"
class="mx-4"
clearable
label="Найти тестирование по названию"
variant="outlined"
/>
<v-data-table
:headers="headers"
:items="filteredScheduledTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
</v-btn> </v-btn>
<v-btn color="teal-darken-4">Пройти</v-btn> <v-btn color="teal-darken-1" elevation="0">
</template> Пройти
</v-data-table>
</v-card>
</v-tabs-window-item>
<!-- Завершенные -->
<v-tabs-window-item>
<v-card class="mb-6" outlined>
<v-card-title>
Завершенные
</v-card-title>
<v-data-table
:headers="headers"
:items="filteredCompletedTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn color="teal-darken-4">Посмотреть результаты</v-btn>
</template>
</v-data-table>
</v-card>
</v-tabs-window-item>
<!-- Каталог -->
<v-tabs-window-item>
<v-card outlined>
<v-card-title>
Каталог
</v-card-title>
<v-text-field
v-model="search"
class="mx-4"
clearable
label="Найти тестирование по названию"
variant="outlined"
/>
<v-data-table
:headers="headers"
:items="filteredTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
</v-btn> </v-btn>
<v-btn color="teal-darken-4">Пройти</v-btn>
</template> </template>
</v-data-table> </CatalogTest>
</v-card> </v-tabs-window-item>
<!-- Вкладка завершенных -->
<v-tabs-window-item>
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
<!-- Здесь отобразить результат теста после того как будет готов БЭК и УМТ -->
<template #results>
<!-- <div>
<v-icon icon="mdi-calendar-clock" size="large" />
<span class="ml-1">12354</span>
</div> -->
</template>
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Результаты
</v-btn>
</template>
</CatalogTest>
</v-tabs-window-item>
<!-- Вкладка каталога -->
<v-tabs-window-item>
<CatalogTest title="Каталог" :activeTab="activeTab" :testingCard="getAllTests">
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться
</v-btn>
</template>
</CatalogTest>
</v-tabs-window-item> </v-tabs-window-item>
</v-tabs-window> </v-tabs-window>
</v-container> </v-container>
</template> </template>
<script> <script>
import {computed, ref} from 'vue'; import CatalogTest from "@/components/testing/CatalogTest.vue";
import TestCard from "@/components/tests/TestCard.vue"; import { axiosApiInstance } from "@/utils/axios-api";
import { ref, computed, watch } from "vue"
export default { export default {
components: {TestCard}, components: {
CatalogTest
},
setup() { setup() {
const activeTab = ref(0); const activeTab = ref(0);
const search = ref(''); const currentTest = ref('')
const headers = [ const getAllTests = ref([])
{text: 'Картинка', value: 'image', sortable: false},
{text: 'Название', value: 'title', align: 'start'},
{text: 'Действия', value: 'actions', sortable: false},
];
const tests = ref([ const getTestById = () => {
{ let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : ''
id: 1, axiosApiInstance.get(`/api/tests/gettests/${status}`).then(resp => getAllTests.value = resp.data).finally(() => {
title: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий', if (activeTab.value == 0) {
type: 'test', currentTest.value = getAllTests.value.length
description: 'Краткое описание тестирования', }
date: '2025-02-28', })
questions: 20, }
time: '15 минут',
attempts: 1,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
{
id: 2,
title: 'Удобство раздела тестирования',
type: 'survey',
description: 'Опрос среди сотрудников ЦОД МФ',
date: '2025-06-22',
questions: 28,
time: null,
attempts: null,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
{
id: 3,
title: 'Законченная карточка законченного тестирования',
type: 'survey',
description: 'законченное описание законченного тестирования',
date: '2024-06-22',
questions: 1,
time: null,
attempts: null,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
]);
const currentDate = new Date(); getTestById()
const scheduledTests = computed(() => { watch (() => activeTab.value,
return tests.value.filter(test => new Date(test.date) > currentDate); () => {
}); getTestById()
}
)
const completedTests = computed(() => { const tabs = computed(() => [
return tests.value.filter(test => new Date(test.date) <= currentDate); { value: 0, title: `Назначенные (${currentTest.value})`, },
}); { value: 1, title: 'Завершенные', },
{ value: 2, title: 'Каталог', },
])
const filteredScheduledTests = computed(() => {
if (!search.value) return scheduledTests.value;
return scheduledTests.value.filter(test =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
const filteredCompletedTests = computed(() => {
if (!search.value) return completedTests.value;
return completedTests.value.filter(test =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
const filteredTests = computed(() => {
if (!search.value) return tests.value.filter(test => new Date(test.date) > currentDate);
return tests.value.filter(test => new Date(test.date) > currentDate)
.filter((test) =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
return { return {
activeTab, activeTab,
search, tabs,
headers, getAllTests,
tests, }
filteredTests, }
filteredScheduledTests,
filteredCompletedTests,
scheduledTests,
completedTests,
};
},
};
</script>
<style>
.v-data-table__wrapper {
overflow-x: auto;
} }
</style> </script>
+3 -3
View File
@@ -20,11 +20,12 @@
<!-- Вкладка завершенных --> <!-- Вкладка завершенных -->
<v-tabs-window-item> <v-tabs-window-item>
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests"> <CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
<!-- Здесь отобразить результат теста после того как будет готов БЭК и УМТ -->
<template #results> <template #results>
<div> <!-- <div>
<v-icon icon="mdi-calendar-clock" size="large" /> <v-icon icon="mdi-calendar-clock" size="large" />
<span class="ml-1">12354</span> <span class="ml-1">12354</span>
</div> </div> -->
</template> </template>
<template #buttons> <template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0"> <v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
@@ -44,7 +45,6 @@
</CatalogTest> </CatalogTest>
</v-tabs-window-item> </v-tabs-window-item>
</v-tabs-window> </v-tabs-window>
{{ getAllTests }}
</v-container> </v-container>
</template> </template>