diff --git a/ CHANGELOG.md b/ CHANGELOG.md index dcee8de5..fbc3ff99 100644 --- a/ CHANGELOG.md +++ b/ CHANGELOG.md @@ -1 +1,2 @@ +1.0.1 Страница заявок корректно отображает мультиответ 1.0.0 Добавлены фичи "мультиответ", "перенос строки в своём ответе", "свой ответ", "плейсхолдер своего ответа" \ No newline at end of file diff --git a/src/pages/QuizAnswersPage/AnswerList.tsx b/src/pages/QuizAnswersPage/AnswerList.tsx index 14ff0b7c..0ba466be 100644 --- a/src/pages/QuizAnswersPage/AnswerList.tsx +++ b/src/pages/QuizAnswersPage/AnswerList.tsx @@ -1,7 +1,7 @@ import { FC } from "react"; import { Box, Typography } from "@mui/material"; import { DateDefinition, TimeDefinition } from "./helper"; -import { CardAnswer } from "./CardAnswer"; +import { CardAnswer } from "./cardAnswers/CardAnswer"; import { Result } from "@root/results/store"; interface AnswerListProps { diff --git a/src/pages/QuizAnswersPage/CardAnswer.tsx b/src/pages/QuizAnswersPage/cardAnswers/CardAnswer.tsx similarity index 90% rename from src/pages/QuizAnswersPage/CardAnswer.tsx rename to src/pages/QuizAnswersPage/cardAnswers/CardAnswer.tsx index d7cdef6f..7a43aaa9 100644 --- a/src/pages/QuizAnswersPage/CardAnswer.tsx +++ b/src/pages/QuizAnswersPage/cardAnswers/CardAnswer.tsx @@ -1,9 +1,9 @@ import { ArrowDownIcon } from "@icons/questionsPage/ArrowDownIcon"; import { Box, IconButton, Link, Typography, useMediaQuery, useTheme } from "@mui/material"; import { FC, MouseEvent, useState } from "react"; -import { ContactIcon } from "./icons/ContactIcon"; -import { MessageIcon } from "./icons/MessageIcon"; -import { PhoneIcon } from "./icons/PhoneIcon"; +import { ContactIcon } from "../icons/ContactIcon"; +import { MessageIcon } from "../icons/MessageIcon"; +import { PhoneIcon } from "../icons/PhoneIcon"; import { DeleteIcon } from "@icons/questionsPage/deleteIcon"; import { deleteResult, obsolescenceResult } from "@root/results/actions"; @@ -12,10 +12,14 @@ import { useQuizStore } from "@root/quizes/store"; import { useQuestionsStore } from "@root/questions/store"; import AddressIcon from "@icons/ContactFormIcon/AddressIcon"; -import { DeleteModal } from "./DeleteModal"; +import { DeleteModal } from "../DeleteModal"; import type { AnyTypedQuizQuestion } from "@frontend/squzanswerer"; import { useCurrentQuiz } from "@/stores/quizes/hooks"; +import { ListOfOptionsCardAnswer } from "./ListOfOptionsCardAnswer"; +import { ListOfImagesCardAnswer } from "./ListOfImagesCardAnswer"; + +import { timewebContentFile, timewebContent } from "./helper" interface CardAnswerProps { isNew: boolean; @@ -312,6 +316,26 @@ export const CardAnswer: FC = ({ qid = quest[i].backendId } } + if (answer?.Version !== undefined) { + if (typeOuestion === "variant" || typeOuestion === "emoji") return ( + + ) + if (typeOuestion === "varimg" || typeOuestion === "images" && answer.content.includes("Image")) return ( + + ) + + } + return ( = ({ {id + 1}. {titleQuestion}. - {typeOuestion === "file" && ( + {typeOuestion === "file" && answer.content && ( = ({ {!(typeOuestion === "file" || typeOuestion === "images" || typeOuestion === "varimg") && ( {answer.content} )} + ); })} @@ -433,26 +458,3 @@ export const CardAnswer: FC = ({ ); }; - -function timewebContentFile(editQuizId: string, content: string, qid: string) { - if (content.includes(" - return content.split("<")[1].split('src="')[1].split('"/>')[0] - } - //Новая версия: контент просто записан с указанием расширения файла - return `https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizanswer/${editQuizId}/${qid}/${content}` -} -function timewebContent(editQuizId: string, content: string, qid: string) { - if (content.includes(" - return content.split("<")[1].split('src="')[1].split('"/>')[0] - } - if (content.includes(`"Image"`)) { - const data = JSON.parse(content) - return data.Image - } - //Новая версия: контент просто записан с указанием расширения файла(устарело) - return `https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/${editQuizId}/${content}` -} \ No newline at end of file diff --git a/src/pages/QuizAnswersPage/cardAnswers/ListOfImagesCardAnswer.tsx b/src/pages/QuizAnswersPage/cardAnswers/ListOfImagesCardAnswer.tsx new file mode 100644 index 00000000..3a754928 --- /dev/null +++ b/src/pages/QuizAnswersPage/cardAnswers/ListOfImagesCardAnswer.tsx @@ -0,0 +1,55 @@ +import { Box, Typography } from "@mui/material"; +import { splitUserText, timewebContent } from "./helper"; + +interface Props { + title: string; + id: number; + answer: string; + quizId: string; + questionId: string; +} + +export const ListOfImagesCardAnswer = ({ + title, + id, + answer, + quizId, + questionId, +}: Props) => { + console.log('"' + answer + '"') + console.log(splitUserText('"' + answer + '"')) + + return e.stopPropagation()} + > + + {id + 1}. {title}. + + + { + splitUserText(answer) + .filter(text => text.length) + .map(text => { + const { Image, Description } = JSON.parse(text) + console.log("Image, Descripton") + console.log(Image, Description) + console.log("Image, Descripton") + return (<> + + {Description} + ) + + }) + } + + +}; \ No newline at end of file diff --git a/src/pages/QuizAnswersPage/cardAnswers/ListOfOptionsCardAnswer.tsx b/src/pages/QuizAnswersPage/cardAnswers/ListOfOptionsCardAnswer.tsx new file mode 100644 index 00000000..74a0faf3 --- /dev/null +++ b/src/pages/QuizAnswersPage/cardAnswers/ListOfOptionsCardAnswer.tsx @@ -0,0 +1,37 @@ +import { Box, Typography } from "@mui/material"; +import { splitUserText } from "./helper"; + +interface Props { + title: string; + id: number; + answer: string; +} + +export const ListOfOptionsCardAnswer = ({ + title, + id, + answer +}: Props) => { + + return e.stopPropagation()} + > + + {id + 1}. {title}. + + + { + splitUserText(answer) + .filter(text => text.length) + .map(text => {text}) + } + + + + +}; \ No newline at end of file diff --git a/src/pages/QuizAnswersPage/cardAnswers/helper.ts b/src/pages/QuizAnswersPage/cardAnswers/helper.ts new file mode 100644 index 00000000..9a2cb5ab --- /dev/null +++ b/src/pages/QuizAnswersPage/cardAnswers/helper.ts @@ -0,0 +1,38 @@ +export function splitUserText(input: string) { + // Регулярное выражение для поиска текста в обратных кавычках + const regex = /`([^`]*)`/g; // Изменено на ([^]*) для захвата пустых строк + let result = []; + let match; + + // Найти все совпадения + while ((match = regex.exec(input)) !== null) { + // Добавляем найденный текст (включая пустые строки) в массив + result.push(match[1]); + } + + return result; +} + +export function timewebContentFile(editQuizId: string, content: string, qid: string) { + if (content.includes(" + return content.split("<")[1].split('src="')[1].split('"/>')[0] + } + //Новая версия: контент просто записан с указанием расширения файла + return `https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizanswer/${editQuizId}/${qid}/${content}` +} +export function timewebContent(editQuizId: string, content: string, qid: string) { + if (content.includes(" + return content.split("<")[1].split('src="')[1].split('"/>')[0] + } else if (content.includes(`"Image"`)) { + const data = JSON.parse(content) + return data.Image + } else { + return content + } + //Новая версия: контент просто записан с указанием расширения файла(устарело) + return `https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/${editQuizId}/${content}` +} \ No newline at end of file