Hi !
I'm a young developer (23 years old), and i'm working with drupal since 3 months.
In the Quizz4 planning you don't speak about possibilities to have different view for a quizz.
Today we can have quizzes with questions displayed page per page. My question is, quizz 4 will led admin to display questions in a single page ?

Members fund testing for the Drupal project. Drupal Association Learn more


turadg’s picture

Yes, that is something that I'm working on.

Can you tell me more about how you plan to use the feature? That will help inform the design.

andeim’s picture

254.85 KB

In a single page we can have multi-choices, questions, long answer, short....
Having all in a single page will be used for short quiz I suppose (5 multi choice for example) but we will be able to do long quiz (no limit ;) ).
My using will be very simple, just the visitor can read his quiz from beginning to end change answers and validate at end.

You can see an example attached.

robatwork’s picture


I'm also in need of this functionality, so allow me to give my input on desired functionality. Ideally, I would like to be able to drag and drop questions onto different pages and order them within a given page, much like you can drag and drop them currently on the "Manage questions" tab to set the overall order. I would like the ability to place an arbitrary number of questions on each individual page -- say 4 questions on page 1, 3 questions on page 2, and 5 questions on page 3. If the interface allowed for a visual way of arranging and laying this out, that would be most intuitive I believe.

Do you have an estimate on when you'll be committing an initial version of your pagination functionality?

Sivaji’s picture

Issue tags: +gsoc2009-sivaji

This feature is already addressed in my GSoC proposal http://groups.drupal.org/node/21627

turadg’s picture

I just spoke with sivaji on IRC and he explained how what adeim described is already in his master plan for 4.x. So adeim you can look forward to sivaji's implementation in late July.

robatwork's request is pretty different and may merit another ticket. It's not putting all the questions on one page, but paginating them across multiple pages. The editing interface would be part of the current Admin section. That shouldn't be too hard to add in.

The bigger issue is how to render those pages. Currently there is one View on the quizzes which assumes a student is taking the quiz. Sivaji's work is on that view.

My plan right is to create a separate Teacher subsystem of Quiz (or something like that) that let's you view a quiz for purposes other than taking it. E.g. printing. This view would make use of the pagination.

robatwork, in your particular case, why do you want pagination? is it for a student view or a teacher view? would what I describe answer your case?

robatwork’s picture


I would want pagination not just for a back-end admin (teacher) view, but more so for the front-end user (student) taking the quiz. The purpose is to split up large quizzes, say with 50+ questions, to make them more manageable for the quiz taker. For example, if I have a quiz with 50 questions, I'd like to have 5 pages with 10 questions each. Ideally on multi-page quizzes, the page number (1 of 5) and progress indicator (3 questions answered, 47 remaining) would display on each page to give status to the quiz taker.

A good use-case of an existing quiz that I'd like to replicate with the Drupal Quiz module can be found here:


Sivaji’s picture

Issue tags: +ToDo
Renee S’s picture

Is this something already in the Look+Feel (can't find it, but maybe I'm looking in the wrong spot!) or will this be implemented under the "Ajaxifying" tasks?

falcon’s picture

Version: 6.x-4.x-dev » 6.x-5.x-dev
Status: Active » Postponed
shumushin’s picture

Subscribing. This feature is a must!

falcon’s picture

If someone creates a patch, or can come up with some funding I will be happy to include this in Quiz 4.1.

oz_an’s picture

what size of funding ur talking about? I really need that feature and tending to use flash to implement it on my own (rather easily and unwillingly), though I hate people using flash when they meet a difficulty in the standard ways. So I really need that future and I think it was and is a must for a quiz module. Maybe we the people who need it can help to fund it.

falcon’s picture

We need to add some features to the admin section. Primarily we need change the manage questions tab so that you can decide what questions belongs to what pages. I imagine that you can add a page row, and all question rows below a page row belongs to that page. In addition we need to rewrite most of the quiz taking logic to allow for multiple questions in one page. I estimate the size of funding to 13 500 USD

oz_an’s picture

then we need 135 contributors

falcon’s picture

Ok. Is 100 USD per contributor a drupal standard? I guess we'll have to cross our fingers that some organization can pay the bill or contribute the development time needed to do this.

404’s picture


nsuit’s picture

I am in need of this functionality too. Subscribing ++

zeezhao’s picture


nsuit’s picture

Is there any way I could test that new work-flow that was mentioned in a response to this blog: http://www.appnovation.com/quiz-module
"Sivaji's new test-taking workflow that incrementally adds questions to the page".

linuxeasy’s picture

I have made changes in the version 3, by which display of multiple questions became possible on the page, and it also accepts the answers correctly too.
I am just testing for bugs and will post them shortly :)

djdevin’s picture

Great! I am developing heavily in Quiz 4 - would love to see what you did and possibly port it over.

falcon’s picture

I hope someone will contribute the development time needed to include this in Quiz 5.

Ideally we should change the entire quiz taking logic while doing this. Currently all answers to a question is stored in $_POST['tries']. Druapals Form API is not used correctly when taking a quiz IMHO. I think Quiz taking should be done using a regular multi-step form, or are there any reasons not to? Optionally we can keep things the way they are, and change it around for Drupal 7.

linuxeasy’s picture

Version: 6.x-4.x-dev » 6.x-5.x-dev
Status: Needs review » Postponed
179.71 KB

Extremely sorry and apologetic for delay in submitting my code!

I have attached my changes in the module.. and I have tested at my end.

I have made changes to the functions such as quiz_take_quiz() of quiz.module, and quiz.pages.inc

I have tested it on all answer types and it works successfully...

please try it out and let me know if you face any probs...

I have attached the zip file, what simply you can do it.. just replace its files with your existing quiz module files (sorry as for now.. i couldn't get time to follow and override or patch techniques of drupal, may be later). However, changes are made only to quiz.module and quiz.pages.inc files, all other files are unchanged!

these changes are made to quiz 3 module.

After replacing it with existing module files... all the questions in a particular quiz will come all at once!

please let me know further recommendations and your valuable feedbacks...

credits to core quiz module developers for making this module in a way that I didn't got too tedious work to implement this feature!

djdevin’s picture

Title: All questions in a single page » All questions in a single page [works successfully]

@linuxeasy, great job, I took your code, tweaked it and applied it to Quiz 4 and was able to get all questions on a single page and have the result stored correctly. Feedback at the end of the quiz also shows. There are some visual issues that need to be addressed and currently no validation on the submission. An option to enable per quiz to show all questions on a single page would be nice. I am going to work on it a little bit more and release a patch if it seems stable enough.

linuxeasy’s picture

@djdevin, Hey thanks Man, please keep me updated regarding the same too:)

