Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-79332

Question statistics occasional errors Call to a member function populate_from_record() on null


      The way things are supposed to work, there should never be statistics calculated for non-question questions like descriptions.

      However, in the past, we had bugs where that did happen (e.g. MDL-77381 is related, but not the exact one).

      In the case where you have some old stats analysis in the database, pointing at the wrong sore of question, this leads to a fatal error:

      Exception - Call to a member function populate_from_record() on null
      Stack trace:
          line 214 of /question/classes/statistics/questions/all_calculated_for_qubaid_condition.php: Error thrown
          line 492 of /question/classes/statistics/questions/calculator.php: call to core_question\statistics\questions\all_calculated_for_qubaid_condition->get_cached()
          line 669 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->get_cached()
          line 159 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysi

      The code needs to be robust to this.

      (If this does not cause a fatal error, you can go to the statistics report in the problem quiz, and click the 'Recalculate' button. However, with this fatal error, you can't get to the button.)

      This can also happen with the variant stats 'e.g. for calcuated questions. So we need the same changes there too.

      Anyway, this is affecting us, so I am going to change the code to be more robust.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Anupama Sarjoshi Anupama Sarjoshi
            Huong Nguyen Huong Nguyen
            CiBoT CiBoT
            0 Vote for this issue
            2 Start watching this issue


                Original Estimate - Not Specified
                Not Specified
                Remaining Estimate - 0 minutes
                Time Spent - 1 hour, 31 minutes
                1h 31m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.