The Quiz 5.x quiz questions are incompatible with the EVA module, when taking the quiz.

There are three issues, all with the questions as they are built and presented while a user takes a quiz.

1) **The $type parameter passed to hook_entity_view_alter() implementations is having the value of the node type, and not the entity type.** nevermind this issue

2) the build array that is produced for a quiz question and passed around to hook_entity_view_alter() implementations does not include the entity object in an index '#entity', as is semi-standard for entity build arrays.

This above two issues basically make the EVA module non-functional for question types, at least as far as they are presented when taking a quiz.
EVA does work for viewing the question node view pages.

3)If you have both the Quiz module, and EVA module installed you will see notices in the log:
Notice: Undefined index: #language in eva_entity_view_alter() (line 56 of /var/www/web/sites7/all/modules/eva/eva.module).
This is due to the quiz question build array not including a '#language' array parameter.
Just having the modules installed will cause tons of notices while taking the quiz, one for each question viewed.

With a clean Quiz 5.x beta2 installation, and then you install the eva module, you'll also see this while taking a quiz:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7879 of /var/www/web/drupal7/includes/common.inc).

Comments

markusa created an issue. See original summary.

markusa’s picture

Issue summary: View changes
markusa’s picture

Big whoops here. Issue 1) is caused by a edit I did to quiz.module on my local
I was experiencing this issue:
https://www.drupal.org/node/2594511

did the change, which fixed the error, but brought up this one....

markusa’s picture

So without the hacks in the https://www.drupal.org/node/2594511
Having the EVA module installed breaks taking a quiz....

this is do to issue 2) I mentioned in the summary

markusa’s picture

see recommended solution here as well: https://www.drupal.org/node/2594511

Those two issues are completely related.

If you are coming here with a problem with Quiz 5.x and using the EVA module you are likely getting this error:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7879 of /var/www/web/drupal7/includes/common.inc).

This small adjustment is working for me here:
/quiz/question_types/quiz_question/quiz_question.module: 215
and here:
/quiz/question_types/quiz_question/quiz_question.core.inc: 729

$type = 'node';
$node_build_array = node_view($node);
 //drupal_alter(array('node_view', 'entity_view'), $node->content, $type);
 drupal_alter(array('node_view', 'entity_view'), $node_build_array, $type);

I think this small alteration will insure compatibility with hook_node_view and hook_entity_view implementations

markusa’s picture

Issue summary: View changes
djdevin’s picture

Status: Active » Closed (duplicate)