What we can do is trying using a if-condition, providing users an option whether they want multiple questions appear at once or one questions.

djdevin’s picture

Version: 6.x-5.x-dev » 6.x-4.x-dev
Status: Postponed » Needs review
10.56 KB

Attached is a patch to Quiz 4 dev branch which enables all questions to be displayed on a single page, configurable per quiz. Results are stored correctly and feedback at end of quiz is shown. Please run update.php after patching (or fresh install), this will add the single_page field to quiz_node_properties.

Also make sure that if you change the settings on a quiz node and aren't seeing the change, logout/login should be enough to clear out the old quiz revision.

To do, for starters?

  • Need to prefill form values on validation fail
  • Test with time limit quizzes and other options
  • Visual fixes (shows "2 of X" questions on the results page)
  • Research possibility of multiple pages

Credit to @linuxeasy for Quiz 3 version

This patch is sponsored by DLC Solutions, LLC. (http://www.dlc-solutions.com)

linuxeasy’s picture

Version: 6.x-5.x-dev » 6.x-4.x-dev
Status: Postponed » Needs review

Great work @djdevin,

I have some opinion on the following:

Regarding -->Visual fixes (shows "2 of X" questions on the results page)

If you see my customization on quiz 3 module, this does not show up.

This could be fixed/hidden by commenting out code showing the above pagination like information.

Isn't it?

I might be incorrect, as I am new to drupal coding, but just having this opinion since it I could hide it in my submitted customization.

linuxeasy ;)

djdevin’s picture

Thanks :) I see, yep that should be taken out if $quiz->single_page is set :) Or maybe change it to say something else, like "X questions" instead of a pager.

Currently testing some other mods, will roll a new patch soon. Also changed the form ID back to quiz-question-answering-form so custom theming/overrides would work.

djdevin’s picture

Here's a better patch.

1) Changed the big form ID to quiz-question-answering-form
2) Used theme_item_list for the list of nodes, and give them classes
3) Updated quiz_progress so we can receive the quiz node - will display "X questions" or "X of X questions"
4) Broke apart the theming functions so we have 1 for normal questions and 1 for the big page of questions

I'd like to see if someone can use form API to generate the questions instead of regexing out the modifications needed to each individual quiz question form.

Appreciating any comments! Patch against dev.

linuxeasy’s picture

I'd like to see if someone can use form API to generate the questions instead of regexing out the modifications needed to each individual quiz question form.

Yup, thats exactly where I got into mess..

  • Before using the regex, I had took help of Jquery module to extract the inner form contents, and deleting the form, but it had made it Javascript dependent, and couldn't run on javascript disabled browsers!
  • Then I made search for php-DOM, to do the same which I did through Jquery, but I couldn't solve it out!
  • Later I took help of regex functions to accomplish the same!

The reason is simple. These forms are generated from the question types modules. Now instead of making modifications in each questions type modules (such as multi choice, true/false, etc), I made the changes at one place!

By this, the other question types can still remain unchanged same as community ones!


ratinakage’s picture

Looking forward to this feature!


cvbuelow’s picture

I used this patch but it seems to have some bugs. When I check the box to show all the questions on one page it does this but when I take the quiz and submit the form it goes to [quiz name]/take and returns 404 Page Not Found. It works fine when the questions are all on separate pages.

Also it seems like there is some sort of caching issue. Once I check the box to show all questions on the same page, then if I make other changes to the quiz like changing the name or adding questions those changes are not reflected when I take the quiz. It still shows the old name. When I go back to settings it shows the new name.

cvbuelow’s picture

Ok, these weren't bugs after all. I just didn't realize what was going on.

If you create a path alias like node/191 => myquizzes/quiz1
you need to manually create one like node/191/take => myquizzes/quiz1/take

The caching issue was that I didn't realize that once you start taking a quiz it will keep you on that revision until you finish it, which makes sense. So if you start taking your quiz, then make a change to it in the settings and refresh you will still be looking at the old revision. Just have to finish the quiz and start again to see the new revision.

cvbuelow’s picture

I did run into another issue though when using "Show all questions on a single page". When you finish the quiz it shows the results to the questions in a different order than the questions were on the single page, which I thought was confusing. The reason is because it is ordering them by the answer_timestamp, which is the same for all questions since they were all submitted at the same time from the single page. To fix this just tell the query to ORDER BY the question weight, in this case rs.weight.

in quiz.module line 3179 (patched version):

