Call to a member function getPluginInstance() on null

Created on 10 May 2024, about 2 months ago
Updated 4 June 2024, 24 days ago

Problem/Motivation

Upon submitting a quiz with a multiple choice question I get a WSOD.

In the logs is:
Warning: Undefined array key 0 in Drupal\quiz_maker\Plugin\QuizMaker\Response\MultipleChoiceResponse->setScore() (line 34 of /www/modules/contrib/quiz_maker/src/Trait/SimpleScoringResponseTrait.php)

Followed by:
Error: Call to a member function getPluginInstance() on null in Drupal\quiz_maker\Plugin\QuizMaker\Response\MultipleChoiceResponse->setScore() (line 36 of /www/modules/contrib/quiz_maker/src/Trait/SimpleScoringResponseTrait.php).

Steps to reproduce

Create a quiz with a multiple choice question

Take the quiz, observe upon submission the above errors occur.

Proposed resolution

Looks like the array keys of $answers on line 34 of SimpleScoringResponseTrait.php is not 0 based, rather keyed by entity ID of the answers.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom ricky@rbwebdesigns.co.uk

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024