Problem/Motivation
I am able to create a Quiz term with no "Max score per question" value, which crashes the quiz when the question from the term is reached.
When the value is left blank, (see attached "max-score" screenshot), I got an error βThe website encountered an unexpected error. Please try again later.β This field is not required and there is no default value so I didn't think it was necessary especially as there is a "Max score for random" field, just below the "Number of random questions asked" , which does have a default value.
In the log messages the error is
Deprecated function: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in Drupal\filter\Element\ProcessedText::preRenderText() (line 101 of /app/web/core/modules/filter/src/Element/ProcessedText.php)
#0 /app/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(8192, 'str_replace(): ...', '/app/web/core/m...', 101)
#1 [internal function]: _drupal_error_handler(8192, 'str_replace(): ...', '/app/web/core/m...', 101)
#2 /app/web/core/modules/filter/src/Element/ProcessedText.php(101): str_replace(Array, '\n', NULL)
#3 [internal function]: Drupal\filter\Element\ProcessedText::preRenderText(Array)
#4 /app/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(101): call_user_func_array(Array, Array)
#5 /app/web/core/lib/Drupal/Core/Render/Renderer.php(788): Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_ren...', 'exception', 'Drupal\\Core\\Ren...')
#6 /app/web/core/lib/Drupal/Core/Render/Renderer.php(374): Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array)
#7 /app/web/core/lib/Drupal/Core/Render/Renderer.php(204): Drupal\Core\Render\Renderer->doRender(Array, true)
#8 /app/web/core/lib/Drupal/Core/Render/Renderer.php(160): Drupal\Core\Render\Renderer->render(Array, true)
#9 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}()
#10 /app/web/core/lib/Drupal/Core/Render/Renderer.php(161): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /app/web/core/modules/filter/filter.module(303): Drupal\Core\Render\Renderer->renderPlain(Array)
#12 /app/web/modules/contrib/quiz/question_types/quiz_multichoice/src/Plugin/quiz/QuizQuestion/MultichoiceQuestion.php(175): check_markup(NULL, NULL)
#13 /app/web/modules/contrib/quiz/src/Form/QuizQuestionAnsweringForm.php(84): Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion->getAnsweringForm(Object(Drupal\Core\Form\FormState), Object(Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse))
#14 [internal function]: Drupal\quiz\Form\QuizQuestionAnsweringForm->buildForm(Array, Object(Drupal\Core\Form\FormState), Object(Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion), Object(Drupal\quiz\Entity\QuizResult))
#15 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(536): call_user_func_array(Array, Array)
#16 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(283): Drupal\Core\Form\FormBuilder->retrieveForm('quiz_question_a...', Object(Drupal\Core\Form\FormState))
#17 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(224): Drupal\Core\Form\FormBuilder->buildForm('Drupal\\quiz\\For...', Object(Drupal\Core\Form\FormState))
#18 /app/web/modules/contrib/quiz/src/Controller/QuizQuestionController.php(210): Drupal\Core\Form\FormBuilder->getForm('Drupal\\quiz\\For...', Object(Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceQuestion), Object(Drupal\quiz\Entity\QuizResult))
#19 [internal function]: Drupal\quiz\Controller\QuizQuestionController->take(Object(Drupal\quiz\Entity\Quiz), '1')
#20 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#21 /app/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#22 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#23 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#24 /app/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#25 /app/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#26 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#34 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#35 {main}
Steps to reproduce
Create a quiz, select "Categorized random questions", select a question type and number of questions. Leave "Max score per question" blank.
Save and take the quiz and you should see the error from above.
Proposed resolution
Make this field required or have a default value of 1.