- Merge request !15Issue #3275463: Typecast the return value of MultichoiceResponse::score to int β (Closed) created by artem_sylchuk
- Status changed to Closed: outdated
9 months ago 11:10pm 26 July 2024
In the previous versions of the module it was possible to create the multichoice qiuz question with empty score field for the correct answer.
Now module prevents that on the form level, but if you had questions created before you can face the situation when selecting the correct answer causes this error:
Return value of Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse::score() must be of the type int or null, string returned in Drupal\quiz_multichoice\Plugin\quiz\QuizQuestion\MultichoiceResponse->score()
That happens because code on in MultichoiceResponse::score (line 73)
$score = $alternative->get('multichoice_score_chosen')->getString();
Can return the empty string and empty string isn't converted to 0 and doesn't comply with the function signature:
public function score(array $response): ?int
Closed: outdated
6.0
Code - Multichoice
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.