I'm using this wonderful module along with Paragraphs which relays on Entity API. Most of it works pretty well except for the answer validation, which only supports node entities, so I get this AJAX bug when user hits "Submit" into a quiz:

AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Service unavailable (with message)
ResponseText: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7922 of /var/www/htdocs/includes/common.inc).

The module is doing calls to field_get_items() as follows:

$items = field_get_items('node', $form_state['values']['entity'], $form_state['values']['field_name']);

This is easy to fix by doing this instead:

$items = field_get_items($form_state['values']['entity']->entityType(), $form_state['values']['entity'], $form_state['values']['field_name']);
CommentFileSizeAuthor
#11 entity-support.patch4.5 KBmishac
#10 entity-support.patch5.07 KBmishac
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

develCuy created an issue. See original summary.

Carsten Müller’s picture

Assigned: Unassigned » Carsten Müller

  • Carsten Müller committed 0844a4c on 7.x-1.x
    Issue #2830387 by develCuy, Carsten Müller: adding Entity and Entity API...
Carsten Müller’s picture

Status: Active » Needs review

I checked this and added entity support fro all entity types but without using the Entity API module. It should now work for every entity type and also with the Entity API module.
I pushed this fix in the 7.x-1.x-dev branch, so it can be tested there. After this i will create a new release for it.

Carsten Müller’s picture

Status: Needs review » Fixed

published release 7.x-1.7 which includes this fix

justkristin’s picture

I have been trying to get it to work as a paragraph in D8... Is this problem with entities what is keeping my quiz paragraph from showing, perhaps? Or shall I keep banging away?

Carsten Müller’s picture

Version: 7.x-1.x-dev » 8.x-1.0-alpha2
Status: Fixed » Needs work

Hello justkristin,

this issue is by now just fixed for the Drupal 7 version. Currently I'm trying to fix the issues in Drupal 7 and then i will switch to the Drupal 8 version and will try to implement all the features there. I'm setting this issue to the Drupal 8 version now to be remembered.

justkristin’s picture

Sir - I think I have paragraphs working, but the result is not shown via ajax, but rather by page reload. Is that related to this ticket? Or should I open another?
Thank you for all the work you do on this...

Carsten Müller’s picture

Hi,

i didn't test it with Paragraphs yet. I will do, when i have some time for this. But maybe this will take a while...

mishac’s picture

FileSize
5.07 KB

I needed paragraph support so I made an initial stab at a patch to make the quiz work for any entity type. It also gets the entity ID from the FieldItemList object, rather than from the Route.

mishac’s picture

FileSize
4.5 KB

Woops that patch includes some changes to the info.yml file that it shouldn't. this one should be better.

  • asrob committed f5d0999 on 8.x-1.x authored by mishac
    Issue #2830387 by mishac: Entity API support
    
    Signed-off-by: Peter Borsa...
asrob’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.