Jump to content

Php Quiz Application


sureshHARDIYA

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by PFMaBiSmAd
Link to comment
Share on other sites

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.