valdes Posted May 3, 2015 Share Posted May 3, 2015 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 3, 2015 Share Posted May 3, 2015 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? Quote Link to comment Share on other sites More sharing options...
valdes Posted May 3, 2015 Author Share Posted May 3, 2015 No,its a marking system. It needs to check for the correct answers, if it checks and there are correct answers, it displays them, also if it checks and it's wrong, it keeps the record also and then later displays the results. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 3, 2015 Share Posted May 3, 2015 Your first challenge is to look at the data you need to store and the processes involved and design a relational database model that supports both. Quote Link to comment Share on other sites More sharing options...
jcbones Posted May 3, 2015 Share Posted May 3, 2015 Remember that relational databases need to be at least 3rd normal form. https://www.youtube.com/watch?v=yYioLVWgh64 Quote Link to comment Share on other sites More sharing options...
valdes Posted May 4, 2015 Author Share Posted May 4, 2015 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 Quote Link to comment Share on other sites More sharing options...
valdes Posted May 4, 2015 Author Share Posted May 4, 2015 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 4, 2015 Share Posted May 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.