opigno_h5p Call to a member function isEvaluated()

Created on 26 April 2024, 8 months ago

Problem/Motivation

Submitting an H5P activity results in the following error:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function isEvaluated() on string in template_preprocess_opigno_user_result_item__opigno_h5p() (line 231 of modules/contrib/opigno_module/ActivityTypes/opigno_h5p/opigno_h5p.module).
template_preprocess_opigno_user_result_item__opigno_h5p(Array, 'opigno_user_result_item', Array)
call_user_func_array('template_preprocess_opigno_user_result_item__opigno_h5p', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('opigno_user_result_item', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 49)
Asm89\Stack\Cors->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

On line 193 of the `opigno_module/ActivityTypes/opigno_h5p/opigno_h5p.module` file there is a foreach loop that is using the same variable, i.e. $answer as the variable that is associated with the above error.

Changing the iterator variable to something like $answer_item fixes the issue. It seems that $answer variable in the foreach loop overrides the $answer (of type \Drupal\opigno_module\Entity\OpignoAnswer) set on line 144.

🐛 Bug report
Status

Closed: won't fix

Version

3.1

Component

Code

Created by

🇪🇹Ethiopia tsega

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024