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