разделение показа
This commit is contained in:
parent
ac85eb5e19
commit
4ff5e42d2c
@ -127,26 +127,26 @@ export const Question = ({
|
||||
question={currentQuestion}
|
||||
stepNumber={currentQuestionStepNumber}
|
||||
/>
|
||||
{show_badge && (
|
||||
<Box
|
||||
sx={{
|
||||
mt: "20px",
|
||||
alignSelf: "end",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "end",
|
||||
gap: "13px",
|
||||
}}
|
||||
>
|
||||
{timerEnabled && isTimerActive && (
|
||||
<CustomCircularTimer
|
||||
duration={timerDuration}
|
||||
remaining={remainingTime}
|
||||
showTime={true}
|
||||
size={76}
|
||||
thickness={4}
|
||||
/>
|
||||
)}
|
||||
<Box
|
||||
sx={{
|
||||
mt: "20px",
|
||||
alignSelf: "end",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "end",
|
||||
gap: "13px",
|
||||
}}
|
||||
>
|
||||
{timerEnabled && isTimerActive && (
|
||||
<CustomCircularTimer
|
||||
duration={timerDuration}
|
||||
remaining={remainingTime}
|
||||
showTime={true}
|
||||
size={76}
|
||||
thickness={4}
|
||||
/>
|
||||
)}
|
||||
{show_badge && (
|
||||
<Link
|
||||
target="_blank"
|
||||
href={`https://${isProduction ? "" : "s"}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
@ -169,8 +169,8 @@ export const Question = ({
|
||||
/>
|
||||
)}
|
||||
</Link>
|
||||
</Box>
|
||||
)}
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
{questionSelect}
|
||||
|
||||
@ -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,25 +62,37 @@ export function useQuestionTimer({ enabled, seconds, quizId, preview, currentQue
|
||||
timeoutRef.current = null;
|
||||
}
|
||||
|
||||
timeoutRef.current = window.setTimeout(async () => {
|
||||
console.log("⏰ Timer expired! Auto-advancing to next question");
|
||||
try {
|
||||
if (!preview) {
|
||||
console.log("📤 Sending empty answer for question:", currentQuestion.id);
|
||||
// Отправляем пустую строку в ответе (questionAnswer === undefined)
|
||||
await sendQuestionAnswer(quizId, currentQuestion, undefined, ownVariants);
|
||||
console.log("✅ Empty answer sent successfully");
|
||||
} else {
|
||||
console.log("👀 Preview mode - skipping answer send");
|
||||
// Для первого вопроса добавляем дополнительную задержку, чтобы избежать конфликтов с навигацией
|
||||
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) {
|
||||
console.log("📤 Sending empty answer for question:", currentQuestion.id);
|
||||
// Отправляем пустую строку в ответе (questionAnswer === undefined)
|
||||
await sendQuestionAnswer(quizId, currentQuestion, undefined, ownVariants);
|
||||
console.log("✅ Empty answer sent successfully");
|
||||
} else {
|
||||
console.log("👀 Preview mode - skipping answer send");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("❌ Error sending empty timed answer", e);
|
||||
enqueueSnackbar("Ошибка при отправке ответа по таймеру");
|
||||
} finally {
|
||||
console.log("➡️ Calling onNext()");
|
||||
onNext();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("❌ Error sending empty timed answer", e);
|
||||
enqueueSnackbar("Ошибка при отправке ответа по таймеру");
|
||||
} finally {
|
||||
console.log("➡️ Calling onNext()");
|
||||
onNext();
|
||||
}
|
||||
}, seconds * 1000);
|
||||
},
|
||||
seconds * 1000 + startDelay
|
||||
);
|
||||
|
||||
return () => {
|
||||
console.log("🧹 Cleaning up timer");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user