commit
5e241259f9
@ -5,6 +5,7 @@ import { GetQuestionListRequest, GetQuestionListResponse } from "@model/question
|
|||||||
import { EditQuestionRequest, EditQuestionResponse } from "@model/question/edit";
|
import { EditQuestionRequest, EditQuestionResponse } from "@model/question/edit";
|
||||||
import { DeleteQuestionRequest, DeleteQuestionResponse } from "@model/question/delete";
|
import { DeleteQuestionRequest, DeleteQuestionResponse } from "@model/question/delete";
|
||||||
import { CopyQuestionRequest, CopyQuestionResponse } from "@model/question/copy";
|
import { CopyQuestionRequest, CopyQuestionResponse } from "@model/question/copy";
|
||||||
|
import { replaceSpacesToEmptyLines } from "../utils/replaceSpacesToEmptyLines";
|
||||||
|
|
||||||
|
|
||||||
const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital/squiz";
|
const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital/squiz";
|
||||||
@ -26,7 +27,7 @@ async function getQuestionList(body?: Partial<GetQuestionListRequest>) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
return response.items;
|
return replaceSpacesToEmptyLines(response.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
function editQuestion(body: EditQuestionRequest, signal?: AbortSignal) {
|
function editQuestion(body: EditQuestionRequest, signal?: AbortSignal) {
|
||||||
|
@ -82,11 +82,11 @@ export const AnswerItem = ({
|
|||||||
setQuestionVariantAnswer(target.value || " ");
|
setQuestionVariantAnswer(target.value || " ");
|
||||||
}}
|
}}
|
||||||
onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {
|
onKeyDown={(event: KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (disableKeyDown) {
|
// if (disableKeyDown) {
|
||||||
enqueueSnackbar("100 максимальное количество вопросов");
|
// enqueueSnackbar("100 максимальное количество вопросов");
|
||||||
} else if (event.code === "Enter" && !largeCheck) {
|
// } else if (event.code === "Enter" && !largeCheck) {
|
||||||
addQuestionVariant(questionId);
|
addQuestionVariant(questionId);
|
||||||
}
|
// }
|
||||||
}}
|
}}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment: (
|
startAdornment: (
|
||||||
|
@ -128,8 +128,6 @@ function CsComponent({
|
|||||||
if ((parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page")
|
if ((parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page")
|
||||||
&& parentQuestion.content.rule.children.length === 1
|
&& parentQuestion.content.rule.children.length === 1
|
||||||
) {
|
) {
|
||||||
console.log(parentQuestion.content.rule.children)
|
|
||||||
console.log("parentQuestion.content.rule.children.length === 1",parentQuestion.content.rule.children.length === 1)
|
|
||||||
enqueueSnackbar("у вопроса этого типа может быть только 1 потомок")
|
enqueueSnackbar("у вопроса этого типа может быть только 1 потомок")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -140,8 +138,6 @@ function CsComponent({
|
|||||||
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
||||||
cy?.data('changed', true)
|
cy?.data('changed', true)
|
||||||
createResult(quiz.backendId, targetQuestion.content.id)
|
createResult(quiz.backendId, targetQuestion.content.id)
|
||||||
console.log("Я собираюсь добавить узел из такого вопроса ", targetQuestion)
|
|
||||||
console.log("Я собираюсь добавить узел у которого папаша вот такой ", parentNodeContentId)
|
|
||||||
const es = cy?.add([
|
const es = cy?.add([
|
||||||
{
|
{
|
||||||
data: {
|
data: {
|
||||||
@ -268,7 +264,12 @@ function CsComponent({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
mb="20px">
|
sx={{
|
||||||
|
mb:"20px",
|
||||||
|
display:'flex',
|
||||||
|
justifyContent:"space-between"
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
sx={{
|
sx={{
|
||||||
height: "27px",
|
height: "27px",
|
||||||
|
@ -229,7 +229,11 @@ export const usePopper = ({
|
|||||||
updateOpenedModalSettingsId(item.id());
|
updateOpenedModalSettingsId(item.id());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("собираюсь анализировать папашу")
|
||||||
|
console.log("Тип папаши ", parentQuestion.type)
|
||||||
if (parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page") {
|
if (parentQuestion?.type === "date" || parentQuestion?.type === "text" || parentQuestion?.type === "number" || parentQuestion?.type === "page") {
|
||||||
|
console.log("Шестерня должна быть невидимая")
|
||||||
|
console.log("Тип папаши ", parentQuestion.type)
|
||||||
gearElement.classList.add("popper-gear-none");
|
gearElement.classList.add("popper-gear-none");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ export const useRemoveNode = ({
|
|||||||
|
|
||||||
//Ищём родителя
|
//Ищём родителя
|
||||||
const parentQuestion = getQuestionByContentId(parentQuestionContentId);
|
const parentQuestion = getQuestionByContentId(parentQuestionContentId);
|
||||||
|
if (parentQuestion.content.rule.children.length === 1) { //если у родителя больше нет потомков
|
||||||
//Делаем результат родителя активным
|
//Делаем результат родителя активным
|
||||||
const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId)
|
const parentResult = trashQuestions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestionContentId)
|
||||||
if (parentResult) {
|
if (parentResult) {
|
||||||
updateQuestion(parentResult.content.id, q => {
|
updateQuestion(parentResult.content.id, q => {
|
||||||
@ -83,6 +83,9 @@ export const useRemoveNode = ({
|
|||||||
createResult(quiz?.backendId, parentQuestionContentId)
|
createResult(quiz?.backendId, parentQuestionContentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//чистим rule родителя
|
//чистим rule родителя
|
||||||
if (!parentQuestion?.type) {
|
if (!parentQuestion?.type) {
|
||||||
return;
|
return;
|
||||||
|
@ -26,7 +26,7 @@ import { useQuestionsStore } from "@root/questions/store";
|
|||||||
import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
|
import { updateOpenedModalSettingsId } from "@root/uiTools/actions";
|
||||||
import { updateRootContentId } from "@root/quizes/actions";
|
import { updateRootContentId } from "@root/quizes/actions";
|
||||||
import { useUiTools } from "@root/uiTools/store";
|
import { useUiTools } from "@root/uiTools/store";
|
||||||
import {useState} from "react";
|
import { useState } from "react";
|
||||||
import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
||||||
import { DeleteFunction } from "@utils/deleteFunc";
|
import { DeleteFunction } from "@utils/deleteFunc";
|
||||||
|
|
||||||
@ -118,116 +118,116 @@ export default function ButtonsOptions({
|
|||||||
>
|
>
|
||||||
{buttonSetting.map(({ icon, title, value, myFunc }) => (
|
{buttonSetting.map(({ icon, title, value, myFunc }) => (
|
||||||
<Box key={value}>
|
<Box key={value}>
|
||||||
{value === "branching" ?
|
{value === "branching" ?
|
||||||
question.type === "page" || question.type === "text" || question.type === "date" || question.type === "number" ?
|
question.type === "page" || question.type === "text" || question.type === "date" || question.type === "number" ?
|
||||||
<></>
|
<></>
|
||||||
:
|
:
|
||||||
(
|
(
|
||||||
// <Tooltip
|
// <Tooltip
|
||||||
// arrow
|
// arrow
|
||||||
// placement="right"
|
// placement="right"
|
||||||
// componentsProps={{
|
// componentsProps={{
|
||||||
// tooltip: {
|
// tooltip: {
|
||||||
// sx: {
|
// sx: {
|
||||||
// background: "#fff",
|
// background: "#fff",
|
||||||
// borderRadius: "6px",
|
// borderRadius: "6px",
|
||||||
// color: "#9A9AAF",
|
// color: "#9A9AAF",
|
||||||
// boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
// boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
||||||
// "& .MuiTooltip-arrow": {
|
// "& .MuiTooltip-arrow": {
|
||||||
// color: "#FFF",
|
// color: "#FFF",
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
// }}
|
// }}
|
||||||
// title={
|
// title={
|
||||||
// <Box>
|
// <Box>
|
||||||
// <Typography
|
// <Typography
|
||||||
// sx={{
|
// sx={{
|
||||||
// color: "#4D4D4D",
|
// color: "#4D4D4D",
|
||||||
// fontWeight: "bold",
|
// fontWeight: "bold",
|
||||||
// fontSize: "14px",
|
// fontSize: "14px",
|
||||||
// marginBottom: "10px",
|
// marginBottom: "10px",
|
||||||
// }}
|
// }}
|
||||||
// >
|
// >
|
||||||
// Будет показан при условии
|
// Будет показан при условии
|
||||||
// </Typography>
|
// </Typography>
|
||||||
// <Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
// <Typography sx={{ fontWeight: "bold", fontSize: "12px" }}>
|
||||||
// Название
|
// Название
|
||||||
// </Typography>
|
// </Typography>
|
||||||
// <Typography
|
// <Typography
|
||||||
// sx={{
|
// sx={{
|
||||||
// fontWeight: "bold",
|
// fontWeight: "bold",
|
||||||
// fontSize: "12px",
|
// fontSize: "12px",
|
||||||
// marginBottom: "10px",
|
// marginBottom: "10px",
|
||||||
// }}
|
// }}
|
||||||
// >
|
// >
|
||||||
// Условие 1, Условие 2
|
// Условие 1, Условие 2
|
||||||
// </Typography>
|
// </Typography>
|
||||||
// <Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
// <Typography sx={{ color: "#7E2AEA", fontSize: "12px" }}>
|
||||||
// Все условия обязательны
|
// Все условия обязательны
|
||||||
// </Typography>
|
// </Typography>
|
||||||
// </Box>
|
// </Box>
|
||||||
// }
|
// }
|
||||||
// >
|
// >
|
||||||
<MiniButtonSetting
|
<MiniButtonSetting
|
||||||
key={title}
|
key={title}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
openedModal();
|
openedModal();
|
||||||
// SSHC(value);
|
// SSHC(value);
|
||||||
// myFunc(question);
|
// myFunc(question);
|
||||||
}}
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
display: quiz.config.type === "form" ? "none" : "flex",
|
display: quiz.config.type === "form" ? "none" : "flex",
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
switchState === value
|
switchState === value
|
||||||
? theme.palette.brightPurple.main
|
? theme.palette.brightPurple.main
|
||||||
: "transparent",
|
: "transparent",
|
||||||
color:
|
color:
|
||||||
switchState === value
|
switchState === value
|
||||||
? "#ffffff"
|
? "#ffffff"
|
||||||
: theme.palette.grey3.main,
|
: theme.palette.grey3.main,
|
||||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||||
height: "30px",
|
height: "30px",
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
color: theme.palette.grey3.main,
|
color: theme.palette.grey3.main,
|
||||||
"& path": { stroke: theme.palette.grey3.main },
|
"& path": { stroke: theme.palette.grey3.main },
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
{isWrappMiniButtonSetting ? null : title}
|
{isWrappMiniButtonSetting ? null : title}
|
||||||
</MiniButtonSetting>
|
</MiniButtonSetting>
|
||||||
// </Tooltip>
|
// </Tooltip>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<MiniButtonSetting
|
<MiniButtonSetting
|
||||||
key={title}
|
key={title}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
SSHC(value);
|
SSHC(value);
|
||||||
myFunc();
|
myFunc();
|
||||||
}}
|
}}
|
||||||
sx={{
|
sx={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
switchState === value
|
switchState === value
|
||||||
? theme.palette.brightPurple.main
|
? theme.palette.brightPurple.main
|
||||||
: "transparent",
|
: "transparent",
|
||||||
color:
|
color:
|
||||||
switchState === value
|
switchState === value
|
||||||
? "#ffffff"
|
? "#ffffff"
|
||||||
: theme.palette.grey3.main,
|
: theme.palette.grey3.main,
|
||||||
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
minWidth: isWrappMiniButtonSetting ? "30px" : "64px",
|
||||||
height: "30px",
|
height: "30px",
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
color: theme.palette.grey3.main,
|
color: theme.palette.grey3.main,
|
||||||
"& path": { stroke: theme.palette.grey3.main },
|
"& path": { stroke: theme.palette.grey3.main },
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{icon}
|
{icon}
|
||||||
{isWrappMiniButtonSetting ? null : title}
|
{isWrappMiniButtonSetting ? null : title}
|
||||||
</MiniButtonSetting>
|
</MiniButtonSetting>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
{/* <>
|
{/* <>
|
||||||
@ -282,7 +282,10 @@ export default function ButtonsOptions({
|
|||||||
<IconButton
|
<IconButton
|
||||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if(question.content.rule.parentId.length !== 0) {
|
if (question.type === null) {
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
|
if (question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true)
|
setOpenDelete(true)
|
||||||
} else {
|
} else {
|
||||||
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
deleteQuestionWithTimeout(question.id, () => DeleteFunction(questions, question, quiz));
|
||||||
@ -305,7 +308,7 @@ export default function ButtonsOptions({
|
|||||||
background: "#FFFFFF",
|
background: "#FFFFFF",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" sx={{textAlign: "center"}}>
|
<Typography variant="h6" sx={{ textAlign: "center" }}>
|
||||||
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
Вы удаляете вопрос, участвующий в ветвлении. Все его потомки потеряют данные ветвления. Вы уверены, что хотите удалить вопрос?
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box
|
<Box
|
||||||
|
@ -315,6 +315,9 @@ export default function ButtonsOptionsAndPict({
|
|||||||
<IconButton
|
<IconButton
|
||||||
sx={{ borderRadius: "6px", padding: "2px" }}
|
sx={{ borderRadius: "6px", padding: "2px" }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (question.type === null) {
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
if(question.content.rule.parentId.length !== 0) {
|
if(question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true)
|
setOpenDelete(true)
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,35 +59,35 @@ import { updateSomeWorkBackend } from "@root/uiTools/actions";
|
|||||||
import { DeleteFunction } from "@utils/deleteFunc";
|
import { DeleteFunction } from "@utils/deleteFunc";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||||
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
||||||
isDragging: boolean;
|
isDragging: boolean;
|
||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
|
export default function QuestionsPageCard({ question, draggableProps, isDragging, index }: Props) {
|
||||||
const maxLengthTextField = 225;
|
const maxLengthTextField = 225;
|
||||||
|
|
||||||
const { questions } = useQuestionsStore();
|
const { questions } = useQuestionsStore();
|
||||||
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
const [plusVisible, setPlusVisible] = useState<boolean>(false);
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
const [isTextFieldtActive, setIsTextFieldtActive] = useState(false);
|
const [isTextFieldtActive, setIsTextFieldtActive] = useState(false);
|
||||||
|
|
||||||
const [openDelete, setOpenDelete] = useState<boolean>(false);
|
const [openDelete, setOpenDelete] = useState<boolean>(false);
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||||
const anchorRef = useRef(null);
|
const anchorRef = useRef(null);
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
|
|
||||||
const setTitle = useDebouncedCallback((title) => {
|
const setTitle = useDebouncedCallback((title) => {
|
||||||
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
||||||
|
|
||||||
updateQuestionFn(question.id, question => {
|
updateQuestionFn(question.id, question => {
|
||||||
question.title = title;
|
question.title = title;
|
||||||
});
|
});
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
const handleInputFocus = () => {
|
const handleInputFocus = () => {
|
||||||
setIsTextFieldtActive(true);
|
setIsTextFieldtActive(true);
|
||||||
@ -98,7 +98,7 @@ const maxLengthTextField = 225;
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Paper
|
<Paper
|
||||||
id={question.id}
|
id={question.id}
|
||||||
@ -277,6 +277,9 @@ const maxLengthTextField = 225;
|
|||||||
margin: "0 5px 0 10px",
|
margin: "0 5px 0 10px",
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
if (question.type === null) {
|
||||||
|
deleteQuestion(question.id);
|
||||||
|
}
|
||||||
if (question.content.rule.parentId.length !== 0) {
|
if (question.content.rule.parentId.length !== 0) {
|
||||||
setOpenDelete(true);
|
setOpenDelete(true);
|
||||||
} else {
|
} else {
|
||||||
@ -417,85 +420,85 @@ const maxLengthTextField = 225;
|
|||||||
}
|
}
|
||||||
|
|
||||||
const IconAndrom = (isExpanded: boolean, questionType: QuestionType | null) => {
|
const IconAndrom = (isExpanded: boolean, questionType: QuestionType | null) => {
|
||||||
switch (questionType) {
|
switch (questionType) {
|
||||||
case "variant":
|
case "variant":
|
||||||
return (
|
return (
|
||||||
<Answer
|
<Answer
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "images":
|
case "images":
|
||||||
return (
|
return (
|
||||||
<OptionsPict
|
<OptionsPict
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "varimg":
|
case "varimg":
|
||||||
return (
|
return (
|
||||||
<OptionsAndPict
|
<OptionsAndPict
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "emoji":
|
case "emoji":
|
||||||
return (
|
return (
|
||||||
<Emoji
|
<Emoji
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "text":
|
case "text":
|
||||||
return (
|
return (
|
||||||
<Input
|
<Input
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "select":
|
case "select":
|
||||||
return (
|
return (
|
||||||
<DropDown
|
<DropDown
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "date":
|
case "date":
|
||||||
return (
|
return (
|
||||||
<Date
|
<Date
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "number":
|
case "number":
|
||||||
return (
|
return (
|
||||||
<Slider
|
<Slider
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "file":
|
case "file":
|
||||||
return (
|
return (
|
||||||
<Download
|
<Download
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "page":
|
case "page":
|
||||||
return (
|
return (
|
||||||
<Page
|
<Page
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "rating":
|
case "rating":
|
||||||
return (
|
return (
|
||||||
<RatingIcon
|
<RatingIcon
|
||||||
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
color={isExpanded ? "#9A9AAF" : "#7E2AEA"}
|
||||||
sx={{ height: "22px", width: "20px" }}
|
sx={{ height: "22px", width: "20px" }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,6 @@ export const QuestionSwitchWindowTool = ({ openBranchingPage, setOpenBranchingPa
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
const isMobile = useMediaQuery(theme.breakpoints.down(600));
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
console.log("Я компонент в котором отвечала");
|
|
||||||
|
|
||||||
const openBranchingPageHC = () => {
|
const openBranchingPageHC = () => {
|
||||||
if (!openBranchingPage) {
|
if (!openBranchingPage) {
|
||||||
|
@ -5,9 +5,9 @@ import { useCurrentQuiz } from "@root/quizes/hooks";
|
|||||||
import { useQuestionsStore } from "@root/questions/store";
|
import { useQuestionsStore } from "@root/questions/store";
|
||||||
|
|
||||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||||
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx"
|
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx";
|
||||||
import { NameplateLogo } from "@icons/NameplateLogo";
|
import { NameplateLogo } from "@icons/NameplateLogo";
|
||||||
import {modes} from "../../utils/themes/Publication/themePublication";
|
import { modes } from "../../utils/themes/Publication/themePublication";
|
||||||
|
|
||||||
type ResultFormProps = {
|
type ResultFormProps = {
|
||||||
currentQuestion: AnyTypedQuizQuestion;
|
currentQuestion: AnyTypedQuizQuestion;
|
||||||
@ -21,25 +21,25 @@ export const ResultForm = ({
|
|||||||
showContactForm,
|
showContactForm,
|
||||||
setShowContactForm,
|
setShowContactForm,
|
||||||
setShowResultForm,
|
setShowResultForm,
|
||||||
|
|
||||||
}: ResultFormProps) => {
|
}: ResultFormProps) => {
|
||||||
const quiz = useCurrentQuiz();
|
const quiz = useCurrentQuiz();
|
||||||
const mode = modes;
|
const mode = modes;
|
||||||
const { questions } = useQuestionsStore();
|
const { questions } = useQuestionsStore();
|
||||||
const resultQuestion = questions.find(
|
const resultQuestion = (questions.find(
|
||||||
(question) =>
|
(question) =>
|
||||||
question.type === "result" &&
|
question.type === "result" &&
|
||||||
(question.content.rule.parentId === "line" || currentQuestion.content.id)
|
question.content.rule.parentId === currentQuestion.content.id
|
||||||
);
|
) ||
|
||||||
|
questions.find(
|
||||||
|
(question) =>
|
||||||
|
question.type === "result" && question.content.rule.parentId === "line"
|
||||||
|
)) as AnyTypedQuizQuestion;
|
||||||
|
|
||||||
const followNextForm = () => {
|
const followNextForm = () => {
|
||||||
setShowResultForm(false);
|
setShowResultForm(false);
|
||||||
setShowContactForm(true);
|
setShowContactForm(true);
|
||||||
};
|
};
|
||||||
if (resultQuestion === undefined) return <></>
|
if (resultQuestion === undefined) return <></>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@ -50,10 +50,9 @@ export const ResultForm = ({
|
|||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
height: "100vh",
|
height: "100vh",
|
||||||
width: "100vw",
|
width: "100vw",
|
||||||
pt: "28px"
|
pt: "28px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
@ -62,53 +61,57 @@ export const ResultForm = ({
|
|||||||
width: "490px",
|
width: "490px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{!resultQuestion?.content.useImage && resultQuestion.content.video && (
|
||||||
!resultQuestion?.content.useImage &&
|
|
||||||
resultQuestion.content.video &&
|
|
||||||
<YoutubeEmbedIframe
|
<YoutubeEmbedIframe
|
||||||
videoUrl={resultQuestion.content.video}
|
videoUrl={resultQuestion.content.video}
|
||||||
containerSX={{
|
containerSX={{
|
||||||
width: "490px",
|
width: "490px",
|
||||||
height: "280px"
|
height: "280px",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
{
|
{resultQuestion?.content.useImage && resultQuestion.content.back && (
|
||||||
resultQuestion?.content.useImage &&
|
|
||||||
resultQuestion.content.back &&
|
|
||||||
<Box
|
<Box
|
||||||
component='img'
|
component="img"
|
||||||
src={resultQuestion.content.back}
|
src={resultQuestion.content.back}
|
||||||
sx={{
|
sx={{
|
||||||
width: "490px",
|
width: "490px",
|
||||||
height: "280px"
|
height: "280px",
|
||||||
}}
|
}}
|
||||||
>
|
></Box>
|
||||||
</Box>
|
)}
|
||||||
}
|
{resultQuestion.description !== "" &&
|
||||||
{resultQuestion.description !== "" && resultQuestion.description !== " " && <Typography
|
resultQuestion.description !== " " && (
|
||||||
sx={{
|
<Typography
|
||||||
fontSize: "23px",
|
sx={{
|
||||||
fontWeight: 700,
|
fontSize: "23px",
|
||||||
m: "20px 0"
|
fontWeight: 700,
|
||||||
}}
|
m: "20px 0",
|
||||||
>{resultQuestion.description}</Typography>}
|
}}
|
||||||
|
>
|
||||||
|
{resultQuestion.description}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
m: "20px 0"
|
m: "20px 0",
|
||||||
}}
|
}}
|
||||||
>{resultQuestion.title || "Форма результатов"}
|
>
|
||||||
|
{resultQuestion.title || "Форма результатов"}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{resultQuestion.content.text !== "" && resultQuestion.content.text !== " " && <Typography
|
{resultQuestion.content.text !== "" &&
|
||||||
sx={{
|
resultQuestion.content.text !== " " && (
|
||||||
fontSize: "18px",
|
<Typography
|
||||||
m: "20px 0"
|
sx={{
|
||||||
}}
|
fontSize: "18px",
|
||||||
>{resultQuestion.content.text}</Typography>}
|
m: "20px 0",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{resultQuestion.content.text}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box width="100%">
|
<Box width="100%">
|
||||||
@ -117,24 +120,30 @@ export const ResultForm = ({
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
justifyContent: "end",
|
justifyContent: "end",
|
||||||
px: "20px"
|
px: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
mt: "15px"
|
mt: "15px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<NameplateLogo style={{ fontSize: "34px" }} />
|
<NameplateLogo style={{ fontSize: "34px" }} />
|
||||||
<Typography sx={{ fontSize: "20px", color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF", whiteSpace: "nowrap" }}>Сделано на PenaQuiz</Typography>
|
<Typography
|
||||||
|
sx={{
|
||||||
|
fontSize: "20px",
|
||||||
|
color: mode[quiz.config.theme] ? "#4D4D4D" : "#F5F7FF",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Сделано на PenaQuiz
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{
|
{quiz?.config.resultInfo.when === "before" && (
|
||||||
quiz?.config.resultInfo.when === "before" &&
|
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -144,7 +153,7 @@ export const ResultForm = ({
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
p: "20px"
|
p: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
@ -153,17 +162,15 @@ export const ResultForm = ({
|
|||||||
sx={{
|
sx={{
|
||||||
p: "10px 20px",
|
p: "10px 20px",
|
||||||
width: "210px",
|
width: "210px",
|
||||||
height: "50px"
|
height: "50px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -130,7 +130,7 @@ export default function EditPage() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
|
const updateQuestionHint = useDebouncedCallback((questions: AnyTypedQuizQuestion[]) => {
|
||||||
const problems = checkQuestionHint(questions);
|
const problems = checkQuestionHint(questions, quiz);
|
||||||
useUiTools.setState({ whyCantCreatePublic: problems });
|
useUiTools.setState({ whyCantCreatePublic: problems });
|
||||||
if (Object.keys(problems).length > 0) {
|
if (Object.keys(problems).length > 0) {
|
||||||
updateQuiz(quiz?.id, (state) => {
|
updateQuiz(quiz?.id, (state) => {
|
||||||
@ -187,8 +187,6 @@ export default function EditPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(quiz?.status);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/*хедер*/}
|
{/*хедер*/}
|
||||||
@ -223,6 +221,12 @@ export default function EditPage() {
|
|||||||
</Link>
|
</Link>
|
||||||
<FormControl fullWidth variant="standard">
|
<FormControl fullWidth variant="standard">
|
||||||
<TextField
|
<TextField
|
||||||
|
value={quiz.name}
|
||||||
|
onChange={(e) =>
|
||||||
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
|
quiz.name = e.target.value;
|
||||||
|
})
|
||||||
|
}
|
||||||
fullWidth
|
fullWidth
|
||||||
id="project-name"
|
id="project-name"
|
||||||
placeholder="Название проекта окно"
|
placeholder="Название проекта окно"
|
||||||
@ -461,7 +465,7 @@ export default function EditPage() {
|
|||||||
fontSize: "14px",
|
fontSize: "14px",
|
||||||
lineHeight: "18px",
|
lineHeight: "18px",
|
||||||
height: "34px",
|
height: "34px",
|
||||||
background: quiz?.status === "start" ? "#7E2AEA" : "#FA5B0E",
|
background: buttonText === "Опубликовано" ? "#FA5B0E" : "#7E2AEA",
|
||||||
}}
|
}}
|
||||||
onClick={handleClickStatusQuiz}
|
onClick={handleClickStatusQuiz}
|
||||||
>
|
>
|
||||||
|
@ -7,6 +7,14 @@ import { useLayoutEffect } from "react";
|
|||||||
export const ModalInfoWhyCantCreate = () => {
|
export const ModalInfoWhyCantCreate = () => {
|
||||||
const { whyCantCreatePublic, openModalInfoWhyCantCreate } = useUiTools();
|
const { whyCantCreatePublic, openModalInfoWhyCantCreate } = useUiTools();
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
console.log(whyCantCreatePublic)
|
||||||
|
if (Object.values(whyCantCreatePublic).length===0) {
|
||||||
|
console.log("нет проблем")
|
||||||
|
updateModalInfoWhyCantCreate(false)
|
||||||
|
}
|
||||||
|
}, [openModalInfoWhyCantCreate])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={openModalInfoWhyCantCreate} onClose={() => updateModalInfoWhyCantCreate(false)}>
|
<Modal open={openModalInfoWhyCantCreate} onClose={() => updateModalInfoWhyCantCreate(false)}>
|
||||||
<Box
|
<Box
|
||||||
@ -30,7 +38,7 @@ export const ModalInfoWhyCantCreate = () => {
|
|||||||
{Object.values(whyCantCreatePublic).map((data) => {
|
{Object.values(whyCantCreatePublic).map((data) => {
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography color="#7e2aea">У вопроса "{data.name}"</Typography>
|
<Typography color="#7e2aea">{data.name === "quiz" ? "У квиза" : `У вопроса "${data.name}"`}</Typography>
|
||||||
{data.problems.map((problem) => (
|
{data.problems.map((problem) => (
|
||||||
<Typography p="5px 0">{problem}</Typography>
|
<Typography p="5px 0">{problem}</Typography>
|
||||||
))}
|
))}
|
||||||
|
@ -285,7 +285,7 @@ export default function StartPageSettings() {
|
|||||||
Изображение
|
Изображение
|
||||||
</Typography>
|
</Typography>
|
||||||
<DropZone
|
<DropZone
|
||||||
text={"5 MB максимум"}
|
value={"5 MB максимум"}
|
||||||
sx={{ maxWidth: "300px" }}
|
sx={{ maxWidth: "300px" }}
|
||||||
imageUrl={quiz.config.startpage.background.desktop}
|
imageUrl={quiz.config.startpage.background.desktop}
|
||||||
originalImageUrl={quiz.config.startpage.background.originalDesktop}
|
originalImageUrl={quiz.config.startpage.background.originalDesktop}
|
||||||
@ -320,7 +320,7 @@ export default function StartPageSettings() {
|
|||||||
>
|
>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="URL видео"
|
placeholder="URL видео"
|
||||||
text={quiz.config.startpage.background.video ?? ""}
|
value={quiz.config.startpage.background.video ?? ""}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.startpage.background.video = e.target.value;
|
quiz.config.startpage.background.video = e.target.value;
|
||||||
@ -396,7 +396,7 @@ export default function StartPageSettings() {
|
|||||||
Логотип
|
Логотип
|
||||||
</Typography>
|
</Typography>
|
||||||
<DropZone
|
<DropZone
|
||||||
text={"5 MB максимум"}
|
value={"5 MB максимум"}
|
||||||
sx={{ maxWidth: "300px" }}
|
sx={{ maxWidth: "300px" }}
|
||||||
imageUrl={quiz.config.startpage.logo}
|
imageUrl={quiz.config.startpage.logo}
|
||||||
originalImageUrl={quiz.config.startpage.originalLogo}
|
originalImageUrl={quiz.config.startpage.originalLogo}
|
||||||
@ -460,7 +460,7 @@ export default function StartPageSettings() {
|
|||||||
Логотип
|
Логотип
|
||||||
</Typography>
|
</Typography>
|
||||||
<DropZone
|
<DropZone
|
||||||
text={"5 MB максимум"}
|
value={"5 MB максимум"}
|
||||||
sx={{ maxWidth: "300px" }}
|
sx={{ maxWidth: "300px" }}
|
||||||
imageUrl={quiz.config.startpage.logo}
|
imageUrl={quiz.config.startpage.logo}
|
||||||
originalImageUrl={quiz.config.startpage.originalLogo}
|
originalImageUrl={quiz.config.startpage.originalLogo}
|
||||||
@ -509,7 +509,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="Имя заголовка об опроснике для подбора табуретки"
|
placeholder="Имя заголовка об опроснике для подбора табуретки"
|
||||||
text={quiz.name}
|
value={quiz.name}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.name = e.target.value;
|
quiz.name = e.target.value;
|
||||||
@ -529,7 +529,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="Внимательно заполняйте поля ответов"
|
placeholder="Внимательно заполняйте поля ответов"
|
||||||
text={quiz.config.startpage.description}
|
value={quiz.config.startpage.description}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.startpage.description = e.target.value;
|
quiz.config.startpage.description = e.target.value;
|
||||||
@ -549,7 +549,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="Начать опрос"
|
placeholder="Начать опрос"
|
||||||
text={quiz.config.startpage.button}
|
value={quiz.config.startpage.button}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.startpage.button = e.target.value;
|
quiz.config.startpage.button = e.target.value;
|
||||||
@ -569,7 +569,8 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="8-800-000-00-00"
|
placeholder="8-800-000-00-00"
|
||||||
text={quiz.config.info.phonenumber}
|
type="number"
|
||||||
|
value={quiz.config.info.phonenumber}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.info.phonenumber = e.target.value;
|
quiz.config.info.phonenumber = e.target.value;
|
||||||
@ -599,7 +600,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="Только лучшее"
|
placeholder="Только лучшее"
|
||||||
text={quiz.config.info.orgname}
|
value={quiz.config.info.orgname}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.info.orgname = e.target.value;
|
quiz.config.info.orgname = e.target.value;
|
||||||
@ -619,7 +620,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="https://mysite.com"
|
placeholder="https://mysite.com"
|
||||||
text={quiz.config.info.site}
|
value={quiz.config.info.site}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.info.site = e.target.value;
|
quiz.config.info.site = e.target.value;
|
||||||
@ -639,7 +640,7 @@ export default function StartPageSettings() {
|
|||||||
</Typography>
|
</Typography>
|
||||||
<CustomTextField
|
<CustomTextField
|
||||||
placeholder="Данные наших документов"
|
placeholder="Данные наших документов"
|
||||||
text={quiz.config.info.law}
|
value={quiz.config.info.law}
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
updateQuiz(quiz.id, (quiz) => {
|
updateQuiz(quiz.id, (quiz) => {
|
||||||
quiz.config.info.law = e.target.value;
|
quiz.config.info.law = e.target.value;
|
||||||
|
@ -16,6 +16,7 @@ import { QuestionsStore, useQuestionsStore } from "./store";
|
|||||||
import { useUiTools } from "../uiTools/store";
|
import { useUiTools } from "../uiTools/store";
|
||||||
import { withErrorBoundary } from "react-error-boundary";
|
import { withErrorBoundary } from "react-error-boundary";
|
||||||
import { QuizQuestionResult } from "@model/questionTypes/result";
|
import { QuizQuestionResult } from "@model/questionTypes/result";
|
||||||
|
import { replaceEmptyLinesToSpace } from "../../utils/replaceEmptyLinesToSpace";
|
||||||
|
|
||||||
|
|
||||||
export const setQuestions = (questions: RawQuestion[] | null) => setProducedState(state => {
|
export const setQuestions = (questions: RawQuestion[] | null) => setProducedState(state => {
|
||||||
@ -202,7 +203,7 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
|||||||
if (q.type === null) throw new Error("Cannot send update request for untyped question");
|
if (q.type === null) throw new Error("Cannot send update request for untyped question");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await questionApi.edit(questionToEditQuestionRequest(q));
|
const response = await questionApi.edit(questionToEditQuestionRequest(replaceEmptyLinesToSpace(q)));
|
||||||
|
|
||||||
//Если мы делаем листочек веточкой - удаляем созданный к нему результ
|
//Если мы делаем листочек веточкой - удаляем созданный к нему результ
|
||||||
const questionResult = useQuestionsStore.getState().questions.find(questionResult => questionResult.type === "result" && questionResult.content.rule.parentId === q.content.id);
|
const questionResult = useQuestionsStore.getState().questions.find(questionResult => questionResult.type === "result" && questionResult.content.rule.parentId === q.content.id);
|
||||||
@ -488,7 +489,6 @@ export const clearRuleForAll = () => {
|
|||||||
|| question.content.rule.default.length > 0
|
|| question.content.rule.default.length > 0
|
||||||
|| question.content.rule.parentId.length > 0)
|
|| question.content.rule.parentId.length > 0)
|
||||||
&& question.type !== "result") {
|
&& question.type !== "result") {
|
||||||
console.log("вызываю очистку рул вопросов")
|
|
||||||
updateQuestion(question.content.id, question => {
|
updateQuestion(question.content.id, question => {
|
||||||
question.content.rule.parentId = "";
|
question.content.rule.parentId = "";
|
||||||
question.content.rule.main = [];
|
question.content.rule.main = [];
|
||||||
@ -510,8 +510,6 @@ export const createResult = async (
|
|||||||
//Мы получили запрос на создание резулта. Анализируем существует ли такой. Если да - просто делаем его активным
|
//Мы получили запрос на создание резулта. Анализируем существует ли такой. Если да - просто делаем его активным
|
||||||
const question = useQuestionsStore.getState().questions.find(q => q.type !== null && q?.content.rule.parentId === parentContentId)
|
const question = useQuestionsStore.getState().questions.find(q => q.type !== null && q?.content.rule.parentId === parentContentId)
|
||||||
|
|
||||||
console.log("Получил запрос на создание результа родителю ", parentContentId)
|
|
||||||
console.log("Ищу такой же результ в списке ", question)
|
|
||||||
if (question) {//существует, делаем активным
|
if (question) {//существует, делаем активным
|
||||||
|
|
||||||
updateQuestion(question.id, (q) => {
|
updateQuestion(question.id, (q) => {
|
||||||
@ -539,6 +537,7 @@ export const createResult = async (
|
|||||||
type: "createBackResult",
|
type: "createBackResult",
|
||||||
createdQuestion,
|
createdQuestion,
|
||||||
});
|
});
|
||||||
|
return createdQuestion
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
devlog("Error creating question", error);
|
devlog("Error creating question", error);
|
||||||
enqueueSnackbar("Не удалось создать вопрос");
|
enqueueSnackbar("Не удалось создать вопрос");
|
||||||
|
@ -21,6 +21,7 @@ interface CustomTextFieldProps {
|
|||||||
maxLength?: number;
|
maxLength?: number;
|
||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
InputProps?: Partial<InputProps>;
|
InputProps?: Partial<InputProps>;
|
||||||
|
type?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CustomTextField({
|
export default function CustomTextField({
|
||||||
@ -35,6 +36,7 @@ export default function CustomTextField({
|
|||||||
emptyError,
|
emptyError,
|
||||||
InputProps,
|
InputProps,
|
||||||
maxLength = 200,
|
maxLength = 200,
|
||||||
|
type=""
|
||||||
}: CustomTextFieldProps) {
|
}: CustomTextFieldProps) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -47,7 +49,13 @@ export default function CustomTextField({
|
|||||||
|
|
||||||
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const inputValue = event.target.value;
|
const inputValue = event.target.value;
|
||||||
setInputValue(inputValue);
|
|
||||||
|
if (type === "number" ) {
|
||||||
|
setInputValue(inputValue .replace (/\D/g, ''));
|
||||||
|
} else {
|
||||||
|
setInputValue(inputValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(event);
|
onChange(event);
|
||||||
|
@ -38,7 +38,7 @@ export default function QuizPreviewLayout() {
|
|||||||
const questions = useQuestionsStore((state) => state.questions);
|
const questions = useQuestionsStore((state) => state.questions);
|
||||||
const currentQuizStep = useQuizPreviewStore((state) => state.currentQuestionIndex);
|
const currentQuizStep = useQuizPreviewStore((state) => state.currentQuestionIndex);
|
||||||
|
|
||||||
const nonDeletedQuizQuestions = questions.filter((question) => !question.deleted);
|
const nonDeletedQuizQuestions = questions.filter((question) => !question.deleted && question.type !== "result" );
|
||||||
const maxCurrentQuizStep = nonDeletedQuizQuestions.length > 0 ? nonDeletedQuizQuestions.length - 1 : 0;
|
const maxCurrentQuizStep = nonDeletedQuizQuestions.length > 0 ? nonDeletedQuizQuestions.length - 1 : 0;
|
||||||
const currentProgress = Math.floor((currentQuizStep / maxCurrentQuizStep) * 100);
|
const currentProgress = Math.floor((currentQuizStep / maxCurrentQuizStep) * 100);
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ export default function QuizPreviewLayout() {
|
|||||||
}}
|
}}
|
||||||
IconComponent={(props) => <ArrowDownIcon {...props} />}
|
IconComponent={(props) => <ArrowDownIcon {...props} />}
|
||||||
>
|
>
|
||||||
{Object.values(questions).map(({ id, title }, index) => (
|
{Object.values(questions.filter(q=>q.type!=="result")).map(({ id, title }, index) => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
key={id}
|
key={id}
|
||||||
value={index}
|
value={index}
|
||||||
|
@ -8,7 +8,6 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Page({ question }: Props) {
|
export default function Page({ question }: Props) {
|
||||||
console.log(question);
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
import { AnyTypedQuizQuestion, QuestionBranchingRuleMain } from "@model/questionTypes/shared";
|
import { AnyTypedQuizQuestion, QuestionBranchingRuleMain } from "@model/questionTypes/shared";
|
||||||
import { WhyCantCreatePublic } from "@root/uiTools/store";
|
import { WhyCantCreatePublic } from "@root/uiTools/store";
|
||||||
import { getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
import { getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||||
|
import { Quiz } from "@model/quiz/quiz";
|
||||||
|
|
||||||
export const checkQuestionHint = (questions: AnyTypedQuizQuestion): Record<string, WhyCantCreatePublic> => {
|
export const checkQuestionHint = (questions: AnyTypedQuizQuestion, quiz:Quiz): Record<string, WhyCantCreatePublic> => {
|
||||||
|
|
||||||
const problems: any = {}
|
const problems: any = {}
|
||||||
|
|
||||||
|
if (quiz.config.startpageType === null) problems.quiz = {name: "quiz", problems: ["Не выбран тип стартовой страницы"]}
|
||||||
|
|
||||||
const pushProblem = (id: string, problem: string, title: string) => {
|
const pushProblem = (id: string, problem: string, title: string) => {
|
||||||
//Если первый вопрос с проблемой - создаём запись. Если не первый - добавляем проблему
|
//Если первый вопрос с проблемой - создаём запись. Если не первый - добавляем проблему
|
||||||
if (id in problems) {
|
if (id in problems) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
||||||
import { clearRuleForAll, deleteQuestion, getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
import { clearRuleForAll, createResult, deleteQuestion, getQuestionByContentId, updateQuestion } from "@root/questions/actions";
|
||||||
import { updateRootContentId } from "@root/quizes/actions";
|
import { updateRootContentId } from "@root/quizes/actions";
|
||||||
|
|
||||||
//Всё здесь нужно сделать последовательно. И пусть весь мир ждёт.
|
//Всё здесь нужно сделать последовательно. И пусть весь мир ждёт.
|
||||||
@ -11,11 +11,13 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
|||||||
if (question.content.rule.parentId === "root") { //удалить из стора root и очистить rule всем вопросам
|
if (question.content.rule.parentId === "root") { //удалить из стора root и очистить rule всем вопросам
|
||||||
updateRootContentId(quiz.id, "");
|
updateRootContentId(quiz.id, "");
|
||||||
await clearRuleForAll();
|
await clearRuleForAll();
|
||||||
console.log("очистка рулов закончилась")
|
|
||||||
await deleteQuestion(question.id);
|
await deleteQuestion(question.id);
|
||||||
} else if (question.content.rule.parentId.length > 0) { //удалить из стора вопрос из дерева и очистить его потомков
|
} else if (question.content.rule.parentId.length > 0) { //удалить из стора вопрос из дерева и очистить его потомков
|
||||||
const clearQuestions = [] as string[];
|
const clearQuestions = [] as string[];
|
||||||
|
|
||||||
|
const parentQuestion = getQuestionByContentId(question.content.rule.parentId);
|
||||||
|
let startCountParentChildren = parentQuestion.content.rule.children
|
||||||
|
|
||||||
//записываем потомков , а их результаты удаляем
|
//записываем потомков , а их результаты удаляем
|
||||||
const getChildren = (parentQuestion: AnyTypedQuizQuestion) => {
|
const getChildren = (parentQuestion: AnyTypedQuizQuestion) => {
|
||||||
questions.forEach((targetQuestion) => {
|
questions.forEach((targetQuestion) => {
|
||||||
@ -41,18 +43,54 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//чистим rule родителя
|
//чистим rule родителя
|
||||||
const parentQuestion = getQuestionByContentId(question.content.rule.parentId);
|
|
||||||
const newRule = {};
|
const newRule = {};
|
||||||
|
const parentChildren = [...parentQuestion.content.rule.children];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
console.log("_________________УДАЛЯЕМЫЙ ВОПРОС_________________", question.content.id)
|
||||||
|
console.log(parentChildren)
|
||||||
|
console.log(question.content.id)
|
||||||
|
console.log(parentChildren.includes(question.content.id))
|
||||||
|
|
||||||
|
|
||||||
|
if (parentChildren.includes(question.content.id))
|
||||||
|
parentChildren.splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1)
|
||||||
|
|
||||||
|
console.log("получившийся массив ", parentChildren)
|
||||||
newRule.main = parentQuestion.content.rule.main.filter((data) => data.next !== question.content.id); //удаляем условия перехода от родителя к этому вопросу
|
newRule.main = parentQuestion.content.rule.main.filter((data) => data.next !== question.content.id); //удаляем условия перехода от родителя к этому вопросу
|
||||||
newRule.parentId = parentQuestion.content.rule.parentId;
|
newRule.parentId = parentQuestion.content.rule.parentId;
|
||||||
newRule.default = parentQuestion.content.rule.parentId === question.content.id ? "" : parentQuestion.content.rule.parentId;
|
newRule.default = parentQuestion.content.rule.parentId === question.content.id ? "" : parentQuestion.content.rule.parentId;
|
||||||
newRule.children = [...parentQuestion.content.rule.children].splice(parentQuestion.content.rule.children.indexOf(question.content.id), 1);
|
newRule.children = parentChildren
|
||||||
|
|
||||||
await updateQuestion(question.content.rule.parentId, (PQ) => {
|
await updateQuestion(question.content.rule.parentId, (PQ) => {
|
||||||
PQ.content.rule = newRule;
|
PQ.content.rule = newRule;
|
||||||
});
|
});
|
||||||
await deleteQuestion(question.id);
|
await deleteQuestion(question.id);
|
||||||
|
|
||||||
|
const parentResult = questions.find(q => q.type === "result" && q.content.rule.parentId === parentQuestion.content.id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//сделать результ родителя видимым если у него не осталось потомков
|
||||||
|
console.log("пришло время анализировать сделать ли результат родителя видимым")
|
||||||
|
console.log("количество детей ", startCountParentChildren.length)
|
||||||
|
|
||||||
|
|
||||||
|
if (startCountParentChildren.length === 1) {
|
||||||
|
if (parentResult) {
|
||||||
|
console.log("я нашел результат родителя")
|
||||||
|
await updateQuestion(parentResult.content.id, q => {
|
||||||
|
q.content.usage = true
|
||||||
|
})
|
||||||
|
} else { //почему-то не существует результа у родителя. Создаём. Новосозданные результы видны сразу
|
||||||
|
console.log("я не нашел результат родителя")
|
||||||
|
await createResult(quiz.backendId, parentQuestion.content.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await deleteQuestion(question.id);
|
await deleteQuestion(question.id);
|
||||||
@ -60,8 +98,6 @@ export const DeleteFunction = async (questions: any, question: any, quiz: any) =
|
|||||||
const result = questions.find(q => q.type === "result" && q.content.rule.parentId === question.content.id)
|
const result = questions.find(q => q.type === "result" && q.content.rule.parentId === question.content.id)
|
||||||
if (result) await deleteQuestion(result.id);
|
if (result) await deleteQuestion(result.id);
|
||||||
|
|
||||||
} else {
|
|
||||||
await deleteQuestion(question.id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -6,12 +6,10 @@ import { DeleteFunction } from "@utils/deleteFunc";
|
|||||||
type allQuestionsTypes = AnyTypedQuizQuestion | UntypedQuizQuestion
|
type allQuestionsTypes = AnyTypedQuizQuestion | UntypedQuizQuestion
|
||||||
|
|
||||||
export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], quiz: Quiz|undefined) => {
|
export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], quiz: Quiz|undefined) => {
|
||||||
console.log("Я отвечаю за удаление неудалёнышей при переключении. Привет, буде знакомы")
|
|
||||||
const questionsForDeletion = questions.filter(
|
const questionsForDeletion = questions.filter(
|
||||||
({ type, deleted }) => type && type !== "result" && deleted
|
({ type, deleted }) => type && type !== "result" && deleted
|
||||||
) as AnyTypedQuizQuestion[];
|
) as AnyTypedQuizQuestion[];
|
||||||
if (questionsForDeletion.length > 0) {
|
if (questionsForDeletion.length > 0) {
|
||||||
console.log("меняю занятость беком на true")
|
|
||||||
updateSomeWorkBackend(true)
|
updateSomeWorkBackend(true)
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +17,6 @@ export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], q
|
|||||||
questionsForDeletion.map(question => DeleteFunction(questions, question, quiz))
|
questionsForDeletion.map(question => DeleteFunction(questions, question, quiz))
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log("______________меняю на 'можно редактировать дальше'______________")
|
|
||||||
updateSomeWorkBackend(false)
|
updateSomeWorkBackend(false)
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -6,11 +6,11 @@ export const useAddAnswer = () => {
|
|||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
|
||||||
const onClickAddAnAnswer = (question: QuizQuestionsWithVariants) => {
|
const onClickAddAnAnswer = (question: QuizQuestionsWithVariants) => {
|
||||||
if (question.content.variants.length >= 10) {
|
// if (question.content.variants.length >= 10) {
|
||||||
enqueueSnackbar("100 максимальное количество вопросов");
|
// enqueueSnackbar("100 максимальное количество вопросов");
|
||||||
} else {
|
// } else {
|
||||||
addQuestionVariant(question.id);
|
addQuestionVariant(question.id);
|
||||||
}
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
return onClickAddAnAnswer;
|
return onClickAddAnAnswer;
|
||||||
|
33
src/utils/replaceEmptyLinesToSpace.ts
Normal file
33
src/utils/replaceEmptyLinesToSpace.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
export const replaceEmptyLinesToSpace = <T = unknown>(object: T): T => {
|
||||||
|
if (Array.isArray(object)) {
|
||||||
|
return object.map(replaceEmptyLinesToSpace) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!object || typeof object !== "object") {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: Record<string, unknown> = {};
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(object)) {
|
||||||
|
if (typeof value === "string") {
|
||||||
|
if (value === "") {
|
||||||
|
result[key] = " ";
|
||||||
|
} else {
|
||||||
|
result[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === "object") {
|
||||||
|
result[key] = replaceEmptyLinesToSpace(value);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result as T;
|
||||||
|
};
|
29
src/utils/replaceSpacesToEmptyLines.ts
Normal file
29
src/utils/replaceSpacesToEmptyLines.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
export const replaceSpacesToEmptyLines = <T = unknown>(object: T): T => {
|
||||||
|
if (Array.isArray(object)) {
|
||||||
|
return object.map(replaceSpacesToEmptyLines) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!object || typeof object !== "object") {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: Record<string, unknown> = {};
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(object)) {
|
||||||
|
if (typeof value === "string") {
|
||||||
|
result[key] = value.replace(/ /g, "");
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === "object") {
|
||||||
|
result[key] = replaceSpacesToEmptyLines(value);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result as T;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user