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

Drag and drop into text question with no places causes Division by zero error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.0.8, 4.1.3
    • Questions, Quiz
    • MOODLE_400_STABLE, MOODLE_401_STABLE

      If you have:

      1. a "Drag and drop into text" question that defines no valid places to drop the draggable expressions into,
      2. a quiz attempt "answering" this question and
      3. run the "Recalculate question statistics" scheduled task,

      you get the following error (in Moodle 4.1.3):

      Scheduled task failed: Recalculate question statistics (quiz_statistics\task\recalculate),Division by zero
      Backtrace:
      * line 207 of /question/type/gapselect/questiontypebase.php: call to qtype_gapselect_question_base->get_random_guess_score()
      * line 472 of /question/classes/statistics/questions/calculator.php: call to qtype_gapselect_base->get_random_guess_score()
      * line 82 of /question/classes/statistics/questions/calculator.php: call to core_question\statistics\questions\calculator->get_random_guess_score()
      * line 647 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->__construct()
      * line 950 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 263 of /lib/cronlib.php: call to quiz_statistics\task\recalculate->execute()
      * line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()
      

      See for example attached question in Moodle XML format. Unfortunately it is not known how that question got created. It was definitely created with an earlier Moodle version. Moodle usually doesn't let you save the question if there are no valid drop zones defined.

      Steps to reproduce:

      1. Import questions-(VO) Pflanzenbiotechnologie-Transformation 2-20230522-1611.xml into a question bank.
      2. Create a new quiz using this question.
      3. Attempt, submit and finish that quiz as a student.
      4. Run the "Recalculate question statistics" scheduled Task.

            Unassigned Unassigned
            tschroeder Tim Schroeder
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

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