-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
4.1.4
-
None
-
MOODLE_401_STABLE
This last week we have upgraded from Moodle 3.11 to Moodle 4.1.4+, with PHP 7.4.
We discovered that the scheduled task quiz_statistics\task\recalculate, all executions shows this error mesage at the end. See below the last lines of the task log.
From the line:
[noformat}
This task has been running for more than 1 hora so stopping this execution.
|
(Note: "1 hora" means "1 hour")
|
|
I was expecting that any single execution of the task with this line that the task would end correctly, as expected, due to the duration of the execution of the task.
|
|
Instead, unexecpectedly, there is an exception thrown after all. It seems that in that loop of the task, it actually does not "break" the loop, but continues into that loop till the line 108:
|
|
$report->calculate_questions_stats_for_question_bank($quizobj->get_quizid());
|
which is the line that finally throws the exception.
|
|
This is the piece of the code for the loop.
|
|
/mod/quiz/report/statistics/classes/task/recalculate.php:75-116
foreach ($latestattempts as $latestattempt) {
if (time() >= $stoptime)
// Check if there is any existing question stats, and it has been calculated after latest quiz attempt.
$qubaids = quiz_statistics_qubaids_condition($latestattempt->quizid,
new sql_join(), $latestattempt->quizgrademethod);
$lateststatstime = $DB->get_field('quiz_statistics', 'COALESCE(MAX(timemodified), 0)',
['hashcode' => $qubaids->get_hash_code()]);
$quizinfo = "'$latestattempt->quizname' ($latestattempt->quizid) in course " .
"$latestattempt->courseshortname ($latestattempt->courseid) has most recent attempt finished at " .
userdate($latestattempt->mostrecentattempttime, $dateformat);
if ($lateststatstime)
if ($lateststatstime >= $latestattempt->mostrecentattempttime)
{ mtrace(" " . $quizinfo . " so nothing to do."); continue; } // OK, so we need to calculate for this quiz.
mtrace(" " . $quizinfo . " so re-calculating statistics for $latestattempt->numberofattempts attempts, start time " .
userdate(time(), $dateformat) . " ...");
try
{ $quizobj = quiz::create($latestattempt->quizid); $report = new quiz_statistics_report(); $report->clear_cached_data($qubaids); $report->calculate_questions_stats_for_question_bank($quizobj->get_quizid()); mtrace(" Calculations completed at " . userdate(time(), $dateformat) . "."); }catch (\Throwable $e)
{ // We don't want an exception from one quiz to stop processing of other quizzes. mtrace_exception($e); $anyexception = $e; }}
|
This is the last lines of the look. This is a sample of a task, but all execution of this task fail for the same reason.
|
|
Calculations completed at 25/07/23, 18:43:20.
This task has been running for more than 1 hora so stopping this execution.
... used 49316 dbqueries
... used 3618.4671690464 seconds
Scheduled task failed: Recalculate question statistics (quiz_statistics\task\recalculate),Error detectat. cal que l'arregli un programador: moodle_database::get_in_or_equal() does not accept empty arrays
Backtrace:
- line 564 of /question/engine/datalib.php: call to moodle_database->get_in_or_equal()
- line 295 of /question/classes/statistics/questions/calculator.php: call to question_engine_data_mapper->load_questions_usages_latest_steps()
- line 96 of /question/classes/statistics/questions/calculator.php: call to core_question\statistics\questions\calculator->get_latest_steps()
- line 660 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\questions\calculator->calculate()
- 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 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()
My assumptions are correct? Or is there something I missed?
Thanks.