Fatal error: Call to a member function on a non-object in .../moodle/mod/quiz/lib.php on line 1005
This line is:
$nextquestionnumber = $QUIZ_QTYPES[$question->qtype]->print_question
($nextquestionnumber, $quiz, $question, $readonly, $details);
We edited the quiz after that, and found that the question couldn't be moved, editing the question fixed that, but the Fatal error remains at the same place. After the error happens the question can't be moved again.
The upgrade went smoothly, as always, and the tables were upgraded.
This is on a GNU/Linux system (Debian woody) with PHP 4.1.2, which has been running moodle and upgrading since 1.2.0
So I made a little chewing-gum fix:
- Dug up the backups of the older version's (1.3.3) database.
- Made a clone site of that older version
- In clone site I backed up the problematic course (there was only one quiz where this error appeared).
- Then I restored that backup as a new course to our upgraded (1.4+) installation.
- Renamed the old one with new name and renamed the restored one with the course's old name.
- Crossed my fingers and toes and hope that the teacher and students doesn't ever find out the difference...
- Janne -
Guess it is a database value that is wrong.
Unfortunately this course is active and I can't try your fix. We have backups, but from previous reports it seems the quiz was damaged before, and 1.4.0 reacts to this quiz in a different way. (it gives different totals depending on the page you are watching).
No other quiz has shown this problem so far.
I have just been bitten by the same "Fatal error: Call to a member function on a non-object in .../mod/quiz/lib.php on line 1005". From the code it looked like it was trying to access a non-existant question.
As it turns it was only happening on a quizz that we knew was corrupted. When the quizz was being set up, I added but then deleted again 30 questions. Looking at the database tables, the question details had been removed, but their question numbers had not been deleted (ie they were listed in quizz.questions, but not in quizz_questions.id).
I fixed my problem by removing the missing questions from the questions field of the quizz table.
BTW, we first noticed that we had a corrupt quizz as the marks were all being scaled out of 70, when we only had 40 questions. It was then that we found the 30 phantom questions.
Hope this helps,
David