After editing a Multiple choice question (specifically, the "Feedback if chosen" and "Feedback if not chosen" fields), confirming an "Update (no revision)" for the corresponding quiz, then re-taking this quiz, I get an HTTP 500 Server Error immediately after answering the amended question.

On re-loading the page, I get the following:

The answer was incorrect. Please try again.
Notice: Undefined property: MultichoiceResponse::$result_answer_id in quiz_question_element_validate() (line 935 of /home/DOMAIN/public_html/SUBDOMAIN/sites/all/modules/quiz/question_types/quiz_question/quiz_question.module).
Warning: array_flip(): Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 219 of /home/DOMAIN/public_html/SUBDOMAIN/sites/all/modules/entity/includes/entity.controller.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /home/DOMAIN/public_html/SUBDOMAIN/includes/entity.inc).
Warning: Creating default object from empty value in quiz_question_element_validate() (line 937 of /home/DOMAIN/public_html/SUBDOMAIN/sites/all/modules/quiz/question_types/quiz_question/quiz_question.module).

This seems to be similar to https://www.drupal.org/node/2419449 ("Notice: Undefined property: MultichoiceResponse::$result_answer_id in MultichoiceResponse->...") which has apparently been fixed.

Comments

Onein created an issue. See original summary.

zrhoffman’s picture

I have this problem, too, after updating from 5.0rc1 to 5.1. I don't think any users edited the quiz before it started throwing errors.

I enabled the "dblog" module, tried taking the quiz and got a 500 error, and found this:

Notice: Undefined property: MultichoiceResponse::$result_answer_id in quiz_question_element_validate() (line 935 of /home/DIRECTORY/profiles/PROFILE/modules/contrib/quiz/question_types/quiz_question/quiz_question.module).
Warning: array_flip(): Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 219 of /home/DIRECTORY/profiles/PROFILE/modules/contrib/entity/includes/entity.controller.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /home/DIRECTORY/includes/entity.inc). 

Like Onein, I get "The answer was incorrect. Please try again." on the next page after the 500 error. I got the error after responding to the first question of the quiz, which is of type "Multiple choice question".

Database updates ran successfully when updating, so that was not the issue.

The following updates are pending:

quiz module :
  7523 -   Add type for quiz results.
  7524 -   Remove old db structure for randomised questions.

Do you wish to run all pending updates? (y/n): y
Performed update: quiz_update_7523                                          [ok]
Performed update: quiz_update_7524                                          [ok]

Edit: We were at 5.0rc1 before the update, not 5.0.

djdevin’s picture

The issue is definitely because the current user's layout (the questions to be taken) contains questions that no longer exist. That causes the "Warning: array_flip" error and the subsequent fatal error.

I can reproduce this easily by taking a quiz and the deleting questions without creating a new revision - but if there is another clear way to reproduce this I can definitely take another look.

We haven't really decided what to do when a question no longer exists, as removing the record would affect things like reporting, scoring, etc.

djdevin’s picture

Status: Active » Closed (duplicate)