Hi everyone. My quiz questions are being selected at random from a list and they are not being repeated. I used tutorials or previous questions on the forum to get that far. However I am having some trouble figuring out how to keep the answers to the quiz matched correctly to the quiz questions.
I attached two pictures. One of them works perfectly but does not randomize questions. The second randomizes and doesn't repeat the questions but the answer is ALWAYS wrong. Except for the first iteration.list
You should have a list of questions and a list of indexes to correct answers initially in the same order.
When you randomize the questions index, you use the same index to access the index of the correct answer in the answers list.
It looks like you should be using global Index rather than local QuestionIndex to index your lists or change your if block to use the local QuestionIndex also.
--
Also, since you never remove answers from AnswerList, your indexes get out of sync between your shrinking QuestionList and unshrinking AnswerList.
--
But if you remove the Answer from the AnswerList at the same time you remove the Question from QuestionList, how will you check it when the Submit button is clicked?
You have to save the current Answer in a separate global variable before removing it, and check the Answer global against the user input when Submit is clicked.
댓글 없음:
댓글 쓰기