feat: question analysis in view
This commit is contained in:
parent
64601e74de
commit
8e6852f38c
@ -37,13 +37,16 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => {
|
|||||||
|
|
||||||
const followNextStep = () => {
|
const followNextStep = () => {
|
||||||
if (answers.length) {
|
if (answers.length) {
|
||||||
|
const answer = answers.find(
|
||||||
|
({ questionId }) => questionId === question.content.id
|
||||||
|
);
|
||||||
|
|
||||||
let readyBeNextQuestion = "";
|
let readyBeNextQuestion = "";
|
||||||
|
|
||||||
question.content.rule.main.forEach(({ next, rules }) => {
|
question.content.rule.main.forEach(({ next, rules }) => {
|
||||||
|
|
||||||
let longerArray = Math.max(
|
let longerArray = Math.max(
|
||||||
rules[0].answers.length,
|
rules[0].answers.length,
|
||||||
[answers.at(-1)?.answer].length
|
[answer?.answer].length
|
||||||
);
|
);
|
||||||
|
|
||||||
for (
|
for (
|
||||||
@ -51,13 +54,12 @@ export const Footer = ({ setCurrentQuestion, question }: FooterProps) => {
|
|||||||
i < longerArray;
|
i < longerArray;
|
||||||
i++ // Цикл по всем элементам бОльшего массива
|
i++ // Цикл по всем элементам бОльшего массива
|
||||||
) {
|
) {
|
||||||
if (rules[0].answers[i] === answers.at(-1)?.answer) {
|
if (rules[0].answers[i] === answer?.answer) {
|
||||||
readyBeNextQuestion = next; // Если хоть один элемент отличается, массивы не равны
|
readyBeNextQuestion = next; // Если хоть один элемент отличается, массивы не равны
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (readyBeNextQuestion) {
|
if (readyBeNextQuestion) {
|
||||||
|
|
||||||
const nextQuestion = getQuestionByContentId(readyBeNextQuestion);
|
const nextQuestion = getQuestionByContentId(readyBeNextQuestion);
|
||||||
|
|
||||||
if (nextQuestion) {
|
if (nextQuestion) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user