обязательность выбора стартовой страницы у квиза
This commit is contained in:
parent
3f95f32ec9
commit
237f7f5288
@ -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) => {
|
||||||
|
|||||||
@ -30,7 +30,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>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user