i'm making a multiple choice quiz. for each question at URL=sitename/question/N there are 2 versions of the page...
- the page you initially see (question + list of radio button answers + submit button)
- essentially the refreshed version of this page, which appears once you click on the submit button. this shows whether you've got the answer right, etc
NOTE: both versions of the page need to have NEXT/PREVIOUS links on case you wanna skip the question, visit the previous one, etc
i think i'm going about it the right way. ie: implementing hook_menu() for url=question/% (wildcard) & then creating a page callback function that deals with the 2 views (in multi-step form fashion), calling drupal_get_form() at least once. & i think i can manage this bit
the PROBLEM (background)
the questions themselves are randomized (there are lots of them in the database but i want them to be asked in a random fashion). so, i create an array of question numbers, which for questions 1-5 might = [3, 4, 0, 2, 1]. & i'll create this array on a landing page before i direct the user to the first question
the problem is that the page callback function that builds each question page needs this 'randomized array' information for at least 2 reasons
- to pull the right question & answer data in from the database (for the page you're on)
- to build the NEXT and PREVIOUS links on the page (ie: it needs to know which questions are coming before & after it to do this)
the PROBLEM
i don't know how drupal can store this kind of array (the randomized question numbers array) so its always accessible by the page callback function. i mean, it seems to me that drupal needs
- access to this array all the time - kinda like when a session variable is used
- some way for each page to know which question its on at any time (ie: which member of the array this corresponds to). such as by using a hidden form field on the question page???
so, i'm thinking a session variable + a hidden form field in the page callback function? but if so, how? or am i barking up the wrong tree?
anyway, any help at all appreciated (i'm a lot stuck)
Comments
Some reading
Some reading
http://drupal.org/node/717750
http://www.isaacsukin.com/news/2010/04/04/multi-page-forms-drupal-6
And modules:
http://drupal.org/project/multipage
http://drupal.org/project/ctools (includes a page wizard).
cheers, but...
already read both those posts