473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Pulling the right answer from MCQS system

semanticnotion
I have a MCQS test application in which i have 3 tables e.g


i) Subject (sub_code, subject)
ii) Question (question_id,question, rate/level, sub_code)
iii) Answer (answer_id, answer, question_id)

I added the subject in subject i added the relevant question and for that question i added relevant answer in answer table.

If the user click on any option how can i know that the selected answer is right or wrong. OR
how can i pull the right answer as out put from my database. Plz Help

Thanks in advance
Oct 5 '10 #1

✓ answered by kovik

In the answers table...

So, the answers would be in the table like this:

Expand|Select|Wrap|Line Numbers
  1. insert into questions (id, subject_id, correct_answer_id, order, question) VALUES
  2. (1, 1, 1, 1, 'what is computer');
  3.  
  4. insert into answers (id, question_id, answer) VALUES
  5. (1, 1, 'A computer is machine')
  6. (2, 1, 'A computer is mobile')
  7. (3, 1, 'A computer is fax')
  8. (4, 1, 'A computer is nothing');
The IDs I've given are arbitrary, and generally shouldn't be set manually.

9 1954
kovik
1,044 Expert 1GB
That depends on what determines the correct answer. In neither your Question table nor your Answer table is there any attribute defining which answer is correct. This should be defined on the question... Is that what the "sub_code" is?
Oct 5 '10 #2
kovik thanks for your response
so where i should define the correct answer whether in question or answer table and in what manner plz help me
Oct 6 '10 #3
kovik
1,044 Expert 1GB
Well, your question implied that this was already defined by this "MCQS" system.. Is this pre-built or did you make it?
Oct 6 '10 #4
No its not pre-build i want to make it
i make these three tables and now i have some problem about the right answer i you have some idea about this plz help me its urgent or if need to know about my code i can upload that.
Oct 7 '10 #5
kovik
1,044 Expert 1GB
Then, you either have to define the correct answer in the question or in the answers. If it is possible to have more than one correct answer, then define it in the answers. If there will always be one correct answer, define it in the question. I would also add an "order" attribute to these items so that they can be reordered without changing their physical IDs.

Expand|Select|Wrap|Line Numbers
  1. # Subjects
  2. create table subjects (
  3.     id int not null auto_increment,
  4.     title varchar(255) not null,
  5. primary key (id));
  6.  
  7. # Questions
  8. create table questions (
  9.     id int not null auto_increment,
  10.     subject_id int not null,
  11.     correct_answer_id int,  # Add this if there's one correct answer
  12.     order int not null default 0,
  13.     question text not null,
  14. primary key (id));
  15.  
  16. # Answers
  17. create table answers (
  18.     id int not null auto_increment,
  19.     question_id int not null,
  20.     answer text not null,
  21.     is_correct boolean default false,  # Add this if there can be multiple answers
  22. primary key (id));
Oct 7 '10 #6
Thanks for this kovik but where should i place the choices like a,b,c,d,e etc
e.g
Q 1 what is computer
a: A computer is machine.
b: A computer is mobile.
c: A computer is fax.
d: A computer is nothing. etc
Oct 11 '10 #7
kovik
1,044 Expert 1GB
In the answers table...

So, the answers would be in the table like this:

Expand|Select|Wrap|Line Numbers
  1. insert into questions (id, subject_id, correct_answer_id, order, question) VALUES
  2. (1, 1, 1, 1, 'what is computer');
  3.  
  4. insert into answers (id, question_id, answer) VALUES
  5. (1, 1, 'A computer is machine')
  6. (2, 1, 'A computer is mobile')
  7. (3, 1, 'A computer is fax')
  8. (4, 1, 'A computer is nothing');
The IDs I've given are arbitrary, and generally shouldn't be set manually.
Oct 11 '10 #8
Thanks alot for your time Kovik
Oct 12 '10 #9
kovik
1,044 Expert 1GB
No problem.
Oct 12 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Kevin A | last post by:
Hi, Is there a way to determine the name and version of the operating system in a portable way? (for Solaris/Linux) Thanks, Kevin
17
by: Carmen Wai | last post by:
Hello: I would like to know whether there is any different in installing Postgresql on the Linux system with file system of EXT2 or EXT3. I have two machines with idential OS (Red Hat 7.3...
1
by: Fred Nelson | last post by:
I'm a newby and I'm writing my first VB.NET print program! I need to change the default left and right margins for my printed output "e" is my "System.Drawing.Printing.PrintPageEventArgs By...
4
by: Agnes | last post by:
I got an window server 2000. How can I get the server system date and systemtime , and put it into a textbox ?? Thanks a lot
1
by: anil kumar.m | last post by:
hi Gurus. i have a requirement like pulling data from disconnected system. y disconnected system means....cleint is not authorising us to connect to his system becoz its in secured zone,so i can't...
0
by: Zelalem | last post by:
Hi... In the near future I am going to start developing an application program with VB.6, that can be used to handle students' examinaton process. Some of the functionalities of the ...
1
by: lazooo | last post by:
I have the two following questions: 1. When you write the code you can do it in two different ways. You can write all the code directly in your gameloop or you can break it down in small functions...
12
by: sdlt85 | last post by:
Hi, I need some help. My program is runing but it is not given me the right answer. The program it suppost to solve a polynomial, using Horners. The user will enter the value for x and the...
15
by: Fro | last post by:
Hi, I have a php-script which writes uploaded files into a directory. My php-script gives a specific names to the saved files. I found in the directory a file which has a name which could not be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.