zlnortheastern / kanbas-quizzes-group9

MIT License
0 stars 0 forks source link

`answer.answers[index]`为undefined #23

Closed lemonzeng closed 1 month ago

lemonzeng commented 1 month ago
89e648e0903265eca8cee315a72e10e 458bf4200fc765196a263fe416e1c35
{questions.map((question, index) => (
          <div key={index} className="mx-3 mb-4 border border-secondary">
            <div
              className="p-3 border-bottom border-secondary"
              style={{ backgroundColor: "#f5f5f5" }}
            >
              <div className="float-end font-color-secondary">
                {answer.answers[index].score}/ {question.points} pts
              </div>
              <div className="fw-bold">Question {index + 1}</div>
            </div>

            <div>
              <div id="question-description" className="p-3 my-3">
                {question.question}
              </div>
              <div>
                <AnswerByType
                  question={question}
                  answer={answer.answers[index]}
                  showCorrect={showCorrect}
                />
              </div>
            </div>
          </div>
        ))}

原因: answer.answers.length != question.length 导致answer.answers[index]为undefined

lemonzeng commented 1 month ago

修改测试数据导致的