i'm trying to make a basic quiz module & would really appreciate some guidance. quite specific level guidance - as to what functions to use, whether i'm on the right lines, etc. (so please don't hold back on any detail if you feel your reply warrants it).
anyway, i'll explain what i'm trying to do (best as i can) & if you have anything to say pls hit me with it
sooooo, i'm trying to create a module that provides basic multiple choice quiz question functionality (& there's no point telling me to use the existing quiz module - the project gets quite complicated later on & my needs are gonna get v specific so i've gotta create everything from scratch. ie: this is the 'start with the basics' bit)
anyway - functionality wise - i start with a 'start screen'. nothing more complex than 'click submit to begin quiz' & a submit button. & then, when you click on this it takes you to the first question. on this page there's a question, 5 answers (with a radio button each) & a submit button. all dead standard multiple choice stuff. & once you've chosen your answer you click submit & it kinda refreshes the page, adding some explanatory text below that explains the answer in detail
code wise, i'm thinking
> the start screen will direct drupal to a url. sitename/test/question-1 (i can get the module to handle this family of urls with hook_menu & whatnot)
> the FormAPI page callback function - once you land on the question page - pulls in the appropriate question data for the question from a custom database table
PROBLEM 1: i don't know which function(s) to use to grab the question data from the custom database table
PROBLEM 2: i also need to grab the 'right answer' from the database - information that, initially, won't be appearing on the page (but which i'm guessing i'll need somewhere cos on the refresh i have to show them whether they've got the answer right or wrong). so how do i store this information? a hidden field? an array? a session variable?
anyway...
> the module will pull in the question data & (presumably) create a form. with FormAPI. 1 question, 5 answers (each has a radio button & only one can be selected). & a submit button
> on submission, if the answer is wrong it refreshes the page. kinda. i mean the 5 radio buttons are no longer visible & neither is the submit button. & the right answer gets a tick & - if there was a wrong answer - that gets a cross. but otherwise the question & answer data still remain. PLUS, whether the question was answered rightly or wrongly the refresh adds an explanatory block of information beneath the questions (which explains the answer)
PROBLEM 3: if i use the same callback function to handle these 2 versions of the same page, the refreshed version of the page needs some way of knowing its the refreshed version. so how do i do this?
anyway, i know its a complex question, but if anyone can provide a bit of guidance with PROBLEMS 1-3 plus whether i'm actually going about it in the right way, it'd be a big help (cos i'm pretty much fumbling around in the dark at the moment)