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

\quiz_statistics\task\recalculate exception for mulitple choice questions with no choices

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.1.5, 4.2.2
    • 4.1.2
    • Questions

      If there are multichoice questions in the database with no answers (doesn't seem possible from the GUI, but we have a few from past semesters in our database), the recalculate scheduled task throws an exception because the value for randomguessscore is calculated as NAN (in question/type/multichoice/questiontype.php:252, denominator of count of answers is 0, division by 0 error). The exception causes the entire task to fail. Even though it is a remote possibility, should a check for dividing by 0 be included here to prevent the task from failing altogether?

      Scheduled task failed: Recalculate question statistics (quiz_statistics\task\recalculate),Error writing to database (Unknown column 'NAN' in 'field list'
      Debug info:
      Unknown column 'NAN' in 'field list'
      INSERT INTO mdl_question_statistics (hashcode,timemodified,questionid,slot,subquestion,s,effectiveweight,negcovar,discriminationindex,discriminativeefficiency,sd,facility,subquestions,maxmark,positions,randomguessscore,variant) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
      [array (
        0 => '67a4aa3ea0c50feb5a90e36dec5271716c86ac33',
        1 => 1681313612,
        2 => '4715684',
        3 => NULL,
        4 => 1,
        5 => 19,
        6 => NULL,
        7 => 0,
        8 => NULL,
        9 => NULL,
        10 => 0.0,
        11 => 0.0,
        12 => '',
        13 => '5.0000000',
        14 => '3,4,7,9,10,11,12,14,15,16,19',
        15 => NAN,
        16 => NULL,
      )]
      Backtrace:

      • line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
      • line 1362 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
      • line 1408 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      • line 231 of /question/classes/statistics/questions/calculated.php: call to mysqli_native_moodle_database->insert_record()
      • line 271 of /question/classes/statistics/questions/all_calculated_for_qubaid_condition.php: call to core_question\statistics\questions\calculated->cache()
      • line 259 of /question/classes/statistics/questions/calculator.php: call to core_question\statistics\questions\all_calculated_for_qubaid_condition->cache()
      • line 650 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->calculate()
      • line 937 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysis()
      • line 108 of /mod/quiz/report/statistics/classes/task/recalculate.php: call to quiz_statistics_report->calculate_questions_stats_for_question_bank()
      • line 259 of /lib/cronlib.php: call to quiz_statistics\task\recalculate->execute()
      • line 120 of /lib/cronlib.php: call to cron_run_inner_scheduled_task()
      • line 73 of /lib/cronlib.php: call to cron_run_scheduled_tasks()
      • line 178 of /admin/cli/cron.php: call to cron_run()

      Thanks!

            timhunt Tim Hunt
            meltonml Michelle Melton
            Mark Johnson Mark Johnson
            Jake Dallimore Jake Dallimore
            CiBoT CiBoT
            Votes:
            4 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 16 minutes
                1h 16m

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