diff --git a/.env.base b/.env.base index 1cbaecd80..c701aff1f 100644 --- a/.env.base +++ b/.env.base @@ -55,7 +55,7 @@ NGINX_EXTERNAL_PORT=80 NGINX_INTERNAL_PORT=80 RUN_WITH_DOCS=False -PRODUCTION=True +PRODUCTION=False MYDEBUG=False DJANGO_CSRF_TRUSTED_ORIGINS="http://localhost, http://portal-t, http://127.0.0.1, http://portal9966/" diff --git a/src/back/portal/settings.py b/src/back/portal/settings.py index 061b92da4..f10ca130a 100644 --- a/src/back/portal/settings.py +++ b/src/back/portal/settings.py @@ -140,11 +140,11 @@ ASGI_APPLICATION = "portal.asgi.application" DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", - "NAME": os.getenv("DB_NAME"), # Имя базы данных - "USER": os.getenv("DB_USER"), # Имя пользователя - "PASSWORD": os.getenv("DB_PASSWORD"), # Пароль - "HOST": os.getenv("DB_HOST"), # Хост - "PORT": os.getenv("DB_INTERNAL_PORT"), # Порт + "NAME": "accounting", # Имя базы данных + "USER": "root", # Имя пользователя + "PASSWORD": "yourpassword", # Пароль + "HOST": "db", # Хост + "PORT": "3306", # Порт } } diff --git a/src/front/src/components/testing/BodyDetailTesting.vue b/src/front/src/components/testing/BodyDetailTesting.vue index fc302986b..a2692d4ad 100644 --- a/src/front/src/components/testing/BodyDetailTesting.vue +++ b/src/front/src/components/testing/BodyDetailTesting.vue @@ -125,20 +125,26 @@ export default { const time = Number(props.data.time); - // Если число больше 60, значит это секунды (таймер запущен) - if (time > 60) { - const minutes = Math.floor(time / 60); - const seconds = time % 60; - return { - value: `${minutes} мин. ${seconds}`, - unit: "сек.", - }; + // Всегда считаем, что время приходит в минутах + if (time >= 60) { + const hours = Math.floor(time / 60); + const minutes = time % 60; + if (minutes === 0) { + return { + value: hours, + unit: hours === 1 ? "час" : hours >= 2 && hours <= 4 ? "часа" : "часов", + }; + } else { + return { + value: `${hours} ч. ${minutes}`, + unit: minutes === 1 ? "мин." : "мин.", + }; + } } else { - // Если меньше 60, значит это минуты (таймер не запущен) + // Если меньше 60, значит это просто минуты return { value: time, - unit: - time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут", + unit: time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут", }; } }); diff --git a/src/front/src/components/vote/ConstructorVote/MainInfo.vue b/src/front/src/components/vote/ConstructorVote/MainInfo.vue index bb827a182..c2f927fbc 100644 --- a/src/front/src/components/vote/ConstructorVote/MainInfo.vue +++ b/src/front/src/components/vote/ConstructorVote/MainInfo.vue @@ -18,6 +18,49 @@ class="scrollable-textarea" > +
+
Материалы к тесту:
+ + + + Добавить файл + + + + + + +
+ +
+ Выбрано файлов: {{ testFilesCount }} +
+ + mdi-file + {{ file.name }} + ({{ Math.round(file.size / 1024) }} KB) + +
+
+
Публикация новости: { return route.path && String(route.path).includes('test'); }); @@ -112,10 +156,10 @@ export default { appoint: false, startDate: new Date(), endDate: new Date(), + test_files: [], } ); - // Отправляем изменения в родителя watch( localForm, (newForm) => { @@ -145,7 +189,7 @@ export default { localForm.value.startDate instanceof Date ? localForm.value.startDate : new Date(); - const newDate = new Date(oldDate); // создаём новый объект с копией даты + const newDate = new Date(oldDate); newDate.setHours(hours, minutes, 0, 0); localForm.value.startDate = newDate; }, @@ -169,6 +213,50 @@ export default { return `${hours}:${minutes}`; }); + // Обработчики для файлов + const triggerFileInput = () => { + fileInput.value?.click(); + }; + + const addFiles = (event) => { + const files = Array.from(event.target.files || []); + + if (files.length > 0) { + // Инициализируем массив файлов если его нет + if (!localForm.value.test_files) { + localForm.value.test_files = []; + } + + // Добавляем новые файлы к существующим + const currentFiles = [...localForm.value.test_files]; // Создаем копию + const newFiles = [...currentFiles, ...files]; + localForm.value.test_files = newFiles; + } + + // Очищаем input для возможности выбора тех же файлов снова + event.target.value = ''; + }; + + const removeFile = (index) => { + const currentFiles = [...(localForm.value.test_files || [])]; + const fileToRemove = currentFiles[index]; + + if (index >= 0 && index < currentFiles.length) { + currentFiles.splice(index, 1); + localForm.value.test_files = currentFiles; + } + }; + + // Computed для корректного отображения файлов + const testFiles = computed(() => { + const files = localForm.value.test_files; + return Array.isArray(files) ? files : []; + }); + + const testFilesCount = computed(() => { + return testFiles.value.length; + }); + return { localForm, returnstart, @@ -177,7 +265,13 @@ export default { selectedTimeEnd, timeOptions, isTestRoute, - isTest: props.isTest + isTest: props.isTest, + fileInput, + triggerFileInput, + addFiles, + removeFile, + testFiles, + testFilesCount }; }, }; diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index 12f4c08fd..3890d4aba 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -197,6 +197,24 @@

