How to implement tests I have never done, I tried to do it for the first time. I implemented about the output from mysql arrays of questions, answers and correct answers, but I have a problem in that it does not work out. Template engine I use pug. I have such an architecture in the database. Subject, questions, answers (and there are stored the correct answers). THEN, from right to left, such a link has a Theme-> Questions-> Answers Only the fact that I received an array of answers I cannot display them normally My implementation

const Router = require('koa-router'), User = require('./model/user'), //Хранятся запросы в таблицу User Test = require('./model/test'), //Хранятся запросы в таблицу Test router = new Router(); router.get('/testing/:id', async ctx => { /** Создаю пустые массивы для ответов и правильных ответов*/ let answearArr = []; let answerCorrectArr = []; let theme = await Test.theme(ctx.params.id); // Получаю название темы по id страницы let test = await Test.test(ctx.params.id); // Получаю все вопросы, где тема = id for(i=0; i < test.length; i++){ let answear = test[i].id; answearArr.push(await Test.answear(answear)); // Делаю выборку и помещаю каждый ответ в массив ответов } for(i=0; i < answearArr.length; i++){ let arr = answearArr[i]; // делаю выборку ответов на вопросы в массиве for(n=0; n < arr.length; n++){ let arr1 = arr[n]; // Выбираю каждый ответ отдельный if(arr1.answer === 1){ answerCorrectArr.push(arr1.id); //помещаю в массив правильных ответов id данного ответа } } } await ctx.render('test', { title: 'Тест', path: 'test', thema: theme[0], test: test, answear: answearArr, }) }) 

In the pug file test

 include layout .container h1=thema.name for question in test p=question.name for answearTest in answear ul li input(type='radio' name=answearTest) | #{answearTest[0].text} // Вот тут/Когда мне нужно выбрать ответы на 1 вопрос 

The following data is stored in arrays

 [ RowDataPacket { id: 1, name: 'Первый вопрос', id_theme: 1 }, RowDataPacket { id: 2, name: 'Второй вопрос', id_theme: 1 }, RowDataPacket { id: 4, name: 'Третий вопрос', id_theme: 1 } ] 

answearArr

 [ [ RowDataPacket { id: 1, text: 'один-два дня', id_question: 1, answer: 1 }, RowDataPacket { id: 2, text: 'более 5 дней', id_question: 1, answer: 0 }, RowDataPacket { id: 3, text: '3-5 дней', id_question: 1, answer: 0 } ], [ RowDataPacket { id: 4, text: 'да', id_question: 2, answer: 1 }, RowDataPacket { id: 5, text: 'нет', id_question: 2, answer: 0 }, RowDataPacket { id: 6, text: 'не постоянно, Меняется постоянно', id_question: 2, answer: 0 } ], [ RowDataPacket { id: 7, text: 'да', id_question: 4, answer: 0 }, RowDataPacket { id: 8, text: 'нет', id_question: 4, answer: 0 }, RowDataPacket { id: 9, text: 'не помню', id_question: 4, answer: 1 } ] ] 

answerCorrectArr

 [ 1, 4, 9 ] 

    0