Merge branch 'develop' into test
This commit is contained in:
commit
f7fa255a03
16 files changed
+599
-112
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing
|
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing, TestFile
|
||||||
import nested_admin
|
import nested_admin
|
||||||
|
|
||||||
class TestAnswerInline(nested_admin.NestedStackedInline):
|
class TestAnswerInline(nested_admin.NestedStackedInline):
|
||||||
@@ -13,8 +13,13 @@ class TestQuestionInline(nested_admin.NestedStackedInline):
|
|||||||
inlines = [TestAnswerInline]
|
inlines = [TestAnswerInline]
|
||||||
fields = ('name', 'file')
|
fields = ('name', 'file')
|
||||||
|
|
||||||
|
class TestFileInline(nested_admin.NestedStackedInline):
|
||||||
|
model = TestFile
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
fields = ('file',)
|
||||||
class TestAdmin(nested_admin.NestedModelAdmin):
|
class TestAdmin(nested_admin.NestedModelAdmin):
|
||||||
inlines = [TestQuestionInline]
|
inlines = [TestFileInline, TestQuestionInline]
|
||||||
|
|
||||||
class TestAttemptInline(admin.TabularInline):
|
class TestAttemptInline(admin.TabularInline):
|
||||||
model = TestAttempt
|
model = TestAttempt
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-01 10:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0009_alter_testquestion_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="test",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(max_length=500, verbose_name="Название теста"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testanswer",
|
||||||
|
name="name",
|
||||||
|
field=models.TextField(verbose_name="Ответ"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 10:02
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0010_alter_test_name_alter_testanswer_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestFile",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"file",
|
||||||
|
models.FileField(upload_to="tests/test_files/", verbose_name="Приложение"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"test",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="test_files",
|
||||||
|
to="tests.test",
|
||||||
|
verbose_name="Тест",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Файл теста",
|
||||||
|
"verbose_name_plural": "Файлы Теста",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 10:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0011_testfile"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testfile",
|
||||||
|
name="file",
|
||||||
|
field=models.FileField(
|
||||||
|
upload_to="tests/files/help/%(test_id)s/", verbose_name="Приложение"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 11:01
|
||||||
|
|
||||||
|
import tests.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0012_alter_testfile_file"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testfile",
|
||||||
|
name="file",
|
||||||
|
field=models.FileField(upload_to=tests.models.id_path, verbose_name="Приложение"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -12,7 +12,7 @@ class Test(models.Model):
|
|||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
verbose_name='Лого Теста')
|
verbose_name='Лого Теста')
|
||||||
name = models.CharField(max_length=255, blank=False, verbose_name="Название теста")
|
name = models.CharField(max_length=500, blank=False, verbose_name="Название теста")
|
||||||
description = models.TextField(verbose_name='Описание')
|
description = models.TextField(verbose_name='Описание')
|
||||||
author = models.ForeignKey(User, on_delete=models.CASCADE,
|
author = models.ForeignKey(User, on_delete=models.CASCADE,
|
||||||
verbose_name='Создатель тестирования')
|
verbose_name='Создатель тестирования')
|
||||||
@@ -28,6 +28,26 @@ class Test(models.Model):
|
|||||||
verbose_name = "Тест"
|
verbose_name = "Тест"
|
||||||
verbose_name_plural = "Тесты"
|
verbose_name_plural = "Тесты"
|
||||||
|
|
||||||
|
def id_path(instance,filename):
|
||||||
|
return f'tests/files/help/{instance.test.id}/{filename}'
|
||||||
|
|
||||||
|
class TestFile(models.Model):
|
||||||
|
test = models.ForeignKey(Test, related_name="test_files",on_delete=models.CASCADE, verbose_name="Тест")
|
||||||
|
file = models.FileField(upload_to=id_path,
|
||||||
|
verbose_name='Приложение')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Файл теста"
|
||||||
|
verbose_name_plural = "Файлы Теста"
|
||||||
|
|
||||||
|
def delete(self, *args, **kwargs):
|
||||||
|
|
||||||
|
if self.file:
|
||||||
|
storage, path = self.file.storage, self.file.path
|
||||||
|
storage.delete(path)
|
||||||
|
|
||||||
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
class TestQuestion(models.Model):
|
class TestQuestion(models.Model):
|
||||||
"""test questions"""
|
"""test questions"""
|
||||||
name = models.TextField(blank=False, verbose_name="Вопрос")
|
name = models.TextField(blank=False, verbose_name="Вопрос")
|
||||||
@@ -51,7 +71,7 @@ class TestQuestion(models.Model):
|
|||||||
|
|
||||||
class TestAnswer(models.Model):
|
class TestAnswer(models.Model):
|
||||||
"""answer options for the question"""
|
"""answer options for the question"""
|
||||||
name = models.CharField(max_length=255, blank=False, verbose_name="Ответ")
|
name = models.TextField(blank=False, verbose_name="Ответ")
|
||||||
file = models.FileField(upload_to='tests/answer_files/',
|
file = models.FileField(upload_to='tests/answer_files/',
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# pylint: skip-file
|
# pylint: skip-file
|
||||||
import base64
|
import base64
|
||||||
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
@@ -107,17 +108,29 @@ class TestResultSerializer(serializers.ModelSerializer):
|
|||||||
model = TestResult
|
model = TestResult
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestFileSerializer(serializers.ModelSerializer):
|
||||||
|
filename= serializers.SerializerMethodField()
|
||||||
|
class Meta:
|
||||||
|
model = TestFile
|
||||||
|
fields = ['file','filename']
|
||||||
|
|
||||||
|
def get_filename(self,obj):
|
||||||
|
return os.path.basename(obj.file.name)
|
||||||
|
|
||||||
|
|
||||||
class TestsSerializer(serializers.ModelSerializer):
|
class TestsSerializer(serializers.ModelSerializer):
|
||||||
datestart = serializers.SerializerMethodField()
|
datestart = serializers.SerializerMethodField()
|
||||||
dateend = serializers.SerializerMethodField()
|
dateend = serializers.SerializerMethodField()
|
||||||
is_passed = serializers.SerializerMethodField()
|
is_passed = serializers.SerializerMethodField()
|
||||||
is_active = serializers.SerializerMethodField()
|
is_active = serializers.SerializerMethodField()
|
||||||
|
files = serializers.SerializerMethodField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Test
|
model = Test
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_files(self,obj):
|
||||||
|
return TestFileSerializer(obj.test_files, many=True).data
|
||||||
|
|
||||||
def get_datestart(self, obj):
|
def get_datestart(self, obj):
|
||||||
user = self.context['request'].user
|
user = self.context['request'].user
|
||||||
if not user.is_authenticated:
|
if not user.is_authenticated:
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ class TestCreate(APIView):
|
|||||||
create test
|
create test
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
|
||||||
self.create_test(request)
|
self.create_test(request)
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
@@ -155,7 +156,7 @@ class TestCreate(APIView):
|
|||||||
return Response({"status": "error", "message": str(e)}, status=400)
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
except DatabaseError as e:
|
except DatabaseError as e:
|
||||||
print(e)
|
|
||||||
return Response({"status": "error", "message": str(e)}, status=400)
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
def create_test(self, request):
|
def create_test(self, request):
|
||||||
@@ -181,6 +182,10 @@ class TestCreate(APIView):
|
|||||||
is_available = True
|
is_available = True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
test_files=[TestFile(file=file,test=test) for file in request.FILES.getlist("test_files")]
|
||||||
|
if len(test_files)>0:
|
||||||
|
TestFile.objects.bulk_create(test_files)
|
||||||
|
|
||||||
questions_files = {
|
questions_files = {
|
||||||
file.name: file for file in request.FILES.getlist("questionsfiles")
|
file.name: file for file in request.FILES.getlist("questionsfiles")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "1.2.1",
|
"version": "1.2.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -15,7 +15,11 @@
|
|||||||
<template v-for="(x, i) in carous" :key="i">
|
<template v-for="(x, i) in carous" :key="i">
|
||||||
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
||||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||||
<v-card v-if="x.text !== '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
<v-card
|
||||||
|
v-if="x.text !== '' || x.title != null"
|
||||||
|
class="bgCard h-100 d-flex flex-column"
|
||||||
|
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||||
|
>
|
||||||
<v-card-title
|
<v-card-title
|
||||||
v-if="x.title != null"
|
v-if="x.title != null"
|
||||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||||
@@ -176,7 +180,17 @@ export default {
|
|||||||
<style>
|
<style>
|
||||||
.titles {
|
.titles {
|
||||||
font-family: cursive !important;
|
font-family: cursive !important;
|
||||||
background: #ffffff8c;
|
background: rgba(255, 255, 255, 0.7) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.textareas .v-field__input {
|
.textareas .v-field__input {
|
||||||
@@ -188,6 +202,16 @@ export default {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.titles, .text-text_carous, .text-text_caroustext-black, .v-card-title, .v-card-text, .v-textarea .v-field__input {
|
.titles, .text-text_carous, .text-text_caroustext-black, .v-card-title, .v-card-text, .v-textarea .v-field__input {
|
||||||
color: #111 !important;
|
color: #111 !important;
|
||||||
text-shadow: none !important;
|
text-shadow: none !important;
|
||||||
|
|||||||
@@ -125,20 +125,26 @@ export default {
|
|||||||
|
|
||||||
const time = Number(props.data.time);
|
const time = Number(props.data.time);
|
||||||
|
|
||||||
// Если число больше 60, значит это секунды (таймер запущен)
|
// Всегда считаем, что время приходит в минутах
|
||||||
if (time > 60) {
|
if (time >= 60) {
|
||||||
const minutes = Math.floor(time / 60);
|
const hours = Math.floor(time / 60);
|
||||||
const seconds = time % 60;
|
const minutes = time % 60;
|
||||||
return {
|
if (minutes === 0) {
|
||||||
value: `${minutes} мин. ${seconds}`,
|
return {
|
||||||
unit: "сек.",
|
value: hours,
|
||||||
};
|
unit: hours === 1 ? "час" : hours >= 2 && hours <= 4 ? "часа" : "часов",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
value: `${hours} ч. ${minutes}`,
|
||||||
|
unit: minutes === 1 ? "мин." : "мин.",
|
||||||
|
};
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Если меньше 60, значит это минуты (таймер не запущен)
|
// Если меньше 60, значит это просто минуты
|
||||||
return {
|
return {
|
||||||
value: time,
|
value: time,
|
||||||
unit:
|
unit: time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
||||||
time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,50 @@
|
|||||||
class="scrollable-textarea"
|
class="scrollable-textarea"
|
||||||
></v-textarea>
|
></v-textarea>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="isTest" class="pt-2">
|
||||||
|
<div class="text-overline text-grey mb-2">Материалы к тесту:</div>
|
||||||
|
|
||||||
|
<!-- Кнопка добавления файла -->
|
||||||
|
<v-btn
|
||||||
|
variant="outlined"
|
||||||
|
color="teal-darken-4"
|
||||||
|
prepend-icon="mdi-plus"
|
||||||
|
class="mb-3"
|
||||||
|
@click="triggerFileInput"
|
||||||
|
>
|
||||||
|
Добавить файл
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<!-- Скрытый input для выбора файлов -->
|
||||||
|
<input
|
||||||
|
ref="fileInput"
|
||||||
|
type="file"
|
||||||
|
multiple
|
||||||
|
style="display: none"
|
||||||
|
@change="addFiles"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Список добавленных файлов -->
|
||||||
|
<div v-if="testFilesCount > 0" class="mb-2">
|
||||||
|
<v-card variant="outlined" class="pa-2">
|
||||||
|
<div class="text-caption text-grey mb-2">
|
||||||
|
Выбрано файлов: {{ testFilesCount }}
|
||||||
|
</div>
|
||||||
|
<v-chip
|
||||||
|
v-for="(file, index) in testFiles"
|
||||||
|
:key="`file-${index}-${file.name}-${file.size}`"
|
||||||
|
color="teal-darken-4"
|
||||||
|
closable
|
||||||
|
class="ma-1"
|
||||||
|
@click:close="removeFile(index)"
|
||||||
|
>
|
||||||
|
<v-icon start>mdi-file</v-icon>
|
||||||
|
{{ file.name }}
|
||||||
|
<span class="text-caption ml-2">({{ Math.round(file.size / 1024) }} KB)</span>
|
||||||
|
</v-chip>
|
||||||
|
</v-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div v-if="!isTest" class="pt-2 d-flex align-center">
|
<div v-if="!isTest" class="pt-2 d-flex align-center">
|
||||||
<span class="text-overline text-grey text-center">Публикация новости: </span>
|
<span class="text-overline text-grey text-center">Публикация новости: </span>
|
||||||
<v-switch
|
<v-switch
|
||||||
@@ -98,6 +142,7 @@ export default {
|
|||||||
emits: ['update:form'],
|
emits: ['update:form'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const fileInput = ref(null);
|
||||||
const isTestRoute = computed(() => {
|
const isTestRoute = computed(() => {
|
||||||
return route.path && String(route.path).includes('test');
|
return route.path && String(route.path).includes('test');
|
||||||
});
|
});
|
||||||
@@ -112,10 +157,10 @@ export default {
|
|||||||
appoint: false,
|
appoint: false,
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
endDate: new Date(),
|
endDate: new Date(),
|
||||||
|
test_files: [],
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Отправляем изменения в родителя
|
|
||||||
watch(
|
watch(
|
||||||
localForm,
|
localForm,
|
||||||
(newForm) => {
|
(newForm) => {
|
||||||
@@ -145,7 +190,7 @@ export default {
|
|||||||
localForm.value.startDate instanceof Date
|
localForm.value.startDate instanceof Date
|
||||||
? localForm.value.startDate
|
? localForm.value.startDate
|
||||||
: new Date();
|
: new Date();
|
||||||
const newDate = new Date(oldDate); // создаём новый объект с копией даты
|
const newDate = new Date(oldDate);
|
||||||
newDate.setHours(hours, minutes, 0, 0);
|
newDate.setHours(hours, minutes, 0, 0);
|
||||||
localForm.value.startDate = newDate;
|
localForm.value.startDate = newDate;
|
||||||
},
|
},
|
||||||
@@ -169,6 +214,50 @@ export default {
|
|||||||
return `${hours}:${minutes}`;
|
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 {
|
return {
|
||||||
localForm,
|
localForm,
|
||||||
returnstart,
|
returnstart,
|
||||||
@@ -177,7 +266,13 @@ export default {
|
|||||||
selectedTimeEnd,
|
selectedTimeEnd,
|
||||||
timeOptions,
|
timeOptions,
|
||||||
isTestRoute,
|
isTestRoute,
|
||||||
isTest: props.isTest
|
isTest: props.isTest,
|
||||||
|
fileInput,
|
||||||
|
triggerFileInput,
|
||||||
|
addFiles,
|
||||||
|
removeFile,
|
||||||
|
testFiles,
|
||||||
|
testFilesCount
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -197,6 +197,24 @@
|
|||||||
</div>
|
</div>
|
||||||
<p v-else class="text-grey text-center mt-2">Не выбрано</p>
|
<p v-else class="text-grey text-center mt-2">Не выбрано</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Материалы к тесту на странице подтверждения -->
|
||||||
|
<div class="mt-2 mb-4">
|
||||||
|
<p><strong class="px-2">Материалы к тесту:</strong></p>
|
||||||
|
<div v-if="form.test_files && form.test_files.length > 0" class="mt-2">
|
||||||
|
<v-chip
|
||||||
|
v-for="(file, index) in form.test_files"
|
||||||
|
:key="index"
|
||||||
|
color="primary"
|
||||||
|
size="small"
|
||||||
|
class="me-2 mb-2"
|
||||||
|
>
|
||||||
|
<v-icon start icon="mdi-paperclip"></v-icon>
|
||||||
|
{{ file.name }}
|
||||||
|
</v-chip>
|
||||||
|
</div>
|
||||||
|
<p v-else class="text-grey text-center mt-2">Не выбрано</p>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<p><strong class="px-2">Вопросы:</strong></p>
|
<p><strong class="px-2">Вопросы:</strong></p>
|
||||||
@@ -341,7 +359,8 @@ export default {
|
|||||||
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||||
questions: [],
|
questions: [],
|
||||||
news: false,
|
news: false,
|
||||||
appoint: false
|
appoint: false,
|
||||||
|
test_files: []
|
||||||
});
|
});
|
||||||
|
|
||||||
const testSettings = ref({
|
const testSettings = ref({
|
||||||
@@ -525,6 +544,7 @@ export default {
|
|||||||
}))
|
}))
|
||||||
})),
|
})),
|
||||||
image: testImage.value,
|
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),
|
pass_perc: Number(testSettings.value.pass_perc),
|
||||||
time: Number(testSettings.value.time),
|
time: Number(testSettings.value.time),
|
||||||
question_count: actualTestQuestionCount.value,
|
question_count: actualTestQuestionCount.value,
|
||||||
@@ -577,7 +597,8 @@ export default {
|
|||||||
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||||
questions: [],
|
questions: [],
|
||||||
news: false,
|
news: false,
|
||||||
appoint: false
|
appoint: false,
|
||||||
|
test_files: []
|
||||||
};
|
};
|
||||||
testSettings.value = {
|
testSettings.value = {
|
||||||
pass_perc: '70',
|
pass_perc: '70',
|
||||||
|
|||||||
@@ -152,13 +152,22 @@
|
|||||||
</v-main>
|
</v-main>
|
||||||
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
||||||
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
|
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
|
||||||
<v-card-text class="justify-center bgCard h-100 ma-3 d-flex flex-column">
|
<v-card-text
|
||||||
<v-row class="bgText flex-grow-0">
|
class="justify-center bgCard h-100 ma-3 d-flex flex-column"
|
||||||
|
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||||
|
>
|
||||||
|
<v-row
|
||||||
|
class="bgText flex-grow-0"
|
||||||
|
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||||
|
>
|
||||||
<v-col class="text-center textcolor font-weight-black text-h3 pb-0">
|
<v-col class="text-center textcolor font-weight-black text-h3 pb-0">
|
||||||
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row class="bgText flex-grow-0">
|
<v-row
|
||||||
|
class="bgText flex-grow-0"
|
||||||
|
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||||
|
>
|
||||||
<v-col class="text-subtitle-1 text-center textcolor pt-0">
|
<v-col class="text-subtitle-1 text-center textcolor pt-0">
|
||||||
Авторизуйтесь для получения доступа к контенту портала
|
Авторизуйтесь для получения доступа к контенту портала
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -382,6 +391,25 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bgText {
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.textcolor {
|
||||||
|
color: #2f535e !important;
|
||||||
|
}
|
||||||
|
|
||||||
.mystat {
|
.mystat {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
|
|||||||
@@ -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) {
|
async function deleteVote(id) {
|
||||||
try {
|
try {
|
||||||
await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`);
|
await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`);
|
||||||
@@ -210,12 +190,20 @@ async function getVoteResult(id) {
|
|||||||
|
|
||||||
async function createTest(testData) {
|
async function createTest(testData) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
if (testData.image) {
|
if (testData.image) {
|
||||||
formData.append('image', 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) => {
|
testData.questions.forEach((question, qIndex) => {
|
||||||
if (question.image) {
|
if (question.image) {
|
||||||
formData.append('questionsfiles', question.image);
|
formData.append('questionsfiles', question.image);
|
||||||
|
|||||||
@@ -16,28 +16,73 @@
|
|||||||
<v-window-item class="my-2 mx-auto h-100" :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp}">
|
<v-window-item class="my-2 mx-auto h-100" :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp}">
|
||||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Назначенные">
|
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Назначенные">
|
||||||
<template #buttons="{ cardValue }">
|
<template #buttons="{ cardValue }">
|
||||||
<v-btn
|
<div class="d-flex flex-column gap-2">
|
||||||
class="mr-2 custom-btn"
|
<div class="d-flex gap-2">
|
||||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
<v-btn
|
||||||
variant="flat"
|
v-if="cardValue.files && cardValue.files.length > 0"
|
||||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
class="mr-2 custom-btn"
|
||||||
elevation="0"
|
:color="$vuetify.theme.dark ? 'blue' : 'blue-lighten-5'"
|
||||||
@click="goToTest(cardValue.id)"
|
variant="flat"
|
||||||
>
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
elevation="0"
|
||||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
@click="toggleMaterials(cardValue.id)"
|
||||||
</v-btn>
|
>
|
||||||
<v-btn
|
<v-icon start :icon="expandedMaterials.has(cardValue.id) ? 'mdi-chevron-up' : 'mdi-chevron-down'" :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'" />
|
||||||
class="custom-btn"
|
<span :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'">Материалы</span>
|
||||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-darken-1'"
|
</v-btn>
|
||||||
variant="flat"
|
<v-btn
|
||||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
class="mr-2 custom-btn"
|
||||||
elevation="0"
|
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||||
@click="startTest(cardValue.id)"
|
variant="flat"
|
||||||
>
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
<v-icon start icon="mdi-play" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined" />
|
elevation="0"
|
||||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined">Пройти тест</span>
|
@click="goToTest(cardValue.id)"
|
||||||
</v-btn>
|
>
|
||||||
|
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||||
|
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
class="custom-btn"
|
||||||
|
:color="$vuetify.theme.dark ? 'teal' : 'teal-darken-1'"
|
||||||
|
variant="flat"
|
||||||
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
|
elevation="0"
|
||||||
|
@click="startTest(cardValue.id)"
|
||||||
|
>
|
||||||
|
<v-icon start icon="mdi-play" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined" />
|
||||||
|
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined">Пройти тест</span>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
<!-- Аккордеон с материалами -->
|
||||||
|
<v-expand-transition>
|
||||||
|
<div v-if="expandedMaterials.has(cardValue.id) && cardValue.files && cardValue.files.length > 0">
|
||||||
|
<v-card class="mt-2">
|
||||||
|
<v-card-text class="py-0">
|
||||||
|
<v-list density="compact">
|
||||||
|
<v-list-item
|
||||||
|
v-for="(file, index) in cardValue.files"
|
||||||
|
:key="index"
|
||||||
|
class="px-2"
|
||||||
|
@click="downloadFile(file.file, file.filename)"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-icon
|
||||||
|
:icon="getFileIcon(file.filename)"
|
||||||
|
:color="getFileColor(file.filename)"
|
||||||
|
class="mr-3"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<v-list-item-title class="text-body-2">{{ file.filename }}</v-list-item-title>
|
||||||
|
<template v-slot:append>
|
||||||
|
<v-icon icon="mdi-download" color="primary" />
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</div>
|
||||||
|
</v-expand-transition>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CatalogTest>
|
</CatalogTest>
|
||||||
</v-window-item>
|
</v-window-item>
|
||||||
@@ -65,49 +110,98 @@
|
|||||||
<v-window-item :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp, 'mx-auto': true, 'h-100': true}">
|
<v-window-item :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp, 'mx-auto': true, 'h-100': true}">
|
||||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" class="position-relative" title="Каталог">
|
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" class="position-relative" title="Каталог">
|
||||||
<template #buttons="{ cardValue }">
|
<template #buttons="{ cardValue }">
|
||||||
<div v-if="accountStore.user.is_staff" class="d-flex" :class="{'position-relative': $vuetify.display.smAndDown, 'position-absolute top-0 right-0': $vuetify.display.mdAndUp}">
|
<div class="d-flex flex-column gap-2">
|
||||||
<v-btn
|
<div class="d-flex flex-wrap gap-2 align-start justify-space-between">
|
||||||
class="mr-2 custom-btn"
|
<!-- Основные кнопки пользователя -->
|
||||||
:color="$vuetify.theme.dark ? 'amber' : 'amber-lighten-5'"
|
<div class="d-flex gap-2 flex-wrap">
|
||||||
variant="flat"
|
<v-btn
|
||||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
v-if="cardValue.files && cardValue.files.length > 0"
|
||||||
elevation="0"
|
class="mr-2 custom-btn"
|
||||||
@click="openAddDialog(cardValue.id)"
|
:color="$vuetify.theme.dark ? 'blue' : 'blue-lighten-5'"
|
||||||
>
|
variant="flat"
|
||||||
<v-icon icon="mdi-account-plus" :class="$vuetify.theme.dark ? 'text-amber-lighten-1' : 'text-amber-darken-2'" />
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
<v-tooltip
|
elevation="0"
|
||||||
activator="parent"
|
@click="toggleMaterials(cardValue.id)"
|
||||||
location="top"
|
>
|
||||||
>Назначить сотрудникам</v-tooltip>
|
<v-icon start :icon="expandedMaterials.has(cardValue.id) ? 'mdi-chevron-up' : 'mdi-chevron-down'" :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'" />
|
||||||
</v-btn>
|
<span :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'">Материалы</span>
|
||||||
<v-btn
|
</v-btn>
|
||||||
v-if="cardValue.author === accountStore.user.id"
|
<v-btn
|
||||||
class="mr-2 custom-btn"
|
class="mr-2 custom-btn"
|
||||||
:color="$vuetify.theme.dark ? 'red' : 'red-lighten-5'"
|
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||||
variant="flat"
|
variant="flat"
|
||||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
elevation="0"
|
elevation="0"
|
||||||
@click="openDeleteDialog(cardValue.id)"
|
@click="goToTest(cardValue.id)"
|
||||||
>
|
>
|
||||||
<v-icon icon="mdi-delete" :class="$vuetify.theme.dark ? 'text-red-lighten-1' : 'text-red-darken-2'" />
|
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||||
<v-tooltip
|
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||||
activator="parent"
|
</v-btn>
|
||||||
location="top"
|
</div>
|
||||||
>Удалить тестирование</v-tooltip>
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<v-btn
|
<!-- Служебные кнопки администратора -->
|
||||||
class="mr-2 custom-btn"
|
<div v-if="accountStore.user.is_staff" class="d-flex gap-2">
|
||||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
<v-btn
|
||||||
variant="flat"
|
class="custom-btn"
|
||||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
:color="$vuetify.theme.dark ? 'amber' : 'amber-lighten-5'"
|
||||||
elevation="0"
|
variant="flat"
|
||||||
@click="goToTest(cardValue.id)"
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
>
|
elevation="0"
|
||||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
@click="openAddDialog(cardValue.id)"
|
||||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
>
|
||||||
</v-btn>
|
<v-icon icon="mdi-account-plus" :class="$vuetify.theme.dark ? 'text-amber-lighten-1' : 'text-amber-darken-2'" />
|
||||||
|
<v-tooltip
|
||||||
|
activator="parent"
|
||||||
|
location="top"
|
||||||
|
>Назначить сотрудникам</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
v-if="cardValue.author === accountStore.user.id"
|
||||||
|
class="custom-btn"
|
||||||
|
:color="$vuetify.theme.dark ? 'red' : 'red-lighten-5'"
|
||||||
|
variant="flat"
|
||||||
|
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||||
|
elevation="0"
|
||||||
|
@click="openDeleteDialog(cardValue.id)"
|
||||||
|
>
|
||||||
|
<v-icon icon="mdi-delete" :class="$vuetify.theme.dark ? 'text-red-lighten-1' : 'text-red-darken-2'" />
|
||||||
|
<v-tooltip
|
||||||
|
activator="parent"
|
||||||
|
location="top"
|
||||||
|
>Удалить тестирование</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Аккордеон с материалами -->
|
||||||
|
<v-expand-transition>
|
||||||
|
<div v-if="expandedMaterials.has(cardValue.id) && cardValue.files && cardValue.files.length > 0">
|
||||||
|
<v-card class="mt-2">
|
||||||
|
<v-card-text class="py-0">
|
||||||
|
<v-list density="compact">
|
||||||
|
<v-list-item
|
||||||
|
v-for="(file, index) in cardValue.files"
|
||||||
|
:key="index"
|
||||||
|
class="px-2"
|
||||||
|
@click="downloadFile(file.file, file.filename)"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-icon
|
||||||
|
:icon="getFileIcon(file.filename)"
|
||||||
|
:color="getFileColor(file.filename)"
|
||||||
|
class="mr-3"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<v-list-item-title class="text-body-2">{{ file.filename }}</v-list-item-title>
|
||||||
|
<template v-slot:append>
|
||||||
|
<v-icon icon="mdi-download" color="primary" />
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</div>
|
||||||
|
</v-expand-transition>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CatalogTest>
|
</CatalogTest>
|
||||||
</v-window-item>
|
</v-window-item>
|
||||||
@@ -234,6 +328,7 @@ export default {
|
|||||||
const assignedEmployeesDetails = ref([]);
|
const assignedEmployeesDetails = ref([]);
|
||||||
const showResultsDialog = ref(false);
|
const showResultsDialog = ref(false);
|
||||||
const testResults = ref(null);
|
const testResults = ref(null);
|
||||||
|
const expandedMaterials = ref(new Set()); // Для управления раскрытием материалов по ID теста
|
||||||
const snackbar = ref({
|
const snackbar = ref({
|
||||||
show: false,
|
show: false,
|
||||||
text: '',
|
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 {
|
return {
|
||||||
activeTab,
|
activeTab,
|
||||||
tabs,
|
tabs,
|
||||||
@@ -516,6 +689,11 @@ export default {
|
|||||||
assignedEmployees,
|
assignedEmployees,
|
||||||
assignedEmployeesDetails,
|
assignedEmployeesDetails,
|
||||||
assignedEmployeesCount,
|
assignedEmployeesCount,
|
||||||
|
expandedMaterials,
|
||||||
|
toggleMaterials,
|
||||||
|
downloadFile,
|
||||||
|
getFileIcon,
|
||||||
|
getFileColor,
|
||||||
snackbar
|
snackbar
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user