How can I tell which variable is missing?
Posted on 2013-12-21
A user takes a test, but they fail to answer a couple of questions. I need to determine which questions they didn't answer and insert those instances into a table.
Right now, my quiz table looks like this:
id, class_content_id, question, answer, correct_answer, question_id
1 27 blah, blah blah,blah Y 1
2 27 blah, blah blah, blah 1
3 27 blah, blah blah, blah 1
4 27 blah, blah blah, blah 2
5 27 blah, blah blah, blah Y 2
6 27 blah, blah blah, blah 3
7 27 blah, blah blah, blah 3
8 27 blah, blah blah, blah 3
9 27 blah, blah blah, blah Y 3
...there's more than one question, but hopefully you can trace my logic. You've got several questions, each is a multiple choice question so you have several possible answers, but the correct answer is distinguished by the presence of the "Y" under correct answer.
When the system goes to correct the test, it uploads each response into a separate table in order to first determine whether or not all of the questions were answered. That table looks like this:
id class_content_id question_id session_number
1 27 1 12345
2 27 2 12345
I'll count the number of rows in the quiz_finish table and then compare that to the number of distinct rows in the quiz table, based on the question_id.
I'm at that point now where I need to figure out which question specifically was left unanswered. I've played around with a couple of options, but I'm not getting it done.
I began by looping the quiz_finish table and attempting to compare that to the quiz table using a for loop, thinking that I could establish $i as the actual question id, and do a comparison and while I think that could do it, I've yet to get it to work.