From 23c1688d012d0f26f45116e2917a3410bd0f1a43 Mon Sep 17 00:00:00 2001 From: IlyaDoronin Date: Mon, 4 Dec 2023 16:36:30 +0300 Subject: [PATCH] fix: questions multianswer logic --- .../BranchingQuestionsModal/index.tsx | 26 ++++++++++--------- src/pages/ViewPublicationPage/Footer.tsx | 4 +-- src/stores/questions/store.ts | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pages/Questions/BranchingQuestionsModal/index.tsx b/src/pages/Questions/BranchingQuestionsModal/index.tsx index 9099e3f9..068c1abf 100644 --- a/src/pages/Questions/BranchingQuestionsModal/index.tsx +++ b/src/pages/Questions/BranchingQuestionsModal/index.tsx @@ -1,24 +1,28 @@ -import { useParams } from "react-router-dom"; import { Box, Modal, Button, Typography } from "@mui/material"; import { useQuestionsStore } from "@root/questions/store"; -import { AnyTypedQuizQuestion, UntypedQuizQuestion } from "@model/questionTypes/shared"; - -type AnyQuestion = UntypedQuizQuestion | AnyTypedQuizQuestion +import { AnyTypedQuizQuestion } from "@model/questionTypes/shared"; interface Props { openedModalQuestions: boolean; - setModalQuestionTargetContentId: (contentId:string) => void; - setOpenedModalQuestions: (open:boolean) => void; + setModalQuestionTargetContentId: (contentId: string) => void; + setOpenedModalQuestions: (open: boolean) => void; } -export const BranchingQuestionsModal = ({ openedModalQuestions, setOpenedModalQuestions, setModalQuestionTargetContentId}:Props) => { - const quizId = Number(useParams().quizId); +export const BranchingQuestionsModal = ({ + openedModalQuestions, + setOpenedModalQuestions, + setModalQuestionTargetContentId, +}: Props) => { const { questions } = useQuestionsStore(); const handleClose = () => { setOpenedModalQuestions(false); }; + const typedQuestions: AnyTypedQuizQuestion[] = questions.filter( + (question) => question.type && !question.content.rule.parentId + ) as AnyTypedQuizQuestion[]; + return ( - {questions.filter((q:AnyQuestion) => { -if (q.content === null) return true - return (q.type && !q.content.rule.parentId)}).map((question: AnyTypedQuizQuestion, index:number) => ( + {typedQuestions.map((question) => (