Using Quiz 7.x-5.0-beta4 I had created a quiz with the Random Questions option and noticed that on the quiz main page the number of questions shown was incorrect. After doing some research I opted to upgrade to version 7.x-5.0-rc3 because it appeared that it contained the fix to the number of questions problem. (I did run update.php after moving in the newer files)

It did fix that problem as my existing random question quiz now showed the correct number of questions. However, when I created a new random question quiz all proceeded normally until I tried to take the quiz. At this point I first got a message that it had encountered an unexpected error, please try again. When I tried again I got the message that I had already taken the quiz and when I tried to take it again (quiz is set to unlimited), it just reloaded the page and gave me the same message. This happened every time I tried to take it.

Looking at the logs I saw the following message that coincided with each of my attempts to take the quiz:

Notice: Undefined variable: question_node in quiz_take_question() (line 1937 of /srv/bindings/3135e28ac36d47c2b027a8fd474d4571/code/sites/all/modules/quiz/quiz.module).

On a less critical note, all my quizzes use a Quiz Page so all the questions are on one page. The most recent random question quiz that I created prior to the upgrade to 5.0-rc3 (which works) has 23 questions. Only 22 show on the page. The 23rd is on a additional page. Why is this? I looked at one of my normal quizzes with 30 questions and all 30 are on the one page.

CommentFileSizeAuthor
#4 random.png45.99 KBdjdevin
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bill Redman created an issue. See original summary.

djdevin’s picture

However, when I created a new random question quiz all proceeded normally until I tried to take the quiz. At this point I first got a message that it had encountered an unexpected error, please try again. When I tried again I got the message that I had already taken the quiz and when I tried to take it again (quiz is set to unlimited), it just reloaded the page and gave me the same message. This happened every time I tried to take it.

Okay that seems odd, I will try and reproduce. If you could give me any more information about how the quiz is set up it would help.

On a less critical note, all my quizzes use a Quiz Page so all the questions are on one page. The most recent random question quiz that I created prior to the upgrade to 5.0-rc3 (which works) has 23 questions. Only 22 show on the page. The 23rd is on a additional page. Why is this? I looked at one of my normal quizzes with 30 questions and all 30 are on the one page.

I think this one is actually by design (a bug, but sort of unavoidable right now). See #2391171: Random Questions in a Quiz with pages

Maybe you didn't see it on the old site, but there is a chance that when it picks random questions it shuffles the page as well. I think if you tried enough attempts it would eventually shuffle the page?

bill_redman’s picture

The quiz in question is made up a Quiz Page and 25 multiple choice questions. Of those 25, 5 are marked as compulsory. The number of random questions is set to 18 of the remaining 20. Quiz allows unlimited attempts and the passing score is anything from 0 to 100 since this is being used as a learning tool. I think that covers it. If you need additional info, just let me know.

As for the second question, thanks for the link to an explanation. As I said, this was not an issue, just a question.

Thanks.

djdevin’s picture

FileSize
45.99 KB

Is your parent page also marked as compulsory?

I saw some issues when the page was not a required question (as sometimes it didn't get included in quiz).

I set up a quiz like this and haven't had any issues:

bill_redman’s picture

My parent page was not set as compulsory. I set is as such, but still was unable to take the quiz. It just re-loads the info page. Same error message in logs as originally noted. Also, I have 2 other quizzes using random questions where the parent page was not marked as compulsory and they are working fine.

djdevin’s picture

Could you try with a brand new user? Just want to eliminate the possibility that the user is taking the Quiz on an old (broken) revision.

bill_redman’s picture

I tried as a totally different user as you suggested and I able to take the exam. I tried multiple times and each time I was successful. So, it looks like your suspicions were correct. However, while still logged in as this user, I tried to take another exam that worked previously only to encounter the same problem that originally prompted this posting. At this point I think I'm going to delete that quiz and re-create it and hope that straightens things out.

Thanks, as always, for your help. I will let you know if re-creating the quiz works.

djdevin’s picture

No problem, and yes that does sound like because the page could possibly (but not always) not be part of the quiz.

So I think both issues are really because of #2391171: Random Questions in a Quiz with pages which needs some more thought - it explains the oddity with one question not on a page, and also some of the issues that may happen when randomizing a quiz with pages.

bill_redman’s picture

Update: I deleted and re-created the quiz and so far, everything is working as it should.

bill_redman’s picture

One more question, if I may. Marking the parent page as compulsory seems to have resolved my issue as you suspected. However, I was informed by a quiz taker that when they took it, they were scored as if the parent page was a question they failed to answer. Any way around that?

djdevin’s picture

I'd need more information about that, since Pages are worth 0 points internally. Any screenshots of the quiz results would help.

bill_redman’s picture

As I think about this, it might be better (for me, at least) to confirm that I have understood and set up the quiz correctly.

The quiz has a total of 25 questions nested under a parent Quiz Page. Each question has a max score of 1.

Of those 25, 5 plus the parent page are marked as Compulsory with the Number of random questions set at 18 for a total of 23.

On the info page it indicates that the quiz has 24 questions which I'm assuming to be my 23 valid questions plus the parent page.

However, when the person took the quiz they got 22 of the 23 questions correct and they were given a score of 92. Which would be accurate were there 24 actual questions in the quiz. Their score should have been 96. This is what made me think the parent page was being counted as a question.

djdevin’s picture

Title: Cannot take newly created Quiz » Random ungraded questions break max score
Version: 7.x-5.0-rc3 » 7.x-5.x-dev

I've reproduced it but it's tricky and probably not a useful situation. You can also do the same with Quiz directions or any other ungraded question type.

1. Create a quiz
2. Set the quiz to "Random question"
3. Add a quiz directions and a true/false question
4. Leave both as NOT compulsory
5. Set random questions to 2
6. Take quiz

You can only get 1/2 because since the quiz is random, when a result is generated it takes all the questions and calculates a max score for the quiz based on the random question configuration. Since there are 2 random questions it calculates it as 2 points. But Quiz directions are worth 0 points so it is impossible to get 2 points.

So what I think we have to do here is:

1. Require that non-graded questions be marked as compulsory in random quizzes (so we can have a consistent max score of the quiz).
2. Exclude non-graded questions from the "max score for random" calculation (so at run-time, the question is worth 0 points)

bill_redman’s picture

Hi, I was wondering if this was ever resolved? The reason I ask is because it has occurred again on a quiz of mine using a Quiz Page and randomized questions.

Quiz Page marked as Compulsory
Number of random questions - 20

When quiz is scored, the Quiz Page is included in the calculation. 18 correct answers resulted in a score of 86%, should be 90%.

Thanks.

djdevin’s picture

Sorry for the delay, this does not appear to be fixed. This is a valid bug but it's an edge case so it has not come up.

bill_redman’s picture

No need to apologize. Here I am replying 2 months later. I understand your position and that's fair. As it is, the quiz in question is not currently being used very much, or if it is, nobody has complained. If you could keep it in the queue, though, that would be appreciated.