diff --git a/src/back/about_inspection/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/about_inspection/migrations/__pycache__/0001_initial.cpython-310.pyc index 5cede0f26..e911c828e 100644 Binary files a/src/back/about_inspection/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/about_inspection/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/about_inspection/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/about_inspection/migrations/__pycache__/__init__.cpython-310.pyc index cb371f7b8..728be7769 100644 Binary files a/src/back/about_inspection/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/about_inspection/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/accounts/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/accounts/migrations/__pycache__/0001_initial.cpython-310.pyc index 5cdb51cbe..881179603 100644 Binary files a/src/back/accounts/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/accounts/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/accounts/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/accounts/migrations/__pycache__/__init__.cpython-310.pyc index e889456ed..1937b86c3 100644 Binary files a/src/back/accounts/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/accounts/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/calendar_of_events/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/calendar_of_events/migrations/__pycache__/0001_initial.cpython-310.pyc index 68b50fecf..954af8bf7 100644 Binary files a/src/back/calendar_of_events/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/calendar_of_events/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/calendar_of_events/migrations/__pycache__/0002_alter_calendar_author.cpython-310.pyc b/src/back/calendar_of_events/migrations/__pycache__/0002_alter_calendar_author.cpython-310.pyc index 156dcb424..de376c07d 100644 Binary files a/src/back/calendar_of_events/migrations/__pycache__/0002_alter_calendar_author.cpython-310.pyc and b/src/back/calendar_of_events/migrations/__pycache__/0002_alter_calendar_author.cpython-310.pyc differ diff --git a/src/back/calendar_of_events/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/calendar_of_events/migrations/__pycache__/__init__.cpython-310.pyc index e2b8d6f7d..6eb83438a 100644 Binary files a/src/back/calendar_of_events/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/calendar_of_events/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/commeteresp/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/commeteresp/migrations/__pycache__/0001_initial.cpython-310.pyc index ad1958f7d..366c69d21 100644 Binary files a/src/back/commeteresp/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/commeteresp/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/commeteresp/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/commeteresp/migrations/__pycache__/__init__.cpython-310.pyc index 56858ac04..2891d9815 100644 Binary files a/src/back/commeteresp/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/commeteresp/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/general_vacation/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/general_vacation/migrations/__pycache__/0001_initial.cpython-310.pyc index 8e1e7eed7..ae80862f8 100644 Binary files a/src/back/general_vacation/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/general_vacation/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/general_vacation/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/general_vacation/migrations/__pycache__/__init__.cpython-310.pyc index 45cc44c6c..74fe08105 100644 Binary files a/src/back/general_vacation/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/general_vacation/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/navigation/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/navigation/migrations/__pycache__/0001_initial.cpython-310.pyc index 66bb53c2d..ad32a6e64 100644 Binary files a/src/back/navigation/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/navigation/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/navigation/migrations/__pycache__/0002_news_vote.cpython-310.pyc b/src/back/navigation/migrations/__pycache__/0002_news_vote.cpython-310.pyc index 7dd73c689..b1472238e 100644 Binary files a/src/back/navigation/migrations/__pycache__/0002_news_vote.cpython-310.pyc and b/src/back/navigation/migrations/__pycache__/0002_news_vote.cpython-310.pyc differ diff --git a/src/back/navigation/migrations/__pycache__/0003_news_vote.cpython-310.pyc b/src/back/navigation/migrations/__pycache__/0003_news_vote.cpython-310.pyc index 5a5f8977c..3219123de 100644 Binary files a/src/back/navigation/migrations/__pycache__/0003_news_vote.cpython-310.pyc and b/src/back/navigation/migrations/__pycache__/0003_news_vote.cpython-310.pyc differ diff --git a/src/back/navigation/migrations/__pycache__/0004_remove_news_vote.cpython-310.pyc b/src/back/navigation/migrations/__pycache__/0004_remove_news_vote.cpython-310.pyc index 9cf7ab124..4c13fb64e 100644 Binary files a/src/back/navigation/migrations/__pycache__/0004_remove_news_vote.cpython-310.pyc and b/src/back/navigation/migrations/__pycache__/0004_remove_news_vote.cpython-310.pyc differ diff --git a/src/back/navigation/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/navigation/migrations/__pycache__/__init__.cpython-310.pyc index af390d965..7f1631bc6 100644 Binary files a/src/back/navigation/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/navigation/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/safety/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/safety/migrations/__pycache__/0001_initial.cpython-310.pyc index 6df7bf8cf..87f31ff1a 100644 Binary files a/src/back/safety/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/safety/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/safety/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/safety/migrations/__pycache__/__init__.cpython-310.pyc index 99d48a974..603d89ed9 100644 Binary files a/src/back/safety/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/safety/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/tests/admin.py b/src/back/tests/admin.py index dc0563d7c..c2926eca7 100644 --- a/src/back/tests/admin.py +++ b/src/back/tests/admin.py @@ -5,11 +5,13 @@ import nested_admin class TestAnswerInline(nested_admin.NestedStackedInline): model = TestAnswer extra = 0 + fields = ('name', 'file', 'right_wrong') class TestQuestionInline(nested_admin.NestedStackedInline): model = TestQuestion extra = 0 inlines = [TestAnswerInline] + fields = ('name', 'file') class TestAdmin(nested_admin.NestedModelAdmin): inlines = [TestQuestionInline] diff --git a/src/back/tests/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0001_initial.cpython-310.pyc index 63832c29f..0a64f3542 100644 Binary files a/src/back/tests/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0002_test_dateend_test_datestart.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0002_test_dateend_test_datestart.cpython-310.pyc index 1007c5602..30ece3314 100644 Binary files a/src/back/tests/migrations/__pycache__/0002_test_dateend_test_datestart.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0002_test_dateend_test_datestart.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0003_testing_is_active.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0003_testing_is_active.cpython-310.pyc index f9eea5d27..74ef8d5c6 100644 Binary files a/src/back/tests/migrations/__pycache__/0003_testing_is_active.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0003_testing_is_active.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0004_test_is_available.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0004_test_is_available.cpython-310.pyc index 1bbf199c9..fbfc01778 100644 Binary files a/src/back/tests/migrations/__pycache__/0004_test_is_available.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0004_test_is_available.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0005_testing_datestart_testing_news.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0005_testing_datestart_testing_news.cpython-310.pyc index 49921c085..bfca8d81f 100644 Binary files a/src/back/tests/migrations/__pycache__/0005_testing_datestart_testing_news.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0005_testing_datestart_testing_news.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0006_testresult_question_alter_testresult_answer.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0006_testresult_question_alter_testresult_answer.cpython-310.pyc index b48889c3e..f8683e388 100644 Binary files a/src/back/tests/migrations/__pycache__/0006_testresult_question_alter_testresult_answer.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0006_testresult_question_alter_testresult_answer.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/0007_alter_testattempt_testing_alter_testing_user.cpython-310.pyc b/src/back/tests/migrations/__pycache__/0007_alter_testattempt_testing_alter_testing_user.cpython-310.pyc index ce13c308f..36ce42c22 100644 Binary files a/src/back/tests/migrations/__pycache__/0007_alter_testattempt_testing_alter_testing_user.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/0007_alter_testattempt_testing_alter_testing_user.cpython-310.pyc differ diff --git a/src/back/tests/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/tests/migrations/__pycache__/__init__.cpython-310.pyc index 721ee85aa..079986991 100644 Binary files a/src/back/tests/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/tests/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/userauth/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/userauth/migrations/__pycache__/0001_initial.cpython-310.pyc index 1c0bd9757..de5cc29ac 100644 Binary files a/src/back/userauth/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/userauth/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/userauth/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/userauth/migrations/__pycache__/__init__.cpython-310.pyc index 96a84006d..8ae244756 100644 Binary files a/src/back/userauth/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/userauth/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/vote/admin.py b/src/back/vote/admin.py index 19a39c4cc..6398499e8 100644 --- a/src/back/vote/admin.py +++ b/src/back/vote/admin.py @@ -1,6 +1,22 @@ from django.contrib import admin from .models import * +import nested_admin -admin.site.register(Vote) -admin.site.register(Question) -admin.site.register(Answer) \ No newline at end of file +# admin.site.register(Vote) +# admin.site.register(Question) +# admin.site.register(Answer) + +class AnswerInline(nested_admin.NestedTabularInline): + model = Answer + extra = 1 + fields = ('name', 'file') + +class QuestionInline(nested_admin.NestedStackedInline): + model = Question + inlines = [AnswerInline] + extra = 1 + fields = ('name', 'file') + +@admin.register(Vote) +class VoteAdmin(nested_admin.NestedModelAdmin): + inlines = [QuestionInline] \ No newline at end of file diff --git a/src/back/vote/migrations/0004_alter_answer_file_alter_answer_name_and_more.py b/src/back/vote/migrations/0004_alter_answer_file_alter_answer_name_and_more.py new file mode 100644 index 000000000..c5128c6b6 --- /dev/null +++ b/src/back/vote/migrations/0004_alter_answer_file_alter_answer_name_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 5.1.6 on 2025-06-19 08:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("vote", "0003_vote_news"), + ] + + operations = [ + migrations.AlterField( + model_name="answer", + name="file", + field=models.FileField( + blank=True, null=True, upload_to="vote/answer_files/", verbose_name="Картинка" + ), + ), + migrations.AlterField( + model_name="answer", + name="name", + field=models.CharField(max_length=255, verbose_name="Ответ"), + ), + migrations.AlterField( + model_name="question", + name="file", + field=models.ImageField( + blank=True, null=True, upload_to="vote/question_images/", verbose_name="Картинка" + ), + ), + migrations.AlterField( + model_name="question", + name="name", + field=models.CharField(max_length=255, verbose_name="Вопрос"), + ), + ] diff --git a/src/back/vote/migrations/__pycache__/0001_initial.cpython-310.pyc b/src/back/vote/migrations/__pycache__/0001_initial.cpython-310.pyc index c0ba47836..0cfbd6ae3 100644 Binary files a/src/back/vote/migrations/__pycache__/0001_initial.cpython-310.pyc and b/src/back/vote/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/src/back/vote/migrations/__pycache__/0002_initial.cpython-310.pyc b/src/back/vote/migrations/__pycache__/0002_initial.cpython-310.pyc index 47161d201..11a32e9d3 100644 Binary files a/src/back/vote/migrations/__pycache__/0002_initial.cpython-310.pyc and b/src/back/vote/migrations/__pycache__/0002_initial.cpython-310.pyc differ diff --git a/src/back/vote/migrations/__pycache__/0003_vote_news.cpython-310.pyc b/src/back/vote/migrations/__pycache__/0003_vote_news.cpython-310.pyc index 18e309ad6..29aa10ada 100644 Binary files a/src/back/vote/migrations/__pycache__/0003_vote_news.cpython-310.pyc and b/src/back/vote/migrations/__pycache__/0003_vote_news.cpython-310.pyc differ diff --git a/src/back/vote/migrations/__pycache__/__init__.cpython-310.pyc b/src/back/vote/migrations/__pycache__/__init__.cpython-310.pyc index e6738ebc3..8e6d02942 100644 Binary files a/src/back/vote/migrations/__pycache__/__init__.cpython-310.pyc and b/src/back/vote/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/src/back/vote/models.py b/src/back/vote/models.py index 08ff0a896..946affab2 100644 --- a/src/back/vote/models.py +++ b/src/back/vote/models.py @@ -26,9 +26,9 @@ class Vote(models.Model): verbose_name_plural = "Голосования" class Question(models.Model): - name = models.CharField(max_length=255) + name = models.CharField(max_length=255, verbose_name="Вопрос") vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE) - file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True) + file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True,verbose_name='Картинка') numb = models.PositiveIntegerField() settings = models.JSONField(default=dict, verbose_name='Json настроек голосования') @@ -40,8 +40,8 @@ class Question(models.Model): verbose_name_plural = "Вопросы" class Answer(models.Model): - name = models.CharField(max_length=255) - file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True) + name = models.CharField(max_length=255, verbose_name='Ответ') + file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True,verbose_name='Картинка') question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE) def __str__(self): diff --git a/src/front/src/components/UI/NewsCard.vue b/src/front/src/components/UI/NewsCard.vue index c956a7d6c..c16d25ce7 100644 --- a/src/front/src/components/UI/NewsCard.vue +++ b/src/front/src/components/UI/NewsCard.vue @@ -41,6 +41,7 @@ @@ -53,6 +54,7 @@ @@ -65,6 +67,7 @@ @@ -76,6 +79,7 @@ @@ -102,8 +106,7 @@ + + + + Нет доступных данных + + + {{ item.raw.familyname }} diff --git a/src/front/src/components/UI/fiousercard/listUser.vue b/src/front/src/components/UI/fiousercard/listUser.vue index aad468665..270f416fc 100644 --- a/src/front/src/components/UI/fiousercard/listUser.vue +++ b/src/front/src/components/UI/fiousercard/listUser.vue @@ -4,10 +4,11 @@ v-if="from_which == 'dialog-search'" class="pl-4 h-100 text-left pa-2" @click="open = true" + active-color="teal-darken-4" > @@ -23,16 +24,17 @@ v-if="from_which == 'top-user'" class="h-100 text-left pa-0 pl-0" @click="open = true" + active-color="teal-darken-4" > diff --git a/src/front/src/components/UI/my-helper.vue b/src/front/src/components/UI/my-helper.vue index 85df72a3a..eb45ddb76 100644 --- a/src/front/src/components/UI/my-helper.vue +++ b/src/front/src/components/UI/my-helper.vue @@ -11,7 +11,7 @@ v-bind="attrs" v-on="on" size="large" - color="indigo" + color="teal-darken-4" icon="mdi-owl" @click="menu = !menu" > diff --git a/src/front/src/components/carousel-list.vue b/src/front/src/components/carousel-list.vue index f6b966916..1df2878e7 100644 --- a/src/front/src/components/carousel-list.vue +++ b/src/front/src/components/carousel-list.vue @@ -9,7 +9,7 @@ hide-delimiters hide-delimiter-background :show-arrows="carous.length < 2 ? false : 'hover'" - color="white" + color="teal-darken-4" @update:modelValue="slidechanged" > @@ -187,3 +187,9 @@ export default { cursor: default !important; } + diff --git a/src/front/src/components/digital-letna.vue b/src/front/src/components/digital-letna.vue index f550fdf4d..a623477a4 100644 --- a/src/front/src/components/digital-letna.vue +++ b/src/front/src/components/digital-letna.vue @@ -28,7 +28,7 @@ @@ -234,4 +234,14 @@ export default { .fiction .v-input__control { display: none; } + + + \ No newline at end of file diff --git a/src/front/src/components/news-full.vue b/src/front/src/components/news-full.vue index d761338b9..3eb034173 100644 --- a/src/front/src/components/news-full.vue +++ b/src/front/src/components/news-full.vue @@ -282,7 +282,7 @@ variant="text" size="small" icon="mdi-delete" - color="delete_btn" + color="teal-darken-4" @click="deletComment(y.id, newsFull.id)" /> @@ -353,6 +353,7 @@ density="compact" variant="text" icon="mdi-close" + color="teal-darken-4" @click="dialogfoto = false" /> @@ -364,6 +365,7 @@ density="compact" variant="text" icon="mdi-chevron-left" + color="teal-darken-4" @click=" indximg != 0 ? (indximg -= 1) @@ -382,6 +384,7 @@ density="compact" variant="text" icon="mdi-chevron-right" + color="teal-darken-4" @click=" indximg != newsFull.gallery.length - 1 ? (indximg += 1) @@ -422,6 +425,7 @@ density="compact" variant="text" icon="mdi-close" + color="teal-darken-4" @click="dialogfotoOne = false" /> diff --git a/src/front/src/components/news-home.vue b/src/front/src/components/news-home.vue index 73b588d92..28beebca8 100644 --- a/src/front/src/components/news-home.vue +++ b/src/front/src/components/news-home.vue @@ -56,7 +56,7 @@ size="small" variant="text" icon="mdi-newspaper" - color="blue-darken-4" + color="teal-darken-4" :to='`/news`' /> diff --git a/src/front/src/components/testing/BodyDetailTesting.vue b/src/front/src/components/testing/BodyDetailTesting.vue index e88d0fd8a..fc302986b 100644 --- a/src/front/src/components/testing/BodyDetailTesting.vue +++ b/src/front/src/components/testing/BodyDetailTesting.vue @@ -57,12 +57,11 @@ {{ data?.question_count }} - - + + - Количество попыток: - {{ data?.attemps_number }} + Количество попыток: {{ remainingAttempts !== undefined ? remainingAttempts : data?.attemps_number }} @@ -75,13 +74,23 @@ - {{ isExamMode ? "Начать" : "Тренироваться" }} + + Все попытки израсходованы + @@ -100,8 +109,12 @@ export default { data: Object, isDialog: { type: Boolean, - default: false, + default: false }, + remainingAttempts: { + type: Number, + default: undefined + } }, setup(props) { const route = useRoute(); diff --git a/src/front/src/components/testing/CatalogTest.vue b/src/front/src/components/testing/CatalogTest.vue index 1ed17fb9c..73a385fcc 100644 --- a/src/front/src/components/testing/CatalogTest.vue +++ b/src/front/src/components/testing/CatalogTest.vue @@ -1,6 +1,7 @@ + + diff --git a/src/front/src/components/testing/DetailCardTest.vue b/src/front/src/components/testing/DetailCardTest.vue index 35e346983..ebafeff62 100644 --- a/src/front/src/components/testing/DetailCardTest.vue +++ b/src/front/src/components/testing/DetailCardTest.vue @@ -12,7 +12,7 @@ /> - + { const minutes = Math.floor(spentTime.value / 60); @@ -90,10 +91,23 @@ export default { }); const getTestById = async (id) => { + // Загружаем детали теста из API testdetail const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`); data.value = resp.data; try { + // Проверяем оставшиеся попытки из API gettests со статусом active + const activeTest = await getActiveTest(id); + + // Если нашли тест в активных, проверяем количество попыток + if (activeTest) { + remainingAttempts.value = activeTest.attemps_number; + } else { + // Если тест не найден в активных, устанавливаем 0 попыток + remainingAttempts.value = 0; + } + + // Получаем данные о назначениях теста const testingResp = await axiosApiInstance.get(`/api/tests/testingview/?test_id=${id}`); const userTestings = testingResp.data; if (userTestings?.length > 0) { @@ -133,6 +147,13 @@ export default { const startTest = async () => { await getTestById(testId); + // Проверяем попытки только для режима экзамена + const isExamMode = route.query.mode === 'exam'; + if (isExamMode && remainingAttempts.value !== undefined && remainingAttempts.value <= 0) { + console.log('Нет оставшихся попыток для прохождения теста'); + return; // Прерываем запуск теста если попыток не осталось + } + testStarted.value = true; testFinished.value = false; @@ -206,11 +227,15 @@ export default { const answers = ref([]); - watch(data.value?.questions, (newData) => { - if (newData && Array.isArray(newData.questions)) { - answers.value = newData.questions.map(() => null); - } - }); + watch( + () => data.value?.questions, + (newQuestions) => { + if (newQuestions && Array.isArray(newQuestions)) { + answers.value = newQuestions.map(() => null); + } + }, + { deep: true } + ); const correctAnswers = computed( () => @@ -274,6 +299,7 @@ export default { answeredQuestions, testPassed, data, + remainingAttempts, }; }, }; diff --git a/src/front/src/components/testing/QuestionBlock.vue b/src/front/src/components/testing/QuestionBlock.vue index 067a6672d..339687127 100644 --- a/src/front/src/components/testing/QuestionBlock.vue +++ b/src/front/src/components/testing/QuestionBlock.vue @@ -10,7 +10,7 @@ @@ -28,7 +28,7 @@ + + diff --git a/src/front/src/components/vote/ConstructorVote/MainInfo.vue b/src/front/src/components/vote/ConstructorVote/MainInfo.vue index 241a5c8d1..bb827a182 100644 --- a/src/front/src/components/vote/ConstructorVote/MainInfo.vue +++ b/src/front/src/components/vote/ConstructorVote/MainInfo.vue @@ -15,6 +15,7 @@ :rules="[rules.required]" label="Описание" variant="outlined" + class="scrollable-textarea" > @@ -183,5 +184,54 @@ export default { diff --git a/src/front/src/components/vote/ConstructorVote/QuestionItem.vue b/src/front/src/components/vote/ConstructorVote/QuestionItem.vue index aa91e35ba..d911358ac 100644 --- a/src/front/src/components/vote/ConstructorVote/QuestionItem.vue +++ b/src/front/src/components/vote/ConstructorVote/QuestionItem.vue @@ -45,7 +45,7 @@ > - Голосование по отделам: + Голосование: @@ -79,9 +82,11 @@ @update:model-value="toggleSelectAll" > - + {{ item.raw.familyname }} @@ -116,7 +121,8 @@ - + + {{ findEmployeeById(person.text)?.fio }} @@ -158,7 +166,7 @@ import QuestionHeader from '@/components/vote/ConstructorVote/QuestionHeader.vue'; import QuestionSettings from '@/components/vote/ConstructorVote/QuestionSettings.vue'; import AnswerList from '@/components/vote/ConstructorVote/AnswerList.vue'; -import { computed, ref } from 'vue'; +import { computed, ref, watch } from 'vue'; import { useRoute } from 'vue-router'; export default { @@ -295,11 +303,55 @@ export default { }; const onEmployeeUpdate = (selected) => { + // Filter existing answers to keep only those that are still selected props.question.answers = props.question.answers.filter((e) => selected.includes(e.text) ); + + // Add new answers for newly selected employees that don't have answers yet + const existingAnswerIds = props.question.answers.map(a => a.text); + const newEmployeeIds = selected.filter(id => !existingAnswerIds.includes(id)); + + // Add new answers for the newly selected employees + newEmployeeIds.forEach(employeeId => { + props.question.answers.push({ text: employeeId, image: null }); + }); + + // Also update the saved state for potential future switching between radio options + props.question._savedSelectedEmployees = [...selected]; + props.question._savedAnswers = [...props.question.answers]; + emit('update:question', props.question); }; + + const removeSelectedEmployee = (employeeId) => { + // Находим индекс сотрудника в массиве selectedEmployees + const index = props.question.selectedEmployees.indexOf(employeeId); + if (index !== -1) { + // Удаляем сотрудника из списка выбранных + props.question.selectedEmployees.splice(index, 1); + // Находим соответствующий ответ и удаляем его + const answerIndex = props.question.answers.findIndex(a => a.text === employeeId); + if (answerIndex !== -1) { + props.question.answers.splice(answerIndex, 1); + } + + // Обновляем сохраненное состояние + if (props.question._savedSelectedEmployees) { + const savedIndex = props.question._savedSelectedEmployees.indexOf(employeeId); + if (savedIndex !== -1) { + props.question._savedSelectedEmployees.splice(savedIndex, 1); + } + + const savedAnswerIndex = props.question._savedAnswers?.findIndex(a => a.text === employeeId); + if (savedAnswerIndex !== -1) { + props.question._savedAnswers.splice(savedAnswerIndex, 1); + } + } + + emit('update:question', props.question); + } + }; const toggleSelectAll = (value) => { props.handleSelectAll(value, props.index); @@ -307,8 +359,21 @@ export default { }; const removeEmployeeAnswer = (pIndex) => { - props.question.selectedEmployees.splice(pIndex, 1); + const employeeId = props.question.answers[pIndex].text; + + props.question.selectedEmployees = props.question.selectedEmployees.filter(id => id !== employeeId); props.question.answers.splice(pIndex, 1); + + // Обновляем сохраненное состояние + if (props.question._savedSelectedEmployees) { + props.question._savedSelectedEmployees = props.question._savedSelectedEmployees.filter(id => id !== employeeId); + + const savedAnswerIndex = props.question._savedAnswers?.findIndex(a => a.text === employeeId); + if (savedAnswerIndex !== -1) { + props.question._savedAnswers.splice(savedAnswerIndex, 1); + } + } + emit('update:question', props.question); }; @@ -320,6 +385,27 @@ export default { const isTestRoute = computed(() => { return route.path && String(route.path).includes('test'); }); + + // Добавляем наблюдение за изменением выбора типа голосования + watch(() => props.question.settings.onlyDep, (newValue, oldValue) => { + // Если выбрано любое значение кроме null, автоматически выбрать всех сотрудников + if (newValue !== null) { + // Сохраняем выбранных сотрудников перед выбором "все" + if (oldValue === null) { + // Сохраняем текущий выбор сотрудников для возможного возврата к "произвольным сотрудникам" + props.question._savedSelectedEmployees = [...props.question.selectedEmployees]; + props.question._savedAnswers = [...props.question.answers]; + } + toggleSelectAll(true); + } + // Если переключаемся на "За произвольного сотрудника" (null) и у нас есть сохраненный выбор + else if (newValue === null && oldValue !== null && props.question._savedSelectedEmployees) { + // Восстанавливаем ранее сохраненный выбор сотрудников + props.question.selectedEmployees = [...props.question._savedSelectedEmployees]; + props.question.answers = [...props.question._savedAnswers]; + emit('update:question', props.question); + } + }); return { resetAnswers, @@ -328,6 +414,7 @@ export default { onEmployeeUpdate, toggleSelectAll, removeEmployeeAnswer, + removeSelectedEmployee, onEmployeesChange, isTestRoute, questionImagePreview, diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index 203b47cc1..c93af7807 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -64,7 +64,7 @@ {{ answer.employee?.fio || answer.name }} - + @@ -197,6 +197,20 @@ export default { } }; + const toggleAnswer = (questionId, answerId) => { + const currentAnswers = result.value[questionId]; + const index = currentAnswers.indexOf(answerId); + + if (index === -1) { + const question = props.data.questions.find(q => q.id === questionId); + if (currentAnswers.length < question.settings.multiChoice) { + currentAnswers.push(answerId); + } + } else { + currentAnswers.splice(index, 1); + } + }; + const submitVote = () => { let voteData = [] for (let val of Object.values(result.value)) { @@ -220,10 +234,10 @@ export default { activepick.value = val } - const groupedAnswers = (question) => { + const groupedAnswers = (question) => { const filtered = question.answers.filter(answer => answer.employee?.id !== accountStore.user.is_idEmployee); - if (question.settings.onlyDep === null) { + if (question.settings.onlyDep === null || question.settings.onlyDep === 'any') { return groupByDepartment(filtered); } else if (question.settings.onlyDep) { const byDepartment = filtered.filter( @@ -263,6 +277,7 @@ export default { isCurrentQuestionAnswered, nextStep, prevStep, + toggleAnswer, submitVote, isVoteSubmitted, result diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index adcfd1bc7..a0dd4d783 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -263,12 +263,17 @@ Голосование по отделам: {{ onlyDepdict.find((e) => e.value === question.settings.onlyDep).name }} - Выбранные сотрудники: - - - {{ findEmployeeById(employeeId.text).fio }} - - + + Выбрано {{ question.answers.length }} сотрудников + + + Выбранные сотрудники: + + + {{ findEmployeeById(employeeId.text).fio }} + + + @@ -588,9 +593,9 @@ export default { }; watch( - form.value, - () => { - if (!form.value.title || !form.value.description || form.value.questions.length < 1) { + () => form.value, + (formValue) => { + if (!formValue.title || !formValue.description || formValue.questions.length < 1) { errorMessage.value = 'Все обязательные поля должны быть заполнены'; } else { errorMessage.value = ''; @@ -602,7 +607,6 @@ export default { watch( () => form.value.questions, (newQuestions) => { - quests.value = newQuestions.map((q) => !!q.text.trim()); const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === ''); const hasInvalidAnswers = validateAnswers(); @@ -628,12 +632,13 @@ export default { }; const onlyDepdict = [ - { name: 'За любого сотрудника', value: null }, + { name: 'За любого сотрудника', value: 'any' }, { - name: 'Кроме своего отдела', + name: 'Только за сотрудника из другого отдела', value: false, }, - { name: 'Только за свой отдел', value: true }, + { name: 'Только за сотрудника из своего отдела', value: true }, + { name: 'За произвольного сотрудника (есть возможность добавить картинку)', value: null }, ]; const quests = computed(() => form.value.questions.map((question) => question.text.length > 0)); @@ -686,11 +691,13 @@ export default { testImage, imagePreview, previewImage, + handleTestImageUpload, getImagePreviewUrl, actualQuestionCount, actualTestQuestionCount, isTest: props.isTest, - imageError + imageError, + validateImage }; }, }; diff --git a/src/front/src/components/vote/VoteResult.vue b/src/front/src/components/vote/VoteResult.vue index 744a5f365..906bdbbed 100644 --- a/src/front/src/components/vote/VoteResult.vue +++ b/src/front/src/components/vote/VoteResult.vue @@ -30,7 +30,7 @@ - + test.id === Number(id)); + return activeTest || null; + } catch (error) { + console.error("Ошибка получения активного теста:", error); + throw error; + } +} + export { axiosApiInstance, @@ -392,4 +404,5 @@ export { assignTestToUser, getTestToUser, deleteTestingRecord, + getActiveTest, } diff --git a/src/front/src/views/HomePage.vue b/src/front/src/views/HomePage.vue index 8c7ff94ac..ab5ea3902 100644 --- a/src/front/src/views/HomePage.vue +++ b/src/front/src/views/HomePage.vue @@ -44,10 +44,10 @@ - + - + @@ -146,12 +146,22 @@ export default { } .bgCard { - /* #ffffff6b #ffffff8c*/ - background: #ffffff38; + background: #fff !important; } .bgText { - background: #ffffffb0; + background: #f5f5f5 !important; + color: #222 !important; line-height: 2.1rem !important; } + +.card-unified { + border-radius: 18px; + box-shadow: none; +} + +.text-unified { + color: #222 !important; + font-family: 'Montserrat', 'Arial', sans-serif; +}
Выбранные сотрудники:
Выбрано {{ question.answers.length }} сотрудников