разделение показа
This commit is contained in:
parent
ac85eb5e19
commit
4ff5e42d2c
@ -127,7 +127,6 @@ export const Question = ({
|
|||||||
question={currentQuestion}
|
question={currentQuestion}
|
||||||
stepNumber={currentQuestionStepNumber}
|
stepNumber={currentQuestionStepNumber}
|
||||||
/>
|
/>
|
||||||
{show_badge && (
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
mt: "20px",
|
mt: "20px",
|
||||||
@ -147,6 +146,7 @@ export const Question = ({
|
|||||||
thickness={4}
|
thickness={4}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{show_badge && (
|
||||||
<Link
|
<Link
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={`https://${isProduction ? "" : "s"}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
href={`https://${isProduction ? "" : "s"}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||||
@ -169,10 +169,10 @@ export const Question = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
</Box>
|
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
</Box>
|
||||||
{questionSelect}
|
{questionSelect}
|
||||||
<Footer
|
<Footer
|
||||||
stepNumber={currentQuestionStepNumber}
|
stepNumber={currentQuestionStepNumber}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import { useYandexMetricsGoals } from "@/utils/hooks/metrics/useYandexMetricsGoa
|
|||||||
import { useQuestionTimer } from "./useQuestionTimer";
|
import { useQuestionTimer } from "./useQuestionTimer";
|
||||||
|
|
||||||
export function useBranchingQuiz() {
|
export function useBranchingQuiz() {
|
||||||
|
console.log("РАБОТАЮ Я, УПРАВЛЯТОР КВИЗА ВЕТВЛЕНИЯ");
|
||||||
//Получаем инфо о квизе и список вопросов.
|
//Получаем инфо о квизе и список вопросов.
|
||||||
const { settings, questions, quizId, cnt, preview } = useQuizStore();
|
const { settings, questions, quizId, cnt, preview } = useQuizStore();
|
||||||
|
|
||||||
@ -57,12 +58,17 @@ export function useBranchingQuiz() {
|
|||||||
if (settings.cfg.haveRoot) {
|
if (settings.cfg.haveRoot) {
|
||||||
// Если есть ветвление, то settings.cfg.haveRoot будет заполнен
|
// Если есть ветвление, то settings.cfg.haveRoot будет заполнен
|
||||||
//Если заполнен, то дерево растёт с root и это 1 вопрос :)
|
//Если заполнен, то дерево растёт с root и это 1 вопрос :)
|
||||||
|
console.log("Существует запись о корне: " + settings.cfg.haveRoot);
|
||||||
const nextQuestion = sortedQuestions.find(
|
const nextQuestion = sortedQuestions.find(
|
||||||
//Функция ищет первое совпадение по массиву
|
//Функция ищет первое совпадение по массиву
|
||||||
(question) => question.id === settings.cfg.haveRoot || question.content.id === settings.cfg.haveRoot
|
(question) => question.id === settings.cfg.haveRoot || question.content.id === settings.cfg.haveRoot
|
||||||
);
|
);
|
||||||
if (!nextQuestion) return null;
|
|
||||||
|
|
||||||
|
console.log("___nextQuestion____");
|
||||||
|
console.log(nextQuestion);
|
||||||
|
console.log("___sortedQuestions____");
|
||||||
|
console.log(sortedQuestions);
|
||||||
|
if (!nextQuestion) return null;
|
||||||
return nextQuestion.id;
|
return nextQuestion.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export function useQuestionTimer({ enabled, seconds, quizId, preview, currentQue
|
|||||||
const ownVariants = useQuizViewStore((state) => state.ownVariants);
|
const ownVariants = useQuizViewStore((state) => state.ownVariants);
|
||||||
const currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
|
const currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
|
||||||
const timeoutRef = useRef<number | null>(null);
|
const timeoutRef = useRef<number | null>(null);
|
||||||
|
const isFirstQuestionRef = useRef<boolean>(true);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log("🕐 useQuestionTimer useEffect triggered", {
|
console.log("🕐 useQuestionTimer useEffect triggered", {
|
||||||
@ -61,7 +62,17 @@ export function useQuestionTimer({ enabled, seconds, quizId, preview, currentQue
|
|||||||
timeoutRef.current = null;
|
timeoutRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutRef.current = window.setTimeout(async () => {
|
// Для первого вопроса добавляем дополнительную задержку, чтобы избежать конфликтов с навигацией
|
||||||
|
const isFirstQuestion = isFirstQuestionRef.current;
|
||||||
|
const startDelay = isFirstQuestion ? 2000 : 100; // 2 секунды для первого вопроса, 100ms для остальных
|
||||||
|
|
||||||
|
if (isFirstQuestion) {
|
||||||
|
console.log("🔄 First question detected, adding 2s delay to prevent navigation conflicts");
|
||||||
|
isFirstQuestionRef.current = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
timeoutRef.current = window.setTimeout(
|
||||||
|
async () => {
|
||||||
console.log("⏰ Timer expired! Auto-advancing to next question");
|
console.log("⏰ Timer expired! Auto-advancing to next question");
|
||||||
try {
|
try {
|
||||||
if (!preview) {
|
if (!preview) {
|
||||||
@ -79,7 +90,9 @@ export function useQuestionTimer({ enabled, seconds, quizId, preview, currentQue
|
|||||||
console.log("➡️ Calling onNext()");
|
console.log("➡️ Calling onNext()");
|
||||||
onNext();
|
onNext();
|
||||||
}
|
}
|
||||||
}, seconds * 1000);
|
},
|
||||||
|
seconds * 1000 + startDelay
|
||||||
|
);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
console.log("🧹 Cleaning up timer");
|
console.log("🧹 Cleaning up timer");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user