Help is need with quiz module error

Help is need with quiz module error

by Dr. Ali Abureesh -
Number of replies: 12
Picture of Core developers Picture of Translators

Hi guys,

I'm facing the following problem with quiz module.

Fatal error: Call to a member function on a non-object in /home/ali4mak/public_html/moodle/lib/questionlib.php on line 1257

I will highly appreciate any help for I'm giving an online quiz on Friday.
Thanks in advance.

Average of ratings: -
In reply to Dr. Ali Abureesh

Re: Help is need with quiz module error

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Which version of Moodle?

What exactly were you doing at the time?
In reply to Tim Hunt

Re: Help is need with quiz module error

by Dr. Ali Abureesh -
Picture of Core developers Picture of Translators
Thanks Tim for your reply. I'm using version 1.6.4
In reply to Dr. Ali Abureesh

Re: Help is need with quiz module error

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You can't be. There is no way that error could have come from line 1257 of lib/questionlib.php in Moodle 1.6.4. Do you have some custom modifications?

And you did not answer: what were you doing when the error occurred?
In reply to Tim Hunt

Re: Help is need with quiz module error

by Dr. Ali Abureesh -
Picture of Core developers Picture of Translators

Sorry for not answering your question.

The version I'm using is Moodle 1.6.4+ (2006050540)
The quiz contain shot answer and MCQ.


When I click Preview:  I get the following:
Fatal error: Call to a member function on a non-object in /home/ali4mak/public_html/moodle/lib/questionlib.php on line 1263
This error I get also when I click Start again.

When I click page 2 or any other page:  I get the following:
Fatal error: Call to a member function on a non-object in /home/ali4mak/public_html/moodle/lib/questionlib.php on line 973.

I still can edit the quiz.
Thanks Tim


In reply to Dr. Ali Abureesh

Re: Help is need with quiz module error

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That makes more sense.

I would guess that you have a question where the question-type has got mixed up in the database.

Do you have direct access to your database? If so, can you try running the query

SELECT DISTINCT qtype FROM mdl_question;

and tell us what it produces.

Also, if you can run some database-maintenance type commands to confirm that the database is not corrupted. Sorry, I can't remember what the command is. It is something like check table.
In reply to Tim Hunt

Re: Help is need with quiz module error

by Dr. Ali Abureesh -
Picture of Core developers Picture of Translators

I did run database maintenance as you directed and I got:

repair status OK

But the Error still shows up. Is there any way to solve this problem or do I have to do the quiz again?

In reply to Dr. Ali Abureesh

Re: Help is need with quiz module error

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I believe that I experienced this when I had manipulated the database directly and had removed some questions. As a result the random question that was there could not find the actual question. I ended up pulling from a backup and adding the question back in and that fixed things for me. You may want to check the mdl_question table and make sure it is not corrupted. Peace.
In reply to Anthony Borrow

Re: Help is need with quiz module error

by Dr. Ali Abureesh -
Picture of Core developers Picture of Translators
 mdl_question table is not corrupted. I might have to do the quiz all over again.
In reply to Dr. Ali Abureesh

Re: Help is need with quiz module error

by Jim Hunt -

An idea that someone else gave me - create a temporary category for test questions and enter all questions into that category and test edit/test the questions till you are comfortable with each question. Then move your questions to the category you want them in.

Since nothing is really deleted in moodle, if you do this the random function can only access the "good" questions, while the "bad" questions remain in the temporary category forever. It seems to be working for me.

I hope that helps!