убираю спасибы
This commit is contained in:
parent
326e2c98b3
commit
fe504e9628
@ -6,6 +6,23 @@ import { AnyTypedQuizQuestion, QuizQuestionVariant } from "@/index";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQuizStore } from "@/stores/useQuizStore";
|
||||
|
||||
const dinocrutch = window.location.pathname === "/413b9e24-996a-400e-9076-c158f64b9bd7";
|
||||
|
||||
// Функция для определения вопроса "спасибо"
|
||||
const isThankYouQuestion = (question: QuizQuestionVariant): boolean => {
|
||||
// Проверяем что у вопроса только один вариант ответа
|
||||
if (question.content.variants.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Проверяем что текст варианта полностью состоит из слова "спасибо"
|
||||
const variant = question.content.variants[0];
|
||||
const answerText = variant.answer.toLowerCase().trim();
|
||||
|
||||
// Проверяем точное совпадение со словом "спасибо"
|
||||
return answerText === "спасибо";
|
||||
};
|
||||
|
||||
export const PointSystemResultList = () => {
|
||||
const theme = useTheme();
|
||||
const { questions } = useQuizStore();
|
||||
@ -16,7 +33,12 @@ export const PointSystemResultList = () => {
|
||||
(q: AnyTypedQuizQuestion): q is QuizQuestionVariant => q.type === "variant"
|
||||
);
|
||||
|
||||
return questionsWothoutResult.map((currentQuestion) => {
|
||||
// Фильтруем вопросы "спасибо" только для указанного квиза
|
||||
const filteredQuestions = dinocrutch
|
||||
? questionsWothoutResult.filter((q) => !isThankYouQuestion(q))
|
||||
: questionsWothoutResult;
|
||||
|
||||
return filteredQuestions.map((currentQuestion) => {
|
||||
let answerIndex = 0;
|
||||
let currentVariants = currentQuestion.content.variants;
|
||||
|
||||
|
@ -12,6 +12,7 @@ import { quizThemes } from "@utils/themes/Publication/themePublication";
|
||||
import { NameplateLogo } from "@icons/NameplateLogo";
|
||||
|
||||
import type { QuizQuestionResult } from "@/model/questionTypes/result";
|
||||
import type { QuizQuestionVariant } from "@/model/questionTypes/variant";
|
||||
import QuizVideo from "@/ui_kit/VideoIframe/VideoIframe";
|
||||
import { TextAccordion } from "./tools/TextAccordion";
|
||||
import { PointSystemResultList } from "./PointSystemResultList";
|
||||
@ -26,6 +27,21 @@ type ResultFormProps = {
|
||||
resultQuestion: QuizQuestionResult;
|
||||
};
|
||||
|
||||
// Функция для определения вопроса "спасибо"
|
||||
const isThankYouQuestion = (question: QuizQuestionVariant): boolean => {
|
||||
// Проверяем что у вопроса только один вариант ответа
|
||||
if (question.content.variants.length !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Проверяем что текст варианта полностью состоит из слова "спасибо"
|
||||
const variant = question.content.variants[0];
|
||||
const answerText = variant.answer.toLowerCase().trim();
|
||||
|
||||
// Проверяем точное совпадение со словом "спасибо"
|
||||
return answerText === "спасибо";
|
||||
};
|
||||
|
||||
export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useRootContainerSize() < 650;
|
||||
@ -39,6 +55,22 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
const yandexMetrics = useYandexMetricsGoals(settings.cfg.yandexMetricsNumber);
|
||||
const { t } = useTranslation();
|
||||
|
||||
// Проверяем, является ли это квизом с костылем
|
||||
const dinocrutch = window.location.pathname === "/413b9e24-996a-400e-9076-c158f64b9bd7";
|
||||
|
||||
// Вычисляем общее количество вопросов с учетом фильтрации
|
||||
const totalQuestions = useMemo(() => {
|
||||
if (dinocrutch) {
|
||||
// Для квиза с костылем: исключаем вопросы "спасибо" и вопросы типа "result"
|
||||
const variantQuestions = questions.filter((e) => e.type === "variant") as QuizQuestionVariant[];
|
||||
const filteredQuestions = variantQuestions.filter((q) => !isThankYouQuestion(q));
|
||||
return filteredQuestions.length;
|
||||
}
|
||||
|
||||
// Для обычных квизов: исключаем только вопросы типа "result"
|
||||
return questions.filter((e) => e.type !== "result").length;
|
||||
}, [questions, dinocrutch]);
|
||||
|
||||
useEffect(() => {
|
||||
vkMetrics.resultIdShown(resultQuestion.id);
|
||||
yandexMetrics.resultIdShown(resultQuestion.id);
|
||||
@ -260,7 +292,7 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
fontWeight: 600,
|
||||
}}
|
||||
>
|
||||
{pointsSum} {t("of")} {questions.filter((e) => e.type != "result").length}
|
||||
{pointsSum} {t("of")} {totalQuestions}
|
||||
</Typography>
|
||||
<TextAccordion
|
||||
headerText={
|
||||
|
@ -26,7 +26,7 @@
|
||||
"preview": "vite preview",
|
||||
"cypress:open": "cypress open",
|
||||
"prepublishOnly": "npm run build:package",
|
||||
"deploy": "podman login gitea.pena && podman build -t gitea.pena/squiz/frontanswerer/$(git branch --show-current):latest . && podman push gitea.pena/squiz/frontanswerer/$(git branch --show-current):latest",
|
||||
"deploy": "docker login gitea.pena && docker build -t gitea.pena/squiz/frontanswerer/$(git branch --show-current):latest . && docker push gitea.pena/squiz/frontanswerer/$(git branch --show-current):latest",
|
||||
"prepare": "husky"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user