user750241
user750241

Reputation: 5

Php quiz-questions in random

I have to develop a online quiz with questions spanning over multiple pages. I have two pool of questions. The pool has to be chosen at random. Once the pool is chosen, the questions have to be displayed in random order to the user. Its a one word answer quiz. I'm planning to use MySQL,apache and PHP to achieve this since I'm new to webapp and they seem easy to learn. Can you please help me with the following things?

  1. How to display one question per page? I can only find examples to display all the questions in single page.
  2. Do i have to score the pool,questions displayed and score as session variable?
  3. From what I have understood, if the browser is closed, session variables are lost. Do I have to store them in a db so that the user can start from where they left? If that is the case, then I will have to one db operation per question.

Upvotes: 0

Views: 1556

Answers (2)

user1654821
user1654821

Reputation: 11

You are going to need to store the questions in an array in the session. A session can be restored, I typical bypass the built in session handler and use my own to store objects in the database.

To display one question per page use jquery to show and hide divs. You can then submit the answer via ajax if necessary or wait until all questions have been answered.

If you need to randomize a set of questions use shuffle

Upvotes: 1

Chris
Chris

Reputation: 4364

  1. MySQL LIMIT 1
  2. Yes
  3. Yes, sessions are lost when closing the browser. There are two things you can do:

    1. Let the user register an account and save his process in the database.
    2. Cookies (but be careful, user can manipulate them).

Upvotes: 0

Related Questions