Fatal Error: Class name must be a valid object or a string in ../quiz/question_types/quiz_question/quiz_question.module on line 646
Hi
I'm getting this error when trying to view previously passed quizzes as in node/%/quiz-results/%/view
The call stack is:
Call Stack
# Time Memory Function Location
1 0.0001 633832 {main}( ) ../index.php:0
2 1.2230 12049888 menu_execute_active_handler( ) ../index.php:21
3 1.2231 12050840 call_user_func_array ( ) ../menu.inc:527
4 1.2231 12051176 quiz_user_results( ) ../menu.inc:527
5 1.2782 14183728 quiz_calculate_score( ) ../quiz.pages.inc:25
6 1.3035 14210184 _quiz_question_response_get_instance( ) ../quiz.module:2438
Going to a page the following message is then displayed:
"The module for the questiontype is not enabled" which appear to be generate in quiz_question_module_for_type() in quiz.module line 2470.
This may be a seperate problem but I'm fairly certain that both are being caused by a question related to the quiz having been deleted. Just before the line where the error is reported there is:
if (!isset($question)) {
$question = node_load($nid, $vid);
}
$constructor = $info[$question->type]['response provider'];
$to_return = new $constructor($result_id, $question, $answer);
I suspect that either there should be a check if $question has been loaded or the code should not have got this far with a question that is no longer available.
I will investigate further and try to find the root cause and create a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | fatal_error_class_name-2624264-14.patch | 5.44 KB | djdevin |
| #13 | tests.patch | 3.61 KB | djdevin |
| #10 | tests.patch | 3.55 KB | djdevin |
| #10 | fatal_error_class_name-2624264-10.patch | 7.78 KB | djdevin |
Comments
Comment #2
donaldp commentedThis fixes both the problems I was finding.
I probably should have named the patch file a bit better.
I should probably also add that this was a deleted multi-choice question on a single page of multichoice questions.
Comment #3
donaldp commentedStill had an issue with this when deleting quiz results so added an additional change around the code listed in comment 1.
Comment #4
djdevinHmm, the question I have is, should we allow questions to be deleted that are part of existing Quiz results? Wouldn't that mess up reporting, a lot?
Comment #5
donaldp commentedI did think that as well. The site I'm working on is still having content added and altered (off line) so I was not in control of what was being deleted and they are not worried about the reporing at present. However stopping questions that are referrenced from being deleted would probably be a good idea.
Comment #6
djdevinWe can add this as a sanity check but I'll probably add a message like "Questions are missing from this result, calculations may be off etc."
Comment #7
gisleThe patch in #3 fixes the problem.
As for #4: I think this is mainly going to be used during development and testing of quizzes (i.e. before they're put in front of real users), so I wouldn't worry to much about messed up reporting.
Maybe some caveats in
README.mdthat deleting quizzes that are part of existing runs will mess up reporting + a sanity check as suggested in #6.But I'll hate being stopped from doing this on a test site.
Comment #8
Remon commentedPatch in #3 works. Development was almost impossible before applying that patch!
Comment #9
djdevinImplemented sanity checks the OOP way by using broken/fallback classes , similar to how Views and some other Drupal contrib modules do it. In the future we can add warning or error handling to the forms but right now it's not really possible given how tightly coupled Questions are with nodes.
But for now, this will enable deletion and management of quizzes and results where their questions have been deleted.
Comment #10
djdevinComment #13
djdevinComment #14
djdevinComment #16
djdevinFixed. Thanks!
Comment #19
shaktikThanks @djdevin