Merge branch 'develop' into сja
This commit is contained in:
commit
cf527a6919
4 files changed
+204
-40
No files matched your search
@@ -142,13 +142,29 @@
|
|||||||
<div v-if="question.settings.choice === 'free'">
|
<div v-if="question.settings.choice === 'free'">
|
||||||
<transition-group name="list" tag="div">
|
<transition-group name="list" tag="div">
|
||||||
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
||||||
<v-text-field v-model="answer.text" :label="'Ответ ' + (ind + 1)"
|
<v-text-field
|
||||||
:rules="[rules.required]"
|
v-model="answer.text"
|
||||||
class="mr-4" density="compact" variant="outlined"></v-text-field>
|
:label="'Ответ ' + (ind + 1)"
|
||||||
<v-file-input v-model="answer.image" accept="image/*" dense density="compact" hide-details
|
:rules="[rules.required]"
|
||||||
label="Картинка" variant="outlined"></v-file-input>
|
class="mr-4"
|
||||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
density="compact"
|
||||||
@click="removeAnswer(index,ind)">
|
variant="outlined">
|
||||||
|
</v-text-field>
|
||||||
|
<v-file-input
|
||||||
|
v-model="answer.image"
|
||||||
|
accept="image/*"
|
||||||
|
dense
|
||||||
|
density="compact"
|
||||||
|
hide-details
|
||||||
|
label="Картинка"
|
||||||
|
variant="outlined">
|
||||||
|
</v-file-input>
|
||||||
|
<v-btn
|
||||||
|
class="ms-1"
|
||||||
|
color="error"
|
||||||
|
icon="mdi-delete"
|
||||||
|
size="small"
|
||||||
|
@click="removeAnswer(index, ind)">
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
@@ -425,17 +441,37 @@ export default {
|
|||||||
|
|
||||||
const errorMessage = ref("");
|
const errorMessage = ref("");
|
||||||
|
|
||||||
|
const validateAnswers = () => {
|
||||||
|
return form.value.questions.some((question) => {
|
||||||
|
if (question.settings.choice === "free") {
|
||||||
|
return question.answers.some(
|
||||||
|
(answer) => !answer.text || answer.text.trim() === ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const saveVoting = async () => {
|
const saveVoting = async () => {
|
||||||
const hasEmptyQuestions = quests.value.includes(false);
|
const hasEmptyQuestions = quests.value.includes(false);
|
||||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
const hasInvalidAnswers = validateAnswers();
|
||||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
|
||||||
|
if (
|
||||||
|
!form.value.title ||
|
||||||
|
!form.value.description ||
|
||||||
|
form.value.questions.length < 1 ||
|
||||||
|
hasEmptyQuestions ||
|
||||||
|
hasInvalidAnswers
|
||||||
|
) {
|
||||||
|
errorMessage.value = "Все обязательные поля и ответы должны быть заполнены";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await createVote(form.value);
|
const response = await createVote(form.value);
|
||||||
console.log("Голосование успешно создано:", response);
|
console.log("Голосование успешно создано:", response);
|
||||||
isVoteCreated.value = true;
|
isVoteCreated.value = true;
|
||||||
emit('updating', 'active');
|
emit("updating", "active");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Ошибка при создании голосования:", error);
|
console.error("Ошибка при создании голосования:", error);
|
||||||
}
|
}
|
||||||
@@ -469,8 +505,7 @@ export default {
|
|||||||
);
|
);
|
||||||
|
|
||||||
watch(form.value, () => {
|
watch(form.value, () => {
|
||||||
const hasEmptyQuestions = quests.value.includes(false);
|
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
|
||||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||||
} else {
|
} else {
|
||||||
errorMessage.value = "";
|
errorMessage.value = "";
|
||||||
@@ -483,12 +518,20 @@ export default {
|
|||||||
|
|
||||||
watch(() => form.value.questions, updateQuests, { deep: true });
|
watch(() => form.value.questions, updateQuests, { deep: true });
|
||||||
|
|
||||||
watch(() => form.value.questions, (newQuestions) => {
|
watch(
|
||||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
() => form.value.questions,
|
||||||
errorMessage.value = hasEmptyQuestions
|
(newQuestions) => {
|
||||||
? "Все вопросы должны быть заполнены"
|
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||||
: "";
|
const hasInvalidAnswers = validateAnswers();
|
||||||
}, { deep: true });
|
|
||||||
|
if (hasEmptyQuestions || hasInvalidAnswers) {
|
||||||
|
errorMessage.value = "Все вопросы и ответы должны быть заполнены";
|
||||||
|
} else {
|
||||||
|
errorMessage.value = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
watch(selectedTimeStart, () => {
|
watch(selectedTimeStart, () => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container style="height: 85vh">
|
<v-container style="height: 85vh;">
|
||||||
<div class="text-end">
|
<div class="text-end">
|
||||||
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||||
@click="$emit('closer')">
|
@click="$emit('closer')">
|
||||||
@@ -35,7 +35,10 @@
|
|||||||
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||||
:key="department"
|
:key="department"
|
||||||
>
|
>
|
||||||
<v-card class="cursor-pointer" @click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])" style="max-height: 50vh; overflow-y: auto;">
|
<v-card
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])"
|
||||||
|
style="max-height: 50vh; overflow-y: auto;">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
@@ -169,9 +172,8 @@
|
|||||||
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong class="mr-4">{{ index + 1 }}.</strong>
|
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||||
<v-avatar v-if="answer.file === null && answer.employee"
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -181,6 +183,7 @@
|
|||||||
@click.stop="opendialog(answer)"/>
|
@click.stop="opendialog(answer)"/>
|
||||||
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||||
{{ answer.count }}
|
{{ answer.count }}
|
||||||
|
{{ voteCount(answer.count) }}
|
||||||
<template v-if="answer.employee">
|
<template v-if="answer.employee">
|
||||||
<br/>
|
<br/>
|
||||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||||
@@ -268,7 +271,21 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getTopResults = (question) => {
|
const getTopResults = (question) => {
|
||||||
return [...question?.answers].sort((a, b) => b.count - a.count);
|
const sortedAnswers = [...question.answers].sort((a, b) => b.count - a.count);
|
||||||
|
|
||||||
|
// Присваиваем одинаковые индексы для одинаковых значений count
|
||||||
|
let rank = 1;
|
||||||
|
let previousCount = null;
|
||||||
|
return sortedAnswers.map((answer, index) => {
|
||||||
|
if (answer.count !== previousCount) {
|
||||||
|
rank = index + 1;
|
||||||
|
previousCount = answer.count;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...answer,
|
||||||
|
rank
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const truncateText = (text, maxLength) => {
|
const truncateText = (text, maxLength) => {
|
||||||
|
|||||||
@@ -1,23 +1,130 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row>
|
<v-container>
|
||||||
<v-col
|
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4">
|
||||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
<v-tab>Назначенные ({{tests.length}})</v-tab>
|
||||||
>
|
<v-tab>Завершенные</v-tab>
|
||||||
Тестирование
|
<v-tab>Каталог</v-tab>
|
||||||
</v-col>
|
</v-tabs>
|
||||||
</v-row>
|
|
||||||
|
<v-tabs-window v-model="activeTab">
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<v-card class="mb-6" outlined>
|
||||||
|
<v-card-title>
|
||||||
|
Назначенные
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
v-model="search"
|
||||||
|
label="Найти тестирование по названию"
|
||||||
|
variant="outlined"
|
||||||
|
clearable
|
||||||
|
class="mb-4"
|
||||||
|
></v-text-field>
|
||||||
|
|
||||||
|
<v-data-table
|
||||||
|
:items="filteredTests"
|
||||||
|
item-value="id"
|
||||||
|
class="elevation-1"
|
||||||
|
:headers="headers"
|
||||||
|
hide-default-footer
|
||||||
|
>
|
||||||
|
<template #item.image="{ item }">
|
||||||
|
<v-avatar size="48">
|
||||||
|
<img :src="item.image" alt="Test Image" />
|
||||||
|
</v-avatar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.actions="{ item }">
|
||||||
|
<v-btn v-if="item.type === 'test'" color="teal-darken-4" variant="tonal" class="mr-4">Тренироваться</v-btn>
|
||||||
|
<v-btn color="teal-darken-4">Пройти</v-btn>
|
||||||
|
</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>
|
||||||
|
<p>Список завершенных тестов будет здесь.</p>
|
||||||
|
</v-card>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<v-card class="mb-6" outlined>
|
||||||
|
<v-card-title>
|
||||||
|
Каталог
|
||||||
|
</v-card-title>
|
||||||
|
<p>Список доступных тестов будет здесь.</p>
|
||||||
|
</v-card>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
</v-tabs-window>
|
||||||
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
setup() {
|
||||||
pagecounter()
|
const activeTab = ref(0);
|
||||||
}
|
const search = ref('');
|
||||||
}
|
|
||||||
|
const headers = [
|
||||||
|
{ text: 'Картинка', value: 'image', sortable: false },
|
||||||
|
{ text: 'Название', value: 'title', align: 'start' },
|
||||||
|
{ text: 'Тип', value: 'type' },
|
||||||
|
{ text: 'Описание', value: 'description' },
|
||||||
|
{ text: 'Дата', value: 'date' },
|
||||||
|
{ text: 'Действия', value: 'actions', sortable: false },
|
||||||
|
];
|
||||||
|
|
||||||
|
const tests = ref([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
|
||||||
|
type: 'test',
|
||||||
|
description: 'Краткое описание тестирования',
|
||||||
|
date: '22.06.2024',
|
||||||
|
questions: 20,
|
||||||
|
time: '15 минут',
|
||||||
|
attempts: 1,
|
||||||
|
image: 'https://via.placeholder.com/48',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: 'Удобство раздела тестирования',
|
||||||
|
type: 'survey',
|
||||||
|
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||||
|
date: '22.06.2024',
|
||||||
|
questions: 28,
|
||||||
|
time: null,
|
||||||
|
attempts: null,
|
||||||
|
image: 'https://via.placeholder.com/48',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const filteredTests = computed(() => {
|
||||||
|
if (!search.value) return tests.value;
|
||||||
|
return tests.value.filter((test) =>
|
||||||
|
test.title.toLowerCase().includes(search.value.toLowerCase())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab,
|
||||||
|
search,
|
||||||
|
headers,
|
||||||
|
tests,
|
||||||
|
filteredTests,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.v-data-table__wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -49,9 +49,6 @@
|
|||||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||||
<v-card>
|
<v-card>
|
||||||
<VoteResult :data="result" @closer="closeModal" />
|
<VoteResult :data="result" @closer="closeModal" />
|
||||||
<v-card-actions>
|
|
||||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|||||||
Reference in new issue
Block a user