Jump to content

Recommended Posts

Ok good morning to you all, I have been working on an online quiz / cbt (computer based testing) program, I have been successfully able to create the admin area where the administrative can upload questions as well as create users who would be writing the exams, but here is my challenge

I have two challenges, writing a php script to load the questions from the database and then display on a page with the multiple choice answer as radio button

 

And when the user clicks the answer he / she chooses, it checks for the correct answer from the database and if it's correct, accepts the answer and moves to the next question.

 

How do I go about this in php,kindly help, I think I am missing something here.

 

it checks for the correct answer from the database and if it's correct, accepts the answer and moves to the next question

If it's not correct, what happens? Do they try again until they get it right, so everyone finally finishes the test with 100% correct?

I have been able to insert into the database, with primary key and auto increment,now I want to call it back up on another page called 'exampage.php' now how do I get to go about it? I'm battling with it, and it really hasn't been fun. Pls help

I need to display the questions from the database and the answers, I echo it out as the answers. So that when the user clicks an answer, it checks with the one already inserted in the database,if it matches, it gives a mark if it doesn't it wouldn't give a mark

You really haven't provided enough information. But, I'll provide a general response.

 

When the user starts a test you need to create a DB record for that test execution. It would only include information such as the user, date, time etc. You would have another table to store the questions and answers that the user responds with. Your tables for the questions and possible answers should already have a value to identify the correct answer - so the results tables do not need to have a value for wrong or right since that can be calculated.

 

Anyway, once the user starts a test you need to associate them with that test. You can do this through the sessions and/or their user ID (if they are required to log in). Once a user answers a question and proceeds to the next one, you will know who they are, what test they are working on and what their results have been so far. Also, once the user initiates the action to start a test I would do the following:

 

Query all the available questions on the test and populate the results table - leaving the answer NULL. The table could have the following fields: ID (PK), question_id, answer_id and sequence. The sequence would be so you can separately track which question the user last answered so you know which one to show them next. If the user is required to answer each question you could select the first one in the sequence order that is unanswered. Otherwise, you could allow a user to skip questions and would need to track which question to show next in session data.

 

So, backing up, upon selecting to take a test you would run two queries: one to populate the test execution table and a second to populate the questions to be asked. Then on each page load, select the next question to show the user from the results table. You would JOIN that table on the answers table to get the available answers. When a user answers a question, store their response in the results table. If you need to show them immediately if their answer was right or wrong, you would also do a SELECT query on that answer to the answers table to see if their response was correct.

 

I know this is just general information and I haven't provided any specifics or code, but it is not a trivial amount of work and I'm not prepared to do it at this time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.