feat: question analysis in view

This commit is contained in:
IlyaDoronin 2023-12-05 10:34:41 +03:00
parent 64601e74de
commit 8e6852f38c

@ -37,13 +37,16 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => {
const followNextStep = () => {
if (answers.length) {
const answer = answers.find(
({ questionId }) => questionId === question.content.id
);
let readyBeNextQuestion = "";
question.content.rule.main.forEach(({ next, rules }) => {
let longerArray = Math.max(
rules[0].answers.length,
[answers.at(-1)?.answer].length
[answer?.answer].length
);
for (
@ -51,13 +54,12 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => {
i < longerArray;
i++ // Цикл по всем эле­мен­там бОльшего массива
) {
if (rules[0].answers[i] === answers.at(-1)?.answer) {
if (rules[0].answers[i] === answer?.answer) {
readyBeNextQuestion = next; // Ес­ли хоть один эле­мент от­ли­ча­ет­ся, мас­си­вы не рав­ны
}
}
});
if (readyBeNextQuestion) {
const nextQuestion = getQuestionByContentId(readyBeNextQuestion);
if (nextQuestion) {