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

Drag drop questions don't validate that drop zones have been defined (causing division by zero errors in the statistics)

    XMLWordPrintable

Details

    Description

      I worked out the real problem here. To reproduce.

      1. Go to the question bank.
      2. Choose 'Create question' and select Drag-drop into image.
      3. Set the Question name, Question text and upload a background image.
      4. Click Save changes.

      Expected result: You get validation errors telling you that you must define at least on drag item.

      Actual result: The question is saved, even though it cannot possibly work.

      The errors when computing the statistics are just a side-effect of this, but since people have bad quesitons in their databases, we need to make that calculation robust too.

      Original bug report follows:

      This task fails to run in our Moodle 4.1dev+ environment (PHP 8.0, Redis 6, Apache 2.4, MariaDB 10.5):

      Execute scheduled task: Vraagstatistieken opnieuw berekenen (quiz_statistics\task\recalculate)
      ... started 13:30:02. Current memory use 5.4 MB.
      Debugging increased temporarily due to faildelay of 1920
      ... used 15169 dbqueries
      ... used 9.6491088867188 seconds
      Scheduled task failed: Vraagstatistieken opnieuw berekenen (quiz_statistics\task\recalculate),Division by zero
      Backtrace:

      • line 151 of /question/type/ddimageortext/questiontypebase.php: call to qtype_ddtoimage_question_base->get_random_guess_score()
      • line 471 of /question/classes/statistics/questions/calculator.php: call to qtype_ddtoimage_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 642 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->__construct()
      • line 941 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysis()
      • line 83 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()

      Attachments

        Issue Links

          Activity

            People

              timhunt Tim Hunt
              alainraap Alain Raap
              Anupama Sarjoshi Anupama Sarjoshi
              Jake Dallimore Jake Dallimore
              CiBoT CiBoT
              Safat Shahin, Tim Hunt, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                13/Mar/23

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 40 minutes
                  3h 40m