When having a full setup of quiz and submodules and adding quiz result display settings, somehow it breaks.
When quiz results cannot get a proper layout it breaks and the quiz cannot be taken because of the next error:

Notice: Undefined offset: 27 in QuizResult->getLayout() in QuizResult.class.inc
Warning: Invalid argument supplied for foreach() in quiz_take_quiz() (line 1886 in quiz.module

I think it would be nicer to set a check if there's a layout, so it cannot break the process.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mr_infinity created an issue. See original summary.

djdevin’s picture

Hi,

That means the quiz attempt did not have any questions, which isn't supposed to happen.

Does it do the same if you delete the current result?

mr_infinity’s picture

Thanks for the quick respond! It appears also when a newly made quiz haves questions... also when creating a new quiz. There is no possibility to start the quiz.

mr_infinity’s picture

I would like to add my patch, if possible.

mr_infinity’s picture

To bring more context: When we create a quiz, we do start the quiz automatically.
But if there are no questions, then it breaks immediatly. So if no questions where presented and you choose to start, it should not break the site.

fabianderijk’s picture

There was also another issue involved in this one. When you reload a quiz that you where taking (for example on the page www.example.com/node/666/take/1) and all results have been removed from that quiz (so you don't have any progress anymore) you should be redirected to the node page instead of getting a 500 error. I've added the code in the patch and uploaded it in this comment.

djdevin’s picture

Status: Active » Needs review
Issue tags: +Needs tests

Thanks, let's see what the tests say.

We should add an automated test for this to make sure this doesn't regress.

Status: Needs review » Needs work

The last submitted patch, 6: layout_error_quiz_not-2884215-6.patch, failed testing. View results

webservant316’s picture

I am experiencing this problem. This is an old issue, but was the solution never implemented?