Hi. I don't know if it's fair to call this a "bug", because the quiz module itself never hits this use case.
However, in my case, I'm wrapping quiz_take_page with another page callback that checks how many questions a few quizzes have before displaying which quiz to take.
A recent change in #2576419: Question count should exclude non gradable questions breaks this use case, because the call to quiz_get_number_of_questions upon submission of the last question prematurely sets the static cache, so when it grades, all kinds of PHP errors are thrown out.
Notice: Undefined property: stdClass::$choice_boolean in MultichoiceResponse->score() (line 888 of sites/all/modules/contrib_frozenversion/quiz/question_types/multichoice/multichoice.classes.inc).
Notice: Undefined property: stdClass::$alternatives in MultichoiceResponse->isAllWrong() (line 924 of sites/all/modules/contrib_frozenversion/quiz/question_types/multichoice/multichoice.classes.inc).
...And the score is wrong.
I'm not sure if this will be even supported, but having a 'donotcache' parameter for _quiz_question_get_instance and calling it in that mode within quiz_get_number_of_questions would be one approach...
Comment | File | Size | Author |
---|---|---|---|
#4 | refactor-2592105-4.patch | 2.86 KB | djdevin |
Comments
Comment #2
captainack CreditAttribution: captainack commentedWell I worked around the problem by copying the old code that used to be in quiz_get_number_of_questions and using that instead.
It solved my problem. But I'm a little puzzled as to why. After looking at quiz_question_answering_form_validate(), I see _quiz_question_get_instance called with FALSE as use_cached, so the (presumably corrupt) cache entry should be overwritten. AFAICT This is called before anything, so there shouldn't be a problem.
Since I'm working around it and it currently shows no problems with basic quiz module usage, you can close this if it's not worth the trouble to investigate.
Comment #3
djdevin_quiz_question_response_get_instance also had a ton of caching on it, which is now unnecessarily because of the level of caching in core (we are using nodes and the Entity API). That was addressed in #2470103: Refactor scoring system to use Entity and Question API
So we should fix this too anyway. There's even a comment that says "get rid of this in D7" so...
Comment #4
djdevinComment #6
djdevin"Fixed"
This delegates to the built in Entity cache.
Comment #7
captainack CreditAttribution: captainack commentedSweet! Thanks Devin!