Не выбрано

+ + +
+

Материалы к тесту:

+
+ + + {{ file.name }} + +
+

Не выбрано

+

Вопросы:

@@ -341,7 +359,8 @@ export default { endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)), questions: [], news: false, - appoint: false + appoint: false, + test_files: [] }); const testSettings = ref({ @@ -525,6 +544,7 @@ export default { })) })), image: testImage.value, + test_files: (form.value.test_files && form.value.test_files.length > 0) ? form.value.test_files : undefined, pass_perc: Number(testSettings.value.pass_perc), time: Number(testSettings.value.time), question_count: actualTestQuestionCount.value, @@ -577,7 +597,8 @@ export default { endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)), questions: [], news: false, - appoint: false + appoint: false, + test_files: [] }; testSettings.value = { pass_perc: '70', diff --git a/src/front/src/utils/axios-api.js b/src/front/src/utils/axios-api.js index bd2fd122d..0316c38b2 100644 --- a/src/front/src/utils/axios-api.js +++ b/src/front/src/utils/axios-api.js @@ -149,26 +149,6 @@ async function getVoteDetail(id) { } } -// async function updateVote(id, updatedData) { -// try { -// const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData); -// return response.data; -// } catch (error) { -// console.error("Ошибка обновления голосования:", error); -// throw error; -// } -// } - -// async function patchVote(id, partialData) { -// try { -// const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData); -// return response.data; -// } catch (error) { -// console.error("Ошибка частичного обновления голосования:", error); -// throw error; -// } -// } - async function deleteVote(id) { try { await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`); @@ -210,12 +190,20 @@ async function getVoteResult(id) { async function createTest(testData) { try { + const formData = new FormData(); if (testData.image) { formData.append('image', testData.image); } + // Добавляем файлы материалов теста + if (testData.test_files && testData.test_files.length > 0) { + testData.test_files.forEach((file) => { + formData.append('test_files', file); + }); + } + testData.questions.forEach((question, qIndex) => { if (question.image) { formData.append('questionsfiles', question.image); diff --git a/src/front/src/views/TestHomePage.vue b/src/front/src/views/TestHomePage.vue index 92009920e..a5e9c0298 100644 --- a/src/front/src/views/TestHomePage.vue +++ b/src/front/src/views/TestHomePage.vue @@ -16,28 +16,73 @@ @@ -65,49 +110,98 @@ @@ -234,6 +328,7 @@ export default { const assignedEmployeesDetails = ref([]); const showResultsDialog = ref(false); const testResults = ref(null); + const expandedMaterials = ref(new Set()); // Для управления раскрытием материалов по ID теста const snackbar = ref({ show: false, text: '', @@ -494,6 +589,84 @@ export default { } }; + const toggleMaterials = (testId) => { + const newExpanded = new Set(expandedMaterials.value); + if (newExpanded.has(testId)) { + newExpanded.delete(testId); + } else { + newExpanded.add(testId); + } + expandedMaterials.value = newExpanded; + }; + + const downloadFile = (fileUrl, filename) => { + const link = document.createElement('a'); + link.href = fileUrl; + link.download = filename; + link.target = '_blank'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }; + + const getFileIcon = (filename) => { + const extension = filename.split('.').pop().toLowerCase(); + switch (extension) { + case 'pdf': + return 'mdi-file-pdf-box'; + case 'doc': + case 'docx': + return 'mdi-file-word-box'; + case 'xls': + case 'xlsx': + return 'mdi-file-excel-box'; + case 'ppt': + case 'pptx': + return 'mdi-file-powerpoint-box'; + case 'txt': + return 'mdi-file-document'; + case 'zip': + case 'rar': + case '7z': + return 'mdi-file-zip-box'; + case 'jpg': + case 'jpeg': + case 'png': + case 'gif': + return 'mdi-file-image-box'; + default: + return 'mdi-file-document-outline'; + } + }; + + const getFileColor = (filename) => { + const extension = filename.split('.').pop().toLowerCase(); + switch (extension) { + case 'pdf': + return 'red'; + case 'doc': + case 'docx': + return 'blue'; + case 'xls': + case 'xlsx': + return 'green'; + case 'ppt': + case 'pptx': + return 'orange'; + case 'zip': + case 'rar': + case '7z': + return 'purple'; + case 'jpg': + case 'jpeg': + case 'png': + case 'gif': + return 'pink'; + default: + return 'grey'; + } + }; + return { activeTab, tabs, @@ -516,6 +689,11 @@ export default { assignedEmployees, assignedEmployeesDetails, assignedEmployeesCount, + expandedMaterials, + toggleMaterials, + downloadFile, + getFileIcon, + getFileColor, snackbar }; },