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