Argument #2 ($crp) must be of type string, array given Drupal\opigno_h5p\TypeProcessors\FillInProcessor::isResponseCorrect()

Created on 7 June 2023, about 1 year ago
Updated 1 February 2024, 5 months ago
๐Ÿ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡ป๐Ÿ‡ณVietnam LuongGiap

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

Comments & Activities

  • Issue created by @LuongGiap
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kbk1992 Hyderabad

    bharath-kondeti โ†’ made their first commit to this issueโ€™s fork.

  • @luonggiap opened merge request.
  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Please review.

  • ๐Ÿ‡ป๐Ÿ‡ณVietnam LuongGiap

    Hi everyone, please help me fix issue

  • Status changed to Active about 1 year ago
  • ๐Ÿ‡ป๐Ÿ‡ณVietnam LuongGiap

    Help me check issue

  • Hi,
    I have the same bug.
    If I change my code with your commit 21899973
    It create new error on line 345 private function isResponseCorrect(string $response, string $crp, bool $caseSensitive): bool {...

    TypeError : Drupal\opigno_h5p\TypeProcessors\FillInProcessor::isResponseCorrect(): Argument #2 ($crp) must be of type string, array given, called in /app/web/modules/contrib/opigno_module/ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php on line 255 dans Drupal\opigno_h5p\TypeProcessors\FillInProcessor->isResponseCorrect() (/app/web/modules/contrib/opigno_module/ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php ligne 335)

    I try to fix it, but next I have same error in $singleCRP.

  • I create patch, please try it.

  • ๐Ÿ‡ฆ๐Ÿ‡ทArgentina leofishman

    Patch works form me, thanks a lot!!!

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland Berdir Switzerland

    The patch works, but knowing nothing about opigno internals, this seems very strange. isResponseCorrect() has $crp as string, the value that is being worked with seems to be a string at least in some cases and then the implementation inside clearly also expects it to be an array or it wouldn't call array_map() on it.

    So instead of converting twice, maybe $crp should be set to array and we should ensure we always pass in an array? The function is private and only used in one place, so should be fine to change.

    Setting to needs review to make it clear that there is a patch here and get feedback from the maintainers.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland Berdir Switzerland

    Turns out the patch doesn't work for us, because it only converts it to an array if case sensitivity is off, but the is_array() below still expects it to be an array.

    Here's patch that does what I suggested and changes the type to array, that seems to just work for us in this one case, will require more testing.

  • I have the same exact bug with a quiz when updating Opigno from 3.0.9 to 3.1.0.

    The error occurred specifically on a Drag Text question:

    This was resolved with the patch provided in comment #12 by Berdir. I did not try any other patches.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance G4MBINI Bรจgles

    Hi,

    I encounter same kind of issue with Flashcards (https://h5p.org/tutorial-flashcards)

    The website encountered an unexpected error. Please try again later.
    TypeError: Drupal\opigno_h5p\TypeProcessors\FillInProcessor::isResponseCorrect(): Argument #2 ($crp) must be of type string, array given, called in /app/web/modules/contrib/opigno_module/ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php on line 255 in Drupal\opigno_h5p\TypeProcessors\FillInProcessor->isResponseCorrect() (line 335 of modules/contrib/opigno_module/ActivityTypes/opigno_h5p/src/TypeProcessors/FillInProcessor.php).
    Drupal\opigno_h5p\TypeProcessors\FillInProcessor->isResponseCorrect('Romain', Array, ) (Line: 255)
    Drupal\opigno_h5p\TypeProcessors\FillInProcessor->getPlaceholderReplacements(Array, Array, ) (Line: 218)
    Drupal\opigno_h5p\TypeProcessors\FillInProcessor->buildReportOutput('Respond to FCWhat's your name ? __________', Array, Array, ) (Line: 72)
    Drupal\opigno_h5p\TypeProcessors\FillInProcessor->generateHtml('Respond to FCWhat's your name ? __________', Array, 'Romain', Object, NULL) (Line: 66)
    Drupal\opigno_h5p\TypeProcessors\TypeProcessor->generateReport(Object, , ) (Line: 118)
    Drupal\opigno_h5p\H5PReport->generateReport(Object) (Line: 78)
    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: 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)
  • ๐Ÿ‡ง๐Ÿ‡ดBolivia vacho Cochabamba

    patch #12 alsow works for us.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jwjoshuawalker San Diego

    Just want to chime in and say we were experiencing this issue as well.

    Very serious problem! Users would go through all the steps of a very lengthy test and at the end it wouldn't record the score in the opigno_learning_path_achievements table as 'completed', but left it stuck in a 'pending' state.
    (It also caused it to fail setting the completed date in that table).

    The proposed patch is simple, has anyone from Opigno seen this thread?

Production build 0.69.0 2024