дополнение моделей вопросов новыми параметрами от фич
This commit is contained in:
parent
7d5bc54325
commit
be376586cc
@ -30,6 +30,9 @@ export const ImageVariant = ({ questionId, variant, index }: ImagesProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("answers");
|
||||||
|
console.log(answers);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
||||||
import type { QuizQuestionImages } from "@model/questionTypes/images";
|
import type { QuizQuestionImages } from "@model/questionTypes/images";
|
||||||
import { Box, RadioGroup, Typography, useTheme } from "@mui/material";
|
import { Box, RadioGroup, Typography, useTheme } from "@mui/material";
|
||||||
import { useQuizViewStore } from "@stores/quizView";
|
import { createQuizViewStore, useQuizViewStore } from "@stores/quizView";
|
||||||
import { ImageVariant } from "./ImageVariant";
|
import { ImageVariant } from "./ImageVariant";
|
||||||
|
|
||||||
type ImagesProps = {
|
type ImagesProps = {
|
||||||
@ -14,7 +14,10 @@ export const Images = ({ currentQuestion }: ImagesProps) => {
|
|||||||
const answer = answers.find(({ questionId }) => questionId === currentQuestion.id)?.answer;
|
const answer = answers.find(({ questionId }) => questionId === currentQuestion.id)?.answer;
|
||||||
const isTablet = useRootContainerSize() < 1000;
|
const isTablet = useRootContainerSize() < 1000;
|
||||||
const isMobile = useRootContainerSize() < 500;
|
const isMobile = useRootContainerSize() < 500;
|
||||||
|
const a = createQuizViewStore().getState();
|
||||||
|
console.log(currentQuestion);
|
||||||
|
console.log("store");
|
||||||
|
console.log(a);
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography
|
||||||
|
@ -20,5 +20,7 @@ export interface QuizQuestionEmoji extends QuizQuestionBase {
|
|||||||
back: string | null;
|
back: string | null;
|
||||||
originalBack: string | null;
|
originalBack: string | null;
|
||||||
autofill: boolean;
|
autofill: boolean;
|
||||||
|
ownPlaceholder?: string;
|
||||||
|
isLargeCheck?: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,7 @@ export interface QuizQuestionImages extends QuizQuestionBase {
|
|||||||
originalBack: string | null;
|
originalBack: string | null;
|
||||||
autofill: boolean;
|
autofill: boolean;
|
||||||
largeCheck: boolean;
|
largeCheck: boolean;
|
||||||
|
ownPlaceholder?: string;
|
||||||
|
isLargeCheck?: boolean;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,6 @@ export interface QuizQuestionVariant extends QuizQuestionBase {
|
|||||||
back: string | null;
|
back: string | null;
|
||||||
originalBack: string | null;
|
originalBack: string | null;
|
||||||
autofill: boolean;
|
autofill: boolean;
|
||||||
|
ownPlaceholder?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,5 +20,8 @@ export interface QuizQuestionVarImg extends QuizQuestionBase {
|
|||||||
autofill: boolean;
|
autofill: boolean;
|
||||||
largeCheck: boolean;
|
largeCheck: boolean;
|
||||||
replText: string;
|
replText: string;
|
||||||
|
/** Чекбокс "Можно несколько" */
|
||||||
|
multi?: boolean;
|
||||||
|
ownPlaceholder?: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,10 @@ export const createQuizViewStore = () =>
|
|||||||
updateAnswer(questionId, answer, points) {
|
updateAnswer(questionId, answer, points) {
|
||||||
set(
|
set(
|
||||||
(state) => {
|
(state) => {
|
||||||
|
console.log(state);
|
||||||
const index = state.answers.findIndex((answer) => questionId === answer.questionId);
|
const index = state.answers.findIndex((answer) => questionId === answer.questionId);
|
||||||
|
console.log("state");
|
||||||
|
console.log(state.answers);
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
state.answers.push({ questionId, answer });
|
state.answers.push({ questionId, answer });
|
||||||
|
@ -33,6 +33,8 @@ export function useQuestionFlowControl() {
|
|||||||
//Изменение стейта (переменной currentQuestionId) ведёт к пересчёту что же за объект сейчас используется. Мы каждый раз просто ищем в списке
|
//Изменение стейта (переменной currentQuestionId) ведёт к пересчёту что же за объект сейчас используется. Мы каждый раз просто ищем в списке
|
||||||
const currentQuestion = sortedQuestions.find((question) => question.id === currentQuestionId) ?? sortedQuestions[0];
|
const currentQuestion = sortedQuestions.find((question) => question.id === currentQuestionId) ?? sortedQuestions[0];
|
||||||
|
|
||||||
|
// console.log(currentQuestion)
|
||||||
|
|
||||||
//Индекс текущего вопроса только если квиз линейный
|
//Индекс текущего вопроса только если квиз линейный
|
||||||
const linearQuestionIndex = //: number | null
|
const linearQuestionIndex = //: number | null
|
||||||
currentQuestion && sortedQuestions.every(({ content }) => content.rule.parentId !== "root") // null when branching enabled
|
currentQuestion && sortedQuestions.every(({ content }) => content.rule.parentId !== "root") // null when branching enabled
|
||||||
|
@ -101,11 +101,22 @@ export function sendQuestionAnswer(
|
|||||||
const answer = questionAnswer.answer;
|
const answer = questionAnswer.answer;
|
||||||
if (!Array.isArray(answer)) throw new Error("Cannot send answer in select question");
|
if (!Array.isArray(answer)) throw new Error("Cannot send answer in select question");
|
||||||
|
|
||||||
|
console.log("до фильтра");
|
||||||
|
console.log(question.content.variants);
|
||||||
|
//Оставляем только выбранные варианты
|
||||||
const selectedVariants = question.content.variants.filter((v) => answer.includes(v.id));
|
const selectedVariants = question.content.variants.filter((v) => answer.includes(v.id));
|
||||||
|
console.log("после фильтра");
|
||||||
|
console.log(selectedVariants);
|
||||||
|
let answerString = ``;
|
||||||
|
selectedVariants.forEach((e) => {
|
||||||
|
answerString += `\`${e.answer}\`,`;
|
||||||
|
});
|
||||||
|
answerString = answerString.slice(0, -1);
|
||||||
|
|
||||||
return sendAnswer({
|
return sendAnswer({
|
||||||
questionId: question.id,
|
questionId: question.id,
|
||||||
body: selectedVariants.map((v) => v.answer).join(", "),
|
body: answerString,
|
||||||
|
// body: selectedVariants.map((v) => v.answer).join(", "),
|
||||||
qid: quizId,
|
qid: quizId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user