This is issue B described in
MDL-77080. Some cloze questions (qtype_multianswer) can have missing subquestions. Those can lead to the scheduled task \quiz_statistics\task\recalculate failing. In MDL-54724 most problems around missing subquestions have been fixed, but this has been missed.
Error in Moodle 4.1.2:
In combination with the fix for
MDL-75576 making it so quiz statistics are only ever calculated in cron and not "on-the-fly" anymore this issue can lead to lots of quizzes not showing any statistics anymore. MDL-54724 describes one way to create cloze questions with missing sub questions through normal use in an old Moodle version. Here is how you can artificially create such a question and evoke the error:
- Create a quiz.
- Add a new question of qtype_multianswer with the text from the attached file "question-text-example.txt" to it.
- Modify the corresponding entry in the question_multianswer table by hand to contain one additional question id in the sequence column (no question must exist for that id!)
- Purge the "other" cache.
- Take and submit the quiz as a student.
- Run the \quiz_statistics\task\recalculate task.