i need help knowing where to start, developing a "multiple choice quiz" module for a drupal site i'm building.

i know drupal has already got a quiz module/framework but the site i'm doing has very specific requirements, so i'll be creating my own module. plus, the opportunity to learn module development is largely the attraction (i'm working my through Packt's Learning Drupal 6 Module Development & Apress's Pro Drupal Development in preparation)

mainly, my problem is that i just don't know where to start. i mean, can CCK be used to create 'question' nodes that enable users to submit data just like you do with HTML forms? & where do modules & templates fit into all this?

basically, i could just do with someone suggesting a couple of strategies i could take. i'll probably figure it out myself eventually but it'd be mighty reassuring in the meantime

to enable you to do this i'll sketch out the nature of the application i'll be building (at half a page it may seem a bit lengthy but i'm trying to be as clear as i can about the functionality of the site)

the site centers around a set of multiple choice quizzes. you're presented with 5 questions and simply have to check (using a check box) which one is correct. if you're right it lets you know. if you're wrong it tells you the right answer, complete with a lengthy description

answering a question doesn't automatically take you to the next question - you have to do that yourself. rather, the default behaviour of any question page is simply to provide feedback on whether your answer was right or wrong once you've answered it. this is what each question does when you select your answer and click "Submit"

the site gives you various forms of feedback about how you did....

  • firstly, & on a per question basis, it lets you know - once you've submitted your answer - whether your answer is right or wrong. it does this by reloading the question page, this time complete with a combination of ticks & crosses (depending on whether you got the answer right or wrong). plus, if you got the answer wrong it gives you a lengthy description explaining the right answer, which appears in a <div> element below the original question data
  • secondly, & also on a per question basis, it lets you know - once you've submitted your answer - what answers other people gave for that question. this appears as a block in the right hand column, consisting of bars for answers A to E. one of which is colored differently from the rest (demonstrating that its the correct answer). & all of them having percentage values next to them indicating what percentage of other quiz takers chose that as their answer
  • & finally, the site lets you know how your overall performance compared to other users. this information appears in a dynamically constructed histogram chart on a page of its own

plus, as well as giving you feedback, the site lets you provide feedback yourself. the way this works is that once you've submitted an answer a 'feedback' block appears at the bottom of the question page, consisting of a small contact form & a 5 star "rate the question" type thing. this lets you say that the questions rubbish, that its incorrect, that you liked it, or whatever

[ as you may have noticed the whole 'feedback' thing is very important to this site ]

the questions themselves are categorized, letting you choose what categories of question you want to answer - or simply letting you answer questions on all of the categories at the same time, which is the default

& there are also 2 quiz modes...

  • revision mode - which just gives you one question after another, &
  • timed mode - which gives you a set of questions & a period of time to answer them in

NB: i'll probably add javascript & AJAX to make this part of the app slicker, but the site will have to work on mobiles that don't have javascript, so it'll have to degrade gracefully back to the basic HTML form approach

& finally, users also need to be able to register, because its a "pay money to do the tests" type site

in terms of basic architecture, the site will seem to need the following things...

  1. a homepage
  2. a fairly involved registration page - needed because there are several different quiz's to sign up for, different subscription periods to choose from (3 months, 6 months, a year, etc) & a payment facility to create
  3. some kind of quiz landing page - somewhere that shows you which quiz's you're allowed to take (depending on what you've signed up for), which categories of questions you want to answer in that quiz, etc
  4. some kind of general "question page" - & this is where i'm most confused. i mean, the question pages seem to be a combination of HTML forms & custom (CCK) content, but i say that only because i'm thinking HTML forms functionality + CCK content display. not because i've even got a clue what i'm talking about

anyway, i've tried to explain it as best i can. any advice or suggestions would be very much appreciated

Comments

goldhat’s picture

I suggest you start by installing and using Webform (http://drupal.org/project/webform) module which is a commonly used automatic form builder. Read through the code for that module because it provides an interface in the Drupal Admin that allows you to generate many different form fields. It might even be something you could extend to create your module which could save you producing your own form generator.

CCK is used to create extra (custom) fields for Content Types which are different types of Nodes. Normally all Node add/edit/delete is done in the Drupal Admin by Administrators. So if you want to build a quiz as a Node with custom CCK fields you will then need to take the Node Add form and place it on your own page. Which is usually done with a function called drupal_get_form (http://api.drupal.org/api/function/drupal_get_form/6).

I'm not sure CCK would work given your requirements. More likely your going to need to create your own custom database tables so that your in full control of how the data is stored.

dandaman’s picture

That does sound like a good start. Keep us updated on your progress.

Dan "da Man" Ficker
http://da-Man.com/

prosatya’s picture

Hi david,
Very interested module. Let me know if you required any type of help in development. I know drupal litle bit and want to expertise on this. I can help you on this without cost.

Thanks
Satya

syakely’s picture

I have built a few courses that display questions with flash.
(currently working on replacing all flash items with jquery / ajax.)

The way I have done it is very simple. I create a content type, with cck fields. body is the question, I have one cck answer field, and one cck multi-able distractor field. (multi-able choice will also work as True, False if only one distractor.)

After you have made some questions create a page that will display your questions in a form and follow your logic.

How you track user's performance can be answered many ways. A couple of ideas would be:
1. Add extra fields to the question content type to keep track, and update it each time a user takes a quiz.
2. Create another content type that will crate a "tracking node" each time a user takes the quiz.

At the end of the quiz, display your stored data.

Hope this helps a little.