Jump to content

Give users random subsets of questions from different "chapters"


wee493

Recommended Posts

I'm creating a quiz type application where there are hundreds of quetsions in a database and they are all tagged with chapter and sub chapters in my review material where they've come from. I have a page where users can select which chapters/sub chapters to answer questions from. I need help on the best way to save which questions the user will be doing and incrementing to the next question through them taking the quiz. 

 

With a normal quiz it's easy to increment id + 1 to the next question, but in this case I assume I need to store an array of what questions they're doing in a session? Or should I store it in the database with a pointer to a quiz session id?

 

What would you recommend?

 

Any ideas are appreciated, thank you!

Link to comment
Share on other sites

The problem with an array is that it's rather cumbersome to turn that back into the corresponding rows. And the results are lost forever once the session has been garbage-collected, which means you don't really know what's happening on your site (no usage statistics, no overview, nothing).

 

Storing the questions in the database will give you a lot more flexibility. I'd create one table for the quiz instances and one table for the randomly ordered questions of each quiz (together with their status). The session only needs to contain the quiz ID.

Link to comment
Share on other sites

Feeling magnanimous this morning let me throw in my $.02 and give you a little outline of what the previous responders are suggesting.

 

1 - define all of your questions (as you said) by subject/chapter/subchapter/unique Q#/ etc.

2 - design a table to hole #1 - one record per question with all of its identifying criteria.

 

During this design phase, be sure you have all of the possible attributes you may need for each question down the road. Maybe a date added to keep track of older questions (outdate perhaps?) or other such things.

 

3 - define a table to define your users. A name, an id, contact info and any other attributes you may need for your testees.

You will have a record for each person who takes your quizzes.

 

4 - define a quiz table that will contain a user id from #3, a quiz datetime, the key info from #1 for each question that is part of this quiz and a result field to track the user's score on each question.

Here you will have a record for each question for each quiz for each user. Make sense?

 

When all is done you will be able to pick a user, show how many quizzes he/she has taken, when it was done and what their score was. You can also track what questions have been used the most or have been used for this user.

 

To create a specific quiz you do a query of your questions to select what you want to test on. If this selection needs to be trimmed to eliminate questions already answered in other quizzes, you will have to either add that to your query or loop thru the query results and create that array you were thinking of with the question key info and using some logic to drop the repeat questions. from that array. If you also want to shorten the list by using some random number selector you can do this against that array as step 2 of this process. Once you have modified your list of questions into table #4. Now you can output this as a complete quiz and then update it with the answers/scores when the user finishes.

 

This is an outline, taking into consideration what I kinda gleaned from your initial post.

 

Good luck!

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.