diff --git a/ CHANGELOG.md b/ CHANGELOG.md new file mode 100644 index 0000000..dee49d8 --- /dev/null +++ b/ CHANGELOG.md @@ -0,0 +1,3 @@ +1.0.2 Страничка результатов способна показать историю и правильность ответов для балловго квиза +1.0.1 Отображение для баллового квиза на страничке результатов списка +1.0.0 Добавлены фичи "мультиответ", "перенос строки в своём ответе", "свой ответ", "плейсхолдер своего ответа" diff --git a/lib/assets/icons/CorrectAnswer.tsx b/lib/assets/icons/CorrectAnswer.tsx new file mode 100644 index 0000000..f059f88 --- /dev/null +++ b/lib/assets/icons/CorrectAnswer.tsx @@ -0,0 +1,39 @@ +import { Box, SxProps } from "@mui/material"; + +type Props = { + sx?: SxProps; +}; + +export const CorrectAnswer = ({ sx }: Props) => { + return ( + + + + + + + ); +}; diff --git a/lib/assets/icons/IncorrectAnswer.tsx b/lib/assets/icons/IncorrectAnswer.tsx new file mode 100644 index 0000000..95473c3 --- /dev/null +++ b/lib/assets/icons/IncorrectAnswer.tsx @@ -0,0 +1,46 @@ +import { Box, SxProps } from "@mui/material"; + +type Props = { + sx?: SxProps; +}; + +export const IncorrectAnswer = ({ sx }: Props) => { + return ( + + + + + + + + ); +}; diff --git a/lib/assets/icons/TickOpenClose.tsx b/lib/assets/icons/TickOpenClose.tsx new file mode 100644 index 0000000..39dbc24 --- /dev/null +++ b/lib/assets/icons/TickOpenClose.tsx @@ -0,0 +1,45 @@ +import { Box, SxProps } from "@mui/material"; + +type Props = { + checked?: boolean; + sx?: SxProps; +}; + +export const TickOpenClose = ({ checked = false, sx }: Props) => { + return ( + + + + + + + ); +}; diff --git a/lib/components/ViewPublicationPage/Footer.tsx b/lib/components/ViewPublicationPage/Footer.tsx index 0f9a6fb..f9c41e3 100644 --- a/lib/components/ViewPublicationPage/Footer.tsx +++ b/lib/components/ViewPublicationPage/Footer.tsx @@ -16,9 +16,6 @@ export const Footer = ({ stepNumber, nextButton, prevButton }: FooterProps) => { const { questions, settings } = useQuizSettings(); const questionsAmount = questions.filter(({ type }) => type !== "result").length; - console.log("questions"); - console.log(questions); - return ( { + const theme = useTheme(); + + const { questions } = useQuizSettings(); + const answers = useQuizViewStore((state) => state.answers); + + const questionsWothoutResult = questions.filter( + (q: AnyTypedQuizQuestion): q is QuizQuestionVariant => q.type === "variant" + ); + + return questionsWothoutResult.map((currentQuestion) => { + let answerIndex = 0; + let currentVariants = currentQuestion.content.variants; + + const currentAnswer = answers.find((a) => a.questionId === currentQuestion.id); + + const answeredVariant = currentVariants.find((v, i) => { + if (v.id === currentAnswer?.answer) { + answerIndex = i; + return true; + } + }); + + return ( + + + + + {currentQuestion.page + 1}. + + {currentQuestion.title || "Вопрос без названия"} + + + {answeredVariant?.points || "0"}/10 + + + + + Ваш ответ: + + + + {/* {Boolean(answeredVariant?.points) ? : } + {answeredVariant?.answer || "не выбрано"} */} + {currentVariants.map((v) => { + if (v.id === currentAnswer?.answer) { + return <>; + } else + return ( + + ); + })} + + + + ); + }); +}; + +interface LineProps { + checkTrue: boolean; + text?: string; +} + +const Line = ({ checkTrue, text }: LineProps) => { + const theme = useTheme(); + + return ( + + {checkTrue ? : } + + {text || "не выбрано"} + + + ); +}; diff --git a/lib/components/ViewPublicationPage/ResultForm.tsx b/lib/components/ViewPublicationPage/ResultForm.tsx index cd620c6..b219d40 100644 --- a/lib/components/ViewPublicationPage/ResultForm.tsx +++ b/lib/components/ViewPublicationPage/ResultForm.tsx @@ -14,6 +14,8 @@ import { NameplateLogo } from "@icons/NameplateLogo"; import type { QuizQuestionResult } from "@/model/questionTypes/result"; import QuizVideo from "@/ui_kit/VideoIframe/VideoIframe"; +import { TextAccordion } from "./tools/TextAccordion"; +import { PointSystemResultList } from "./PointSystemResultList"; type ResultFormProps = { resultQuestion: QuizQuestionResult; @@ -185,6 +187,34 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => { {resultQuestion.content.text} )} + {settings.cfg?.score && ( + + Посмотреть ответы + + } + sx={{ + mt: "60px", + width: "100%", + }} + > + + + + + )} {show_badge && ( diff --git a/lib/components/ViewPublicationPage/tools/TextAccordion.tsx b/lib/components/ViewPublicationPage/tools/TextAccordion.tsx new file mode 100644 index 0000000..e87d86a --- /dev/null +++ b/lib/components/ViewPublicationPage/tools/TextAccordion.tsx @@ -0,0 +1,43 @@ +import { TickOpenClose } from "@/assets/icons/TickOpenClose"; +import { Box, SxProps, Typography, useTheme } from "@mui/material"; +import { useState, ReactNode } from "react"; + +interface Props { + headerText: ReactNode; + children: ReactNode; + sx?: SxProps; +} + +export const TextAccordion = ({ headerText, children, sx }: Props) => { + const theme = useTheme(); + + const [open, setOpen] = useState(false); + + return ( + setOpen((old) => !old)} + > + + {headerText} + + + {open && children} + + ); +}; diff --git a/lib/utils/sendQuestionAnswer.ts b/lib/utils/sendQuestionAnswer.ts index 1a5aaeb..939a699 100644 --- a/lib/utils/sendQuestionAnswer.ts +++ b/lib/utils/sendQuestionAnswer.ts @@ -87,12 +87,14 @@ export function sendQuestionAnswer( let answerString = ``; selectedVariants.forEach((e) => { - if (!e.isOwn) answerString += `\`${e.answer}\`,`; + if (!e.isOwn || (e.isOwn && question.content.own)) { + const body = { + Image: e.extendedText, + Description: e.isOwn ? ownAnswer : e.answer, + }; + answerString += `\`${JSON.stringify(body)}\`,`; + } }); - - if (question.content.own && selectedVariants.some((v) => v.isOwn)) { - answerString += `\`${ownAnswer}\`,`; - } answerString = answerString.slice(0, -1); return sendAnswer({ @@ -213,7 +215,7 @@ export function sendQuestionAnswer( return sendAnswer({ questionId: question.id, - body: JSON.stringify(body), + body: `\`${JSON.stringify(body)}\``, qid: quizId, }); } diff --git a/src/ CHANGELOG.md b/src/ CHANGELOG.md deleted file mode 100644 index 517627c..0000000 --- a/src/ CHANGELOG.md +++ /dev/null @@ -1 +0,0 @@ -1.0.0 Добавлены фичи "мультиответ", "перенос строки в своём ответе", "свой ответ", "плейсхолдер своего ответа"