sureshHARDIYA Posted December 20, 2012 Share Posted December 20, 2012 I have been trying to write quiz application. I have set a database tbl_question(questionId, question, correctAnswer, category) and tbl_options(optionId, questionId, option1, option2, option3, option4). When user logins into the system, a random question should be provided to the user from the database. the question need notto be repeated and once the question is loaded, the user can either quite, or answer. if answer then can go to next question else not. if the user refresh the page the question should be same loaded. Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/ Share on other sites More sharing options...
JonnoTheDev Posted December 20, 2012 Share Posted December 20, 2012 Sounds good, whats the problem? Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/#findComment-1400579 Share on other sites More sharing options...
sureshHARDIYA Posted December 21, 2012 Author Share Posted December 21, 2012 The problem is. I did not get idea how to give random questions to the user. when i used random number concept, then the question is changed when user refresh the page. this should not happen. once the user log into the system, he will be aksed to start the quiz and once he start he should be give an question. the question should persist till he answers or exits. and when he answer the question next button activates and can click on next button to go to next question. I did not get how to start this and what to do. Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/#findComment-1400711 Share on other sites More sharing options...
PFMaBiSmAd Posted December 21, 2012 Share Posted December 21, 2012 You would use a database table to store the status of the quiz's in progress. When someone starts the quiz, you would retrieve the list of question id's for the quiz, randomize them, and store them, one per row, in the 'active' test table. Each row in that table would contain an auto-increment id (which would determine the order of the questions, since they were randomized before being inserted), the user's id, the question id, the answer the user gave for that question (initially a null value when the rows were inserted, updated when the user enters the answer), and the datetime the question was displayed (so that you can track how long ago the test was worked on so that you can eventually remove abandoned tests.) For any user's id, the highest id in that table that does not have an answer, is the current question the user is working on. Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/#findComment-1400732 Share on other sites More sharing options...
PFMaBiSmAd Posted December 22, 2012 Share Posted December 22, 2012 (edited) Here's an alternative method to retrieving all the id's at the start, randomizing them, and storing them for the user. To get the next random question, you would query the question table and get the questions that are not in the set of already answered questions. Then you would randomize those unanswered questions to get the next question. Edited December 22, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/#findComment-1400847 Share on other sites More sharing options...
sureshHARDIYA Posted December 23, 2012 Author Share Posted December 23, 2012 Thank your for the reply. But I really did not get what you mean. Please can you provide some code snippset so that I can get the overview of what you are telling. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/272216-php-quiz-application/#findComment-1400953 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.