function _quiz_get_answers($quiz, $rid) {
  $questions = array();
  $ids = db_query("SELECT question_nid, question_vid, type, rs.max_score
                   FROM {quiz_node_results_answers} ra
                   LEFT JOIN {node} n ON (question_nid = nid)
                   LEFT JOIN {quiz_node_results} r ON (ra.result_id = r.result_id)
                   LEFT OUTER JOIN {quiz_node_relationship} rs ON (question_vid = rs.child_vid) AND rs.parent_vid = r.vid
                   WHERE ra.result_id = %d
                   ORDER BY answer_timestamp, rs.weight", $rid);
djdevin’s picture

Nice find, that makes sense...does this patch work with Quiz 4 un-patched as well?

Even though this patch would fix a specific issue with another patch, I think sorting by actual question order instead of answer timestamp would be a more reliable way to display the results.

ratinakage’s picture

Hi, when is this patch going to become part of the dev branch?


djdevin’s picture

Unfortunately, probably not for a while. This is more of a hack at this point, because it rewrites the output of questions instead of modifying the forms before render. I'm not sure what approach to take but if the maintainers could point us in the right direction I think we have enough support to do it in a "good" way.

falcon’s picture

I haven't had the time to review the patch yet, but if it is a temporary solution it is as djdevin say, we probably won't include it in the quiz core modules.

I think there are three things that are important for this feature:

1. Support for multiple questions on multiple pages.
For instance we might add an "add page" button to the manage questions tab so that we can have something like this:

1. Football questions(page 1)
1.1. Who won the WC?
1.2. Who is the better football player, Bart Simpson or Monty Python?
2. Formula 1 question(page 2)
2.1. Who is the most winning Formula 1 driver?
2.2. Who is the most winning Formula 1 team?

(Maybe we can use quiz directions for this?)

2. Make better use of FAPI
Today we use $_POST directly. It is not a good solution. We should use multistep forms and do the validation and submit process the normal drupal way.

3. API
We will be focusing on making quiz core as extensible as possible in the future. When adding support for multiple questions on multiple pages we need to bear this in mind. (If we make full use of the FAPI we will also make quiz core more extensible.)

(We don't need to make all of this happen at once)

Another question is in what version this patch should be added. Originally I was hoping that we could add this feature to the Drupal 7 version of quiz, I'm not sure if we should make a Quiz 5 version for Drupal 6.

What do you think?

ratinakage’s picture

@faclon - Firstly, thanks for the module! We are using it to administer short quizzes and its working quite nicely!

I don't really think having multiple questions on multiple pages is high on too many people's priority list.

For me, the biggest reason for wanting this feature added is to improve general usability. At the moment, if you have a test with 50 questions and you are on question #50 and want to get back to question #1, you need to click the back button 50 times. And to recheck your work that means clicking and waiting for the page to refresh each time. And then to get back to the end of the test, another 50 clicks. Its quite time consuming even on a fast server.

Having a checkbox that allows you to have your whole test on one page would be a huge help. I would definitely recommend putting it into the Drupal 6 version of the module if its possible...

Another solution to this problem I suggested in this thread: http://drupal.org/node/842450.


djdevin’s picture

@ratinakage I saw your other issue before, it would be nice to have implemented. Have you been able to do any startup work on it? Side note, if you want to link to a thread, just use the #842450: Quiz progress block would be really great syntax, drupal.org will make the issue queue link and color it for you.

As falcon said, we don't have to do everything at once - if we can get Quiz 4 to use more of FAPI and start with implementing single page quizzes, multi-page quizzes would not be far off. Maybe we all can start with looking at what needs to change in quiz core and the question types.

@falcon in regards to the question about what version to implement this in, I am pretty sure people will be running D6 for a while. You said a Quiz 4.1 version could be possible...maybe this would be the back port of some essential Quiz 5 features to D6 (single/multi page quizzes, adaptive/branching questions). I'm really hoping that the changes to use all of FAPI make it into Quiz 4 so we get some better ground work for Quiz 5.

Just thinking out loud. Thoughts appreciated.

ratinakage’s picture


I am having trouble applying this patch. Its the first time I am patching and Drupal module so please bear with me...

I started a clean Drupal site. I patched the module using cygwin and this tutorial (http://community.contractwebdevelopment.com/patching-drupal-modules-in-w...). I then dropped the patched module into the modules folder of my clean Drupal site.

I go to the modules page and try to enable the quiz module and I get the following error:

Fatal error: Cannot redeclare quiz_update_6419() (previously declared in C:\Users\gstern\Desktop\Quiz\Quiz\www\quiz\sites\all\modules\quiz\quiz.install:16) in C:\Users\gstern\Desktop\Quiz\Quiz\www\quiz\sites\all\modules\quiz\quiz.install on line 38

Please let me know if I am doing something wrong...


ratinakage’s picture


Continuing testing this patch, I fixed the error in my post #41, above by changing the quiz_update_6419 method name to quiz_updated_6666.

Now I get a little further. I am able to create a quiz with two questions and see it on a single page by clicking 'Take'. The problem is that once I answer the questions and click 'Finish', it gives me the following error:

warning: Invalid argument supplied for foreach() in C:\Users\gstern\Desktop\Quiz\Quiz\www\quiz\sites\all\modules\quiz\quiz.module on line 1696.

By the way, I am patching the latest Quiz 4.0 rc7.

djdevin’s picture

Try this patch. I had to make some edits for it to work with the latest -dev and rc7. Also make sure you run update.php after you patch. It will add the single_page column to your quiz node properties table.

ashernor’s picture

Even this last patch doesn't work for me ? Can someone publish his patched version of the module ?

djdevin’s picture

Can you provide more information? Are you patching against the dev branch?

ashernor’s picture

I just tried again with the dev branch and the last patch, here is what is my result :

patching file quiz.module
Hunk #6 succeeded at 729 (offset 36 lines).
Hunk #7 succeeded at 905 (offset 36 lines).
Hunk #8 succeeded at 1541 (offset 36 lines).
Hunk #9 succeeded at 1563 (offset 36 lines).
Hunk #10 succeeded at 1572 (offset 36 lines).
Hunk #11 succeeded at 1601 (offset 36 lines).
Hunk #12 succeeded at 1618 (offset 36 lines).
Hunk #13 succeeded at 1637 (offset 36 lines).
Hunk #14 succeeded at 1729 (offset 36 lines).
Hunk #15 succeeded at 1756 (offset 36 lines).
Hunk #16 succeeded at 1824 (offset 36 lines).
Hunk #17 succeeded at 1890 (offset 36 lines).
patching file quiz.pages.inc
Hunk #2 FAILED at 350.
1 out of 3 hunks FAILED -- saving rejects to file quiz.pages.inc.rej
patching file quiz.install
djdevin’s picture

This isn't a big deal, the quiz.pages.inc patch is only to show "20 questions" instead of "1 of 20" questions. I will re-roll a patch for the latest dev. The base functionality should still work fine. Make sure you update.php afterwards.

Still working on a better solution using form API.

sbrousseau’s picture

Hello all,
I am a frequent reader of the drupal forums, but this is my first time posting on drupal.org.

First of all I would like to say a big thanks to djdevin (and linuxeasy for quiz 3 version) for posting this patch, as it provides exactly the functionality I was looking for. Great work!

Secondly, I have run into an issue with quiz scoring while displaying all questions on a single page. I thought maybe if I post it here someone may be able to provide some insight into what might be causing the issue.
Here is what is happening:

-I am using a fresh install of quiz module version 6.x-4.x-dev.
-I have applied the most recent patch submitted by djdevin (quiz4-503228-single-page-quiz.patch) and ran update.php.
-I have created a quiz displaying all questions on a single page.
-The quiz consists of all multichoice questions.
-The quiz is using the "random questions" option and is pulling 10 random questions from a pool of about 60.
-I take the quiz, answer all questions correctly, and click finish.

-Instead of scoring the 10 questions as would be expected, the quiz seems to pull a new set of 10 random questions from the pool of 60 and apply the answers to the new set. Many will be marked as unanswered.
-Every time the results page is refreshed, so is the set of questions.
-If any of these questions were included in the original set of questions they will be marked as correct, otherwise they have no answer and count for 0 points.

I am not sure, but I think the quiz_take_quiz function still believes that the quiz is being loaded for the first time and generates a random list when the finish button is clicked.

Does anyone have any ideas on how to prevent the random list from being generated a second time?

Any input would be greatly appreciated.

sbrousseau’s picture

Adding this code at the very top of the 'quiz_build_question_list' function seems to prevent a new set of questions being randomly generated on page refresh when using the 'random questions' setting:

if ($quiz->single_page && $_SESSION['quiz_'. $quiz->nid]['quiz_questions']) {
$questions = $_SESSION['quiz_'. $quiz->nid]['quiz_questions'];
return $questions;

This at least works while the quiz is in progress... finishing the quiz produces an accurate score, however refreshing on the finish page still loads a random set of questions and affects the score...

extrem94’s picture

Great patch, however I don't know if it's a bug but the summary page does not display for anonymous, it only works if authenticated.

sbrousseau’s picture

I am having this problem too, I think it is related to the random hash code included in the URL for anonymous users to prevent caching. If this code is commented out the summary page shows up:

quiz.module quiz_take_quiz function:

// If anonymous user, refresh url with unique hash to prevent caching.
if (!$user->uid && $q_passed_validation === TRUE) {
drupal_goto('node/'. $quiz->nid .'/take', array('quizkey' => md5(mt_rand() . time())));

Of course I don't think this will fix the problem without creating other problems with caching...

barckhoff’s picture


delykj’s picture


Hany Albeshry’s picture

I have troubles finding the correct version to apply the latest patch in #43 against, please help

barckhoff’s picture

@saintofmadness Use the development version of Quiz (6.x-4.x-dev) and apply the patch to that.

barckhoff’s picture


I just wanted to say that I've installed this patch and the single page view works well except that if you wish to make questions that require answers, it does not enforce this requirement as needed. It displays the message to say that you must answer the question, but this is displayed after calculating the score for the entire quiz, so the answer requirement is ignored.

djdevin’s picture

@barckhoff yes this is a known issue that I have encountered. The temporary solution for us was to do client-side validation. I haven't had a chance to revisit the patch yet (it was for client work) but we have more work coming up that will require some updates to this functionality including utilizing more of form API to submit quizzes. Of course if you're so included to do so, any patch would be appreciated to properly check and report missing values :)

lordpicklepuss’s picture

I'm trying to add a CCK text field to the bottom of each question, and not having any success while using this patch. Is CCK support still available using this patch?

clarjon1’s picture

This patch, even though applied to the rc7, does not work properly, or even apply properly. The following output occurs:

$ patch -p0 -u < quiz4-503228-single-page-quiz.patch 
patching file quiz.module
Hunk #13 FAILED at 1601.
Hunk #14 succeeded at 1670 (offset -2 lines).
Hunk #15 succeeded at 1697 (offset -2 lines).
Hunk #16 succeeded at 1765 (offset -2 lines).
Hunk #17 succeeded at 1831 (offset -2 lines).
1 out of 17 hunks FAILED -- saving rejects to file quiz.module.rej
patching file quiz.pages.inc
Hunk #2 FAILED at 350.
1 out of 3 hunks FAILED -- saving rejects to file quiz.pages.inc.rej                        
patching file quiz.install                          

Contents of quiz.module.rej:

--- quiz.module	(revision 6014)
+++ quiz.module	(working copy)
@@ -1601,14 +1618,35 @@
     $former_question_array = array_shift($_SESSION['quiz_'. $quiz->nid]['quiz_questions']);
     $former_question = node_load($former_question_array['nid'], $former_question_array['vid']);
-    // Call hook_evaluate_question().
-    $types = _quiz_get_question_types();
-    $module = $types[$former_question->type]['module'];
-    $result = module_invoke($module, 'evaluate_question', $former_question, $_SESSION['quiz_'. $quiz->nid]['result_id']);
-    $q_passed_validation = $result->is_valid;
-    if ($q_passed_validation === TRUE) {
-      quiz_store_question_result($quiz, $result, array('set_msg' => TRUE));
+    if (!$quiz->single_page) {
+      // Call hook_evaluate_question().
+      $types = _quiz_get_question_types();
+      $module = $types[$former_question->type]['module'];
+      $result = module_invoke($module, 'evaluate_question', $former_question, $_SESSION['quiz_'. $quiz->nid]['result_id']);
+      $q_passed_validation = $result->is_valid;
+      if ($q_passed_validation === TRUE) {
+        quiz_store_question_result($quiz, $result, array('set_msg' => TRUE));
+      }
+    else {
+      foreach ($questions as $question) {
+        $former_question = node_load($question['nid'], $question['vid']);
+        $_POST['tries'] = $_POST['tries_' . $question['nid']];
+        // Call hook_evaluate_question() for each question.
+        $types = _quiz_get_question_types();
+        $module = $types[$former_question->type]['module'];
+        $result = module_invoke($module, 'evaluate_question', $former_question, $_SESSION['quiz_'. $quiz->nid]['result_id']);
+        $q_passed_validation = $result->is_valid;
+        if (false && $q_passed_validation != 1) {
+          /** Very basic validation. TODO: save form values. */
+          drupal_set_message('Please check your submission for errors.','error');
+          quiz_delete_results(array($_SESSION['quiz_'. $quiz->nid]['result_id']));
+          drupal_goto("node/{$quiz->nid}/take");
+        }
+        quiz_store_question_result($quiz, $result, array('set_msg' => TRUE));
+      }
+      $quiz_end = TRUE;
+    }
     // Stash feedback in the session, since the $_POST gets cleared.
     if ($quiz->feedback_time == QUIZ_FEEDBACK_QUESTION && $_POST['op'] != t('Back') && $q_passed_validation === TRUE) {

Contents of quiz.pages.inc.rej:

--- quiz.pages.inc	(revision 6014)
+++ quiz.pages.inc	(working copy)
@@ -350,7 +350,12 @@
   $output  = '';
   $output .= '<div id="quiz_progress">';
-  $output .= t('Question <span id="quiz-question-number">%x</span> of <span id="quiz-num-questions">%y</span>', array('%x' => $current_question, '%y' => $num_of_question));
+  if ($quiz->single_page) {
+    $output .= format_plural($num_of_question, '<span id="quiz-question-number">1</span> question', '<span id="quiz-question-number">@count</span> questions');
+  }
+  else {
+    $output .= t('Question <span id="quiz-question-number">%x</span> of <span id="quiz-num-questions">%y</span>', array('%x' => $current_question, '%y' => $num_of_question));
+  }
   $output .= '</div><br />'."\n";
   // Add div to be used by jQuery countdown
   $output .= '<div class="countdown"></div>';

The results of this is that for some reason, after the one page has been enabled for a quiz, you cannot revert to single questions per page mode, and the quiz does not seem to save to the database correctly -- i'll do some playing with the code to try and manually patch this, but a more up to date patch for the latest version of the quiz would be a lot better to see.

clarjon1’s picture

I did some playing around, and a clue to the .module error seems to be in the patch file itself -- there is a missing + at the beginning of the line.

+        quiz_store_question_result($quiz, $result, array('set_msg' => TRUE));
+      }
+    else {
+      foreach ($questions as $question) {
+        $former_question = node_load($question['nid'], $question['vid']);

So the patch system was trying to find a non-existant "}" character to put the code around, when that "}" should have been marked with a "+" at the start of the line -- Hope this helps.

sreynen’s picture

Title: All questions in a single page [works successfully] » All questions in a single page
Status: Needs review » Needs work

Just updating issue status and removing old status from title.

joetoday’s picture

Yo djdevin, muchas gracias, patch works awesome! FYI for everyone else, I applied the patch in #43 manually to rc7 (a little tedious, but whatever) and it worked great. Did have an issue trying to patch with cli though. One thing is that when i try to set one page quiz as the default it doesn't work. But I can go to each individual quiz and set them to be one page.

djdevin’s picture

Hmm good point. Currently I'm working on a new non-hack way of doing single page quizzes that paves the way for multi-page quizzes, but it involves modifying all the question types and the question type class to utilize form API entirely for processing/rendering/validating. Once I get it stable I'll post for review.

falcon’s picture

Re #63: Interesting!

djdevin’s picture

I've been trying to refactor based on the hints inside the code and @todos. Things like:

- Eliminating the usage of $_POST['tries'] and $_POST in general
- Have quiz question types return single form elements so they can be joined properly to make multi-question pages
- Using $_SESSION['quiz_questions'] and a $_SESSION['current_quiz_question'] index instead of two separate arrays for questions, to allow for more flexible quiz question navigation
- Try and move things out of quiz_take_quiz that should be in FAPI
- For multichoice et al, instead of choice_answers, using FAPI #options
- Merging single/multi page functions in the last patch so that one function renders an arbitrary # of questions

I managed to get quiz taking and grading working OK with the new way (single and question per page quizzes), but I'm sure it's still a little fragile. Feedback doesn't work yet - it's a little difficult since it's in quiz_take_quiz and now everything is happening in FAPI.

turadg’s picture

@djdevin, awesome work. quiz_take_quiz has been the bane of all Quiz module devs. Falcon made an issue for rewriting it with FAPI, #634110: Rewrite quiz_take_quiz() with FAPI, but I'm surprised he didn't title it "quiz_take_quiz must die die die".

Because this issue requires such bigs change that can introduce a lot of bugs, would it make sense to rewrite quiz_take_quiz for FAPI and get that stable first? That code could get into CVS sooner than later. Then this issue could progress with patches on a more stable target.

Falcon, do you think a quiz_take_quiz rewrite could happen in Quiz 4.x?

djdevin’s picture

I posted an alpha patch over on #634110: Rewrite quiz_take_quiz() with FAPI - hope that's alright, I think all FAPI-related discussion/development should be there as this issue title doesn't really apply to this patch.

adrianmak’s picture


I'm just evaluate an e-learning project for a primary school.

One of the client requirement is to show all questions on a single page instead of one question per page as implemented currently.

Anybody could tell me is this feature implemented yet in dev or rc version ?

tchurch’s picture


djdevin’s picture

@adrianmak, this feature is not in any version as of yet. Currently you will have to use the patches provided if you need it

palmereldritch’s picture

Sorry if this has been asked and answered, but can anyone tell me when/if the ability to present multiple questions per page will be added to Quiz? I understand I can use the patches, above, to present ALL questions on one page, but I only want to present 4 questions at a time, with a total of 40 questions, and I only want to allow the quiz-taker to move to the next set of 4 questions once all 4 of the current questions have been answered correctly. I realize this is probably unlike 99% of the other quizzes out there, so would this scenario be supported once multiple questions per page is added?

Also, the links to the documentation and FAQs for Quiz are currently returing 'Access Forbidden' errors.


djdevin’s picture


That is all that is available now, and it's really a bandaid fix. If you take a look at #634110: Rewrite quiz_take_quiz() with FAPI the functionality is planned to have an arbitrary number of pages.

zeezhao’s picture

@djdevin - please do you have a version of the patch that works with quiz-6.x-4.0? I could not get current patch correctly. Thanks

diseño web palma de Mallorca’s picture

Hi, I got this patch manually typed in files .module .install .inc ... yes my eyes hurt a bit...

Anyway, I did the PHP update, and the table seem to be created on DB, and yes !! all questions where listed in on a single page !! but when I took the quiz and hited the button "Correct the Quiz" did not work !!

When I press the "submit" button at the end of the Quiz, instead of getting the results of the quiz I get the a reload page going to same quiz and all the values I give to each question are all reset, so it's like a reset form button.

Did anyone get the same??


diseño web palma de Mallorca’s picture

Seems like Quiz is not been evaluated... Cauze I can see in my account Results estadistics that test has been taken but shows like "in progress" and score is "not evaluated"

Any idea?¿ OO

Lanbaba’s picture

Great job guys.
Pls can somebody post a patched version of the module here. Having issues with getting the particular version for the patch.

djdevin’s picture

Please try this patch if you need single page support in Quiz4 - this is just a temporary (bad) solution - the good solution is #634110: Rewrite quiz_take_quiz() with FAPI

Patched against 4.x-dev (mar 26), patch with patch -p1

kmccullagh’s picture

hi djdevin,

I just installed that patch (quiz4-503228-single-page-quiz.patch). It gives me the option to show all questions on a single page but when I select the box and save it doesn't store the setting and reverts to blank.

Using drupal 6.16 and quiz 1.4. Any ideas?

djdevin’s picture

@kmccullagh run updatedb or update.php first

kmccullagh’s picture

I tried that and it said update complete however it still doesn't work. The error below is being logged

"Unknown column 'single_page' in 'field list' query: SELECT aid, number_of_random_questions, max_score_for_random, pass_rate, summary_pass, summary_default, randomization, backwards_navigation, repeat_until_correct, feedback_time, display_feedback, quiz_open, quiz_close, takes, show_attempt_stats, keep_results, time_limit, quiz_always, tid, has_userpoints, allow_skipping, allow_resume, allow_jumping, single_page FROM quiz_node_properties WHERE vid = 234 AND nid = 220 in /opt/lampp/htdocs/sandbox/sites/all/modules/contrib/quiz/quiz.module on line 830."

any further suggestions?

oh and we don't use drush.


djdevin’s picture

That field is supposed to get added with the update, not sure why it didn't...you can just do it manually with devel/php

$result = array();
db_add_field($result, 'quiz_node_properties', 'single_page', array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0));

Warning, modifies your DB schema, and this is a very beta solution.

sbrousseau’s picture

Category: feature » bug

Just noticed an issue when using this patch:

-I have a site using quiz version 6.x-4.x-dev and the "quiz reports" module to track user statistics, and everything works as expected.

-I apply this patch (from comment #43) and set the quiz to display all question in a single page.

-Now every time I refresh the "/take" page for the quiz, an additional take is added on the reports page.

-The additional take that is added will always appear as "in progress" and will never finish.

-Finishing the quiz also adds another take (because it refreshes the "/take" page I assume)

Does anyone have an idea as to why this might be occurring because of this patch?

Anyone else having this issue?

Any insight would be greatly appreciated!

falcon’s picture

Category: bug » feature

Thanks for reporting. This isn't a quiz bug, it is a problem with the patch.

AndyThornton’s picture


Take care with the patch from #43 regarding the comment mentioned by Sean above (#82). As he mentioned, each time the quiz is played it leaves an 'in progress' version of the quiz. We had 8200 in-progress quizzes. I made a change that created a new revision and next thing I know our website was down! Basically, in the quiz_take_quiz function it calls a function to tidy old in progress quizzes. It attempted to delete all 8200 old in progress quizzes at once. I am not 100% sure why it couldnt, but I suspect that the DB just got snarled up with locks (especially if someone else tries to play the quiz while this is going on, as they will probably end up trying to delete the same rows etc).

If you find this patch is crucial to your world and you too have a bunch of in-progress quizzes you may wish to be careful when you create a new revision. The way I managed to get around it was by modifying the aforementioned function (_quiz_delete_old_in_progress). I added a "LIMIT 0 , 50" on the select so that it only tries to do 50 per time. This has allowed our site to come back to life, and also allows the quiz to be played again.

djdevin’s picture

Yep that is a known bug with this patch. I haven't touched this one in a while to work on #634110: Rewrite quiz_take_quiz() with FAPI but if you find a solution to have the result not create itself without a submission, that'd be great to at least get this thing more stable for production use.

swarad07’s picture

Version: 6.x-4.x-dev » 6.x-4.1
Component: User interface » Code - other

Hey djdevin,

Is there are patch for quiz 6.x-4.1 version ? I want to display all the questions in one page on the /take page. I am searching for something that can take me close to showing all the questions on one page instead of me starting from scratch. I followed the #634110: Rewrite quiz_take_quiz() with FAPI post too. But couldn't find a solution.


nirvanajyothi’s picture


vishalkhialani’s picture

Version: 6.x-4.1 » 7.x-4.x-dev

Can this be done for quiz 7.x-4.x-dev . As the above patch seems for drupal 6.


scottrigby’s picture

Status: Needs work » Closed (duplicate)

This functionality is resolved in a much better way here #634110: Rewrite quiz_take_quiz() with FAPI. Let's work toward a 7.x-4.x reroll of the patch in that issue.

kurti’s picture

Any news??

I´ve just applied the #43 patch and when I read the #82 post ...argggg always take page.

I need a solution...like all followers :)

If anyone wants to help me contact me to bring me a 6.x - 4.x module with single page works.

Many thanks!!

Paras Kuhad’s picture

Thanks everyone for this great project, I tried patch in #43, but it didn't work for me on 6.x - 4.x version. So I applied the patch manually on 6.x-4.4, I also maintained these two fields : allow_resume, allow_jumping in various queries which were probably introduced after this patch on this issue queue. Here I am attaching a tarball of patched module, I am also providing a patch with respect to 6.x-4.x branch, I hope it would help someone.

kurti’s picture

Many thanks Paras, I have to test it.

Could you upload the module in zip package?

This gz package is empty...

Paras Kuhad’s picture

Hi Kurti,

The uploaded gz package isn't empty, you will have to extract it twice to get the folder.

ansim234’s picture

ansim234’s picture

Hello Paras Kuhad,

Could you upload the module in zip package?

This gz package is empty...

I am not able to get the folder please can you upload again?

djdevin’s picture

450.82 KB

Rezipping for the people who can't open .tgz (Windows?)

ansim234’s picture

Hello djdevin,

This will work for display the all quiz question in one page?

djdevin’s picture

Yes. It will "work" but it's really a hack.

Greg Turner’s picture

Does anyone know the status for a 7.x patch?

doxigo’s picture

Version: 7.x-4.x-dev » 6.x-4.x-dev
Priority: Normal » Major
Status: Closed (duplicate) » Active

I still cant figure out why we cant have allow resume function for single page quizzes, does anyone know how to fix this? or have any suggestions ?

digitopo’s picture

Version: 6.x-4.x-dev » 7.x-4.x-dev

Yes I'm also looking for this option in 7x, bump?

nstillblue’s picture

How can I display all questions on one page in the quiz module for Drupal 7?
I am new to Drupal and I'm happy with the Quiz-module, but this is a major issue for my project.

karan.garg.nsi’s picture

Version: 7.x-4.x-dev » 6.x-4.4

It was a great experience using this quiz plugin. But I have a requirement in my project, that at present is not available in this module and that is the feature of having all the questions of a quiz being listed on a single page, rather requesting for next question after answering one.

jeanfranco’s picture

For everyone who needs the single page support for quiz on Drupal 7, I used the patch on #93 to make a version of it in 7.x-4.0-beta1.
I warn you though this is a rough adaptation of the patch to drupal 7.
I don't know how to make a .patch, so i'm uploading the zip, but I just made changes to quiz.install, quiz.module and quiz.pages.inc.

Renee S’s picture

Version: 6.x-4.4 » 7.x-4.x-dev

Folks, don't change version numbers back and forth -- module development best practice is that changes get made to the current version and then backported.

klaasvw’s picture

Status: Active » Needs review
16.64 KB

Here's a patch against 7.x-4.x-dev containing the changes from #104.

I've also added an upgrade hook that adds the single_page column.

j_ten_man’s picture

#106 works for me. Thanks.

Sivaji’s picture

Version: 7.x-4.x-dev » 7.x-5.x-dev

Moving this to 7.x-5.x.

To commit this patch we need to refactor quiz. Includes (Proper use of form API, refraining from Session and node hooks, etc.), otherwise it would be just an incremental hack.

Madzgo’s picture

I have a problem with patch at #106,
it doesn't save form data, instead it takes me to a 404 page (when someone clicks Finish)

Has anyone had this problem?

mcpuddin’s picture

@sivaji, I just read your most recent comment, and you say that quiz needs to be completely refactored? Is that why this issue exists #2012180: Errors when trying to get 7.x-5.x installed?

Would love to help out where I can with that, but don't even know where to get started.

djdevin’s picture

Check out #634110: Rewrite quiz_take_quiz() with FAPI - this is the big one to get all the question types to use more of the FAPI.

Madzgo’s picture

#109 update:
The problem now only occurs with anonymous users.
I fixed the redirection by removing the url() function in theme_quiz_multi_question_node (quiz.pages.inc). (problem was pathauto)

mcpuddin’s picture

Version: 7.x-5.x-dev » 7.x-4.x-dev

If we have a patch being reviewed for 7.x-4.x-dev in comment #106, why are we pushing this off another X amount of months/years when its almost ready to go? I understand this can be seen as an "incremental hack", but its can fix the problem right now. Shouldn't we instead create another issue for 7.x-5.x-dev and let this one for 4.x-dev move forward?

I'm setting this back to 7.x-4.x-dev so we can at last get that patch reviewed and cleaned up.

mcpuddin’s picture

I took a look at patch #106 and it did not handle
1) quizzes with no questions
2) validation of results

I went ahead and fixed those with this patch agains 7.x-4.x-dev ( don't test against alpha or beta )

After going through the code and sifting through quiz.module, I totally understand what sivaji was talking about. The whole module is a hack ( apologies to the people that wrote it ). However, what we have is what we have and I'm really interested in getting this in 7.x-4.x-dev. If someone is willing to volley the testing around with me, I'd be happy to fix anything you find in a very quick fashion. Just one note, if you notice an error, just please describe how to reproduce the error.

mcpuddin’s picture

Assigned: andeim » mcpuddin
mcpuddin’s picture

Looked into the bug mentioned #112 for anonymous users and fixed it. Thanks Madzgo!

mcpuddin’s picture

So I did some more testing and I realized that the above patch didn't support:

  • Repeat until correct support( which actually is broken in general on #1952828: 'Repeat until correct option' no longer works, this patch includes that one)
  • Preserving the responses
  • Displaying feedback at the end of the question ( or submitting in this case )
  • Using "Continue" until "Next question" ( because there is no next question )

Now let's get some testing!

mcpuddin’s picture

I just made an update so that feedback respects that "pass_rate" variable when completing the quiz.

j_ten_man’s picture

#118 doesn't seem to be working for randomized questions. I have 8 questions and have it set to display 4 random questions. When I submit, different questions come up.

pubo68’s picture

Hi, I'm totally new on Drupal.
Can anyone help me to install this function on my site? I already have installed and working Quiz. Only need the capability of show more than one question per page inside of an article/basic page.

Thank you very much!

bharata’s picture

What would it take to make the patch from post #118 above work for 7.x-4.0-beta1?

Also, isn't there some way that Views could be used to render many questions on one page?


seanenroute’s picture

Results page does not honor Question order. It appears to show the results page in the order the questions were created.

1) Create Quiz, select Taking Options > Select: Show all questions on a single page
2) Create Questions in Quiz: Q1, Q2, Q3, etc
3) Reorder the Quiz Questions to: Q3, Q2, Q1
4) Results page show answers in original order: Q1, Q2, Q3 instead of Q3, Q2, Q1

When I turn off "Show all questions on single page" the Results page shows the correct order of questions.

If I turn the single page feature back on it once again show the incorrect Result page (Q1, Q2, Q3 instead of reordered Q3, Q2, Q1), I was hopeing it would reset but sadly it did not.

I'm guessing that the patch causes the Result page to order the questions based upon the ID of the Question, but just a guess.

Patch #118 with Quiz set to 1 page.

seanenroute’s picture

It gets stuck at Result ID 0 if you start a quiz but don't complete it.

When a user clicks Take a Quiz but doesn't complete the quiz it gets stuck on an infinate loop where you can never get past Result ID #0. Even if you retake the quiz and fill in all the answers it still considers you stuck at Result ID #0.

Even odder, if you take another Quiz when you finish it, you are teleported straight back to the stuck Quiz and get the message that you have to complete all the questions.

Patch #118 with Quiz set to 1 page.

omvaishnav’s picture

Hello All,

Is now any new bug free patch for quiz-7.x-4.0-beta1 version?

I am waiting to a new patch for showing all questions in single page. If anyone has a new solution please reply.


JanderSun’s picture

Hello All,

I too was seeking some guidance in making this work with the quiz-7.x-4.0-beta1 module?

Additional I am seeking guidance in adding a selection to Quiz creation to set the number of questions per page.

Thanks in advance.

drewbe121212’s picture


I have a pretty heavily forked version of Quiz at this moment and I would like to return to the scheduled release cycle of the core module, but this cannot happen until this functionality is present.

Is this meant to just fall off until the rewrite for 8 now?

abhi91garg’s picture

Version: 7.x-4.x-dev » 6.x-4.x-dev
Issue summary: View changes

i used #96.

it was great
but i want 10 question per page in my project.
anybody have idea about this issue.

abhi91garg’s picture


I used #96.

it was great
but i want 10 question per page in my project.
(want pagination in the all questions)
anybody have idea about this issue.

rajatparida’s picture

I am using drupal 7 and quiz 7.4 version , I am also checked with #96 and #106, both are working fine for displaying all question on single page, but unfortunately the form submit not working, when I click on the Finish button, it just reload the page

If any one have any idea regarding this, kindly let me know,


Thytane’s picture

#116 works for me. No fails during the patch instead of the others.

djdevin’s picture

Version: 6.x-4.x-dev » 7.x-4.x-dev
18.31 KB

Rerolled for 7.x-4-x and also fixed an issue where the question title (node body) was not appearing because of changes to rendering. Extra fields on the questions (if any) should display as well.

rajatparida’s picture

Thanks djdevin #131 working fine for me

Sivaji’s picture

Status: Needs review » Closed (won't fix)
Issue tags: -gsoc2009-sivaji, -ToDo

I didn't read the issue fully. However patch in #131 would be an incremental hack to quiz module, especially the snips highlighted below.

@@ -2030,7 +2056,7 @@ function quiz_take_quiz($quiz) {
   if (!isset($_POST['op'])) {
     // @todo Starting new quiz... Do we need to show instructions here?
-  elseif (isset($_POST['question_nid']) &&  ($_POST['question_nid'] != $_SESSION['quiz_' . $quiz->nid]['quiz_questions'][0]['nid'])) {
+  elseif (!$quiz->single_page && (isset($_POST['question_nid']) && $_POST['question_nid'] != $_SESSION['quiz_' . $quiz->nid]['quiz_questions'][0]['nid'])) {
     // The user has pressed the navigation buttons multiple times...
   elseif (isset($_SESSION['quiz_' . $quiz->nid]['question_duration']) && $_SESSION['quiz_' . $quiz->nid]['question_duration'] < -2) {
+      foreach ($question_nodes as $question_node) {
+        $former_question = node_load($question_node->nid, $question_node->vid);
+        $_POST['tries'] = isset($_POST['tries_' . $question_node->nid]) ? $_POST['tries_' . $question_node->nid] : NULL;
+        // Call hook_evaluate_question() for each question.
+        $types = _quiz_get_question_types();
+  foreach ($nodes as $node) {
+    $qno++;
+    if (isset($node)) {
+      preg_match('|<form[^>]*


|si', $node->content['question_form']['#markup'], $matches);
+ $form_free_body = preg_replace('/]*?>/', '', $matches[1]);
+ $node->content['question_form']['#markup'] = str_replace('name="tries', 'name="tries_' . $node->nid . '', $form_free_body);
+ $item_list[] = drupal_render($node->content);
+ }
+ else {
+ break;
+ }
+ }

Ideal way to fix this would be rewriting quiz module or at least function quiz_take_quiz(). I hope to see this happen at least in 8.x.

djdevin’s picture

For sure this is a hack, but I would say getting paginated questions, or at least all questions without pagination should be a focus in 7.x....it will be years before big education sites upgrade to 8.x! Unfortunately we have no other alternative than hacking this functionality to meet our clients' requirements. Judging by the constant activity on this issue it seems like it is requested functionality for a lot of users that shouldn't be put off.

I posted a proof of concept along with other contributors in #634110: Rewrite quiz_take_quiz() with FAPI to rewrite that function and I think it should be revisited before even thinking about 8.x.

kc99’s picture

After trying #131 and #116, get:

Notice: Undefined property: stdClass::$single_page in quiz_take_quiz() (line 2026 of /srv/bindings/03871c1026de4a709ca559d10ff04c25/code/sites/all/modules/quiz/quiz.module).

In Taking Options, Show all questions on a single page checkbox does not stayed checked. Yes, ran update.php.

scottrigby’s picture

Alcaparra’s picture

Component: Code - other » Code - Quiz core

is this feature in the new versions?

djdevin’s picture

it's in the 5.x version

maxichka’s picture

This functionality doesnt seem to be available in 5.x version.

Which Dev version do I download?

djdevin’s picture

The functionality is in any 5.x version, enable the "Quiz page" module.

Alcaparra’s picture

Please, please, please, I need this feature in version 7.x

djdevin’s picture

Please stop asking for this, it is already in the 7.x-5.x version.

seanenroute’s picture

@alcaparra and anyone else interested I've got a test site up running Quiz 7.5x with the ability to create single page quizzes. Feel free to play around.


Alcaparra’s picture

I activated "Quiz page" module, but I don't know what to do after, any guide?

blakefrederick’s picture

I also enabled the Quiz page module, but it appears to only have 2 fields - Title and Question. The Question field is merely a text area with summary. It's not at all clear to me how the Quiz page content type can be utilized to create multiple Quiz questions on a single page. Care to enlighten us djdevin?

ezraw’s picture

I wrote some basic instructions with screenshots that might be of use: https://www.drupal.org/node/2333943#comment-9126321

blakefrederick’s picture

Thanks ezraw! Those instructions are clear and worked perfectly for me.

cornelism’s picture

so tell me, where is that quiz page module, because I cannot seem to find it.

djdevin’s picture

kandrupaler’s picture


I'm new to Drupal. I installed quiz 7.x-4.0-rc1. It's working fine except for the issue in this thread: all questions on one page.

Is there a way to get all questions on the same page with 7.x-4.0-rc1? If yes, what is that way?

Also, I see that it's going to happen in 7.x-5.x. Any idea when this version will be released?

djdevin’s picture


5.x is pretty stable. It's in alpha because the API is changing a bit.

There is no good way to get page functionality in the 4.x version.

If you are just starting out you can safely start with 7.x-5.x-alpha10.

kandrupaler’s picture

Thanks @djdevin. Installed 7.x-5.x-alpha10 and it's working fine!

nareshbw’s picture

#116 is working fine for me

kandrupaler’s picture


7.x-5.x-alpha10 doesn't seem to have H5P support. Is there a way to enable it without losing the same page functionality?

akalata’s picture

@kiranbr for 5.x, use https://www.drupal.org/project/quiz_h5p for H5P content.

kandrupaler’s picture

@akalata thanks a ton!!!!