DB table structure:
Session Table (aka Exam Table)
SessionId(auto) SessionName 137 XULWQ
Question table:
SessionId QuestionId OptionId 137 1 5 137 2 2
Option_Table table:
OptionId OptionType 1 AC 2 AD 3 AE 4 AF 5 AG 6 AH 7 AI 8 AJ 9 AK 10 AL 11 AM 12 AN 13 AO 14 AP 15 AQ 16 AR 17 AS 18 AT 19 AU 20 AV 21 AW 22 AX 23 AY 24 AZ 25 True or False 26 Yes or No
Answer table:
AnswerId(auto) SessionId QuestionId Answer 200 137 1 B 201 137 1 D 202 137 2 F 203 137 2 A 204 137 2 C
I want to create a page where I want it to display incorrect answers to a question.
I am going to do this by extracting the type of each question, displaying all the response letters belonging to the type of options, and then deleting the correct answers from the responses to the letters, so that they are left only with incorrect answers.
array:
$option = array(); $option[1]= array(A,B,C); $option[2]= array(A,B,C,D); $option[3]= array(A,B,C,D,E); ... $option[23]= array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y); $option[24]= array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z); $option[25]= array(True,False); $option[26]= array(Yes,No);
My question is that I need help after this section. How to start getting the wrong answers after this array using mysqli / php and the database that I currently have?
UPDATE:
Below is an sql that displays the correct answers for each question:
SELECT q.QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT(DISTINCT Answer ORDER BY Answer SEPARATOR '') AS Answer, r.ReplyType, q.QuestionMarks FROM Question q LEFT JOIN Answer an ON q.QuestionId = an.QuestionId LEFT JOIN Reply r ON q.ReplyId = r.ReplyId LEFT JOIN Option_Table o ON q.OptionId = o.OptionId group by q.QuestionContent
See SQL Fiddle with Demo
This returns the result:
| QUESTIONCONTENT | OPTIONTYPE | NOOFANSWERS | ANSWER | REPLYTYPE | QUESTIONMARKS | ---------------------------------------------------------------------------------------- | Name these 2 flowers | AF | 2 | C | Multiple | 5 | | What is 2+2? | AD | 1 | ABD | Single | 5 |