Thanks for your work on this great module!

I created quiz with 12 questions. I wanted user to get only 4 random questions on each attempt.So, i selected Number of questions: * in quiz set up as 4. When user is attempting to take test all 12 questions are appearing instead of 4. Am i doing wrong ? Please advise...

Comments

hanskuiters’s picture

Need configuration advise too. Or is there a bug? I'll describe some situations.

A.
'always' questions: 0 | 'random' questions: 8. 'number questions to randomize': >0.
I get the message:

The number of random questions for this Quiz have been lowered to 0 to match the number of questions you assigned.

B.
'always' questions: 3 | 'random' questions: 5. 'number questions to randomize': 5.
I get the message:

The number of random questions for this Quiz have been lowered to 3 to match the number of questions you assigned.

And I then DO get 3 questions, but only the 'always' questions. At quiz start the 'quiz progress' says: Question 4 of 6.

C.
'always' questions: 3 | 'random' questions: 5. 'number questions to randomize': 1.
At quiz start the 'quiz progress' says: Question 2 of 4.

C en D tells me that the system counts all the 'always' and 'random' questions, but only shows the 'always' questions.
Further more these situations tell me that the 'number questions to randomize' can't be higher then the number of 'always' questions.

(Does this make any sence?)

mbutcher’s picture

Status: Active » Fixed

A fix for this has been checked into the 6.x-2.0 development branch. It should become available in the nightly builds and in 6.x-2.0 Alpha 1.

hanskuiters’s picture

But I am using 5.x-2.0-rc1. Will there be a fix for that too in the near future? I would try it myself, but since I am not a programmer, I like some help.

mbutcher’s picture

I'm not planning on doing another D5 release in the near future (unless a serious security bug comes along). Right now it would be too much work to try and port to D6 while also fixing bugs in D5.

mandclu’s picture

Version: 5.x-2.0-beta4 » 5.x-2.0-rc1

I had an issue with random questions not showing, and was able to get it working. The issue, as I saw it, was that the query being built in _quiz_get_random_questions used $quiz properties, when that was never passed to the function. Here's how I got it working:

Lines 1255 to 1257 of quiz. module should now be:

  if ($quiz->number_of_random_questions > 0) {
    $random = _quiz_get_random_questions($quiz);
    $questions = array_merge($questions, $random);

The main difference is that I got the random questions in a separate step, and passed the entire $quiz object. As a result, we need to change the start of _quiz_get_random_questions to:

function _quiz_get_random_questions($quiz) {
  $num_random = $quiz->number_of_random_questions;
  $tid = $quiz->tid;
  $questions = array();

The main difference is that it now accepts the $quiz object, and then sets the two variables that it previously accepted, so that the rest of the code should continue to work.

jenlampton’s picture

Status: Fixed » Active

I just upgraded from Quiz 5.x-1.x to 5.x-2.0-rc1. I was unable to see ANY questions on a quiz that was made of all random questions. When I assigned 5 random questions to the quiz, and set the number of questions to be randomly assigned, I got this error...

The number of random questions for this Quiz have been lowered to 0 to match the number of questions you assigned.

I poked around in the code and found that $assigned_random is being incremented when questions are QUESTION_ALWAYS. changing line 1735 seems to ged rid of the error message. I changed it from this:

if (QUESTION_ALWAYS == $status) {

to this:

if (QUESTION_RANDOM == $status) {

That fix made the error disappear on the config page, but when I try to take a quiz I get this error...

Not enough random questions were found. Please add more questions before trying to take this Quiz.

...which I was able to fix with the code above.
Jen

mbutcher’s picture

Status: Active » Closed (won't fix)

These issues have all been fixed in the Drupal 6 version. I am not maintaining the Quiz 5 branch (no time to backport).

hanskuiters’s picture

Thanks for the work, Jen and Martin. I did some testing and there is one more issue.

If the 'number questions to randomize' is higher than 'Questions random on this quiz', I get the message:

The number of random questions for this Quiz have been lowered to # to match the number of questions you assigned.

Seems allright, but the 'number questions to randomize' is NOT lowered yet. You need to submit the page again. Seems that the page isn't aware of the lowered number.

mbutcher’s picture

Version: 5.x-2.0-rc1 » 6.x-2.0-rc2
Status: Closed (won't fix) » Active

This is on 6.x-2.0 RC2, right? I'm changing the version number of this ticket to reflect that.

hanskuiters’s picture

No, it's on 5.x-2.0-rc1

mbutcher’s picture

Version: 6.x-2.0-rc2 » 5.x-2.0-rc1
Status: Active » Closed (won't fix)

Yeah, I just tested on D6, and the bug is gone there. It was related, I think, to another bug with random questions. Once again I'll have to mark this as "won't fix", since I can't dedicate the time to D5 issues. Frustrating.

Skayazu’s picture

Version: 5.x-2.0-rc1 » 8.x-4.x-dev
Issue summary: View changes

Not enough random questions were found. Please add more questions before trying to take this Quiz.
Happened in 7.x-4.0-rc2 version of module.
Have created taxonomy, correct added to quiz taxonomy with 20 questions, set NUMBER OF QUESTIONS equal 10 and error doesn't allow me take the quiz.

Skayazu’s picture

Status: Closed (won't fix) » Active

Forgot change status...

djdevin’s picture

Version: 8.x-4.x-dev » 6.x-2.0-rc2
Status: Active » Closed (won't fix)

Please don't reopen old issues with different bugs.

Open a new issue and make sure you specify the correct version (8.x-4.x is not supported).

See https://www.drupal.org/issue-queue for issue queue etiquette.