update overdue attempts task fail

update overdue attempts task fail

François Lizotte -
回帖数:8
Particularly helpful Moodlers的头像
Hello,

We get this in one of our Moodle sites:

Execute scheduled task: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts) ... started 07:03:20. Current memory use 20.2Mo. Looking for quiz overdue quiz attempts... ... used 8 dbqueries ... used 0.040343999862671 seconds Scheduled task failed: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts),Attempt to assign property "firstinsection" on null

It sounds like something to fix somwhere in the database, but where?

With debug mode, we got this (sorry for the messy display):

Warning: Undefined property: stdClass::$email in /var/www/html/moodle/config.php on line 132 Execute scheduled task: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts) ... started 20:19:19. Current memory use 20.4Mo. Looking for quiz overdue quiz attempts... Warning: Undefined array key 95610 in /var/www/html/moodle/mod/quiz/attemptlib.php on line 775 Warning: Attempt to read property "section" on null in /var/www/html/moodle/mod/quiz/attemptlib.php on line 775 ... used 8 dbqueries ... used 0.041204929351807 seconds Scheduled task failed: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts),Attempt to assign property "firstinsection" on null Backtrace: * line 718 of /mod/quiz/attemptlib.php: call to quiz_attempt->determine_layout() * line 648 of /mod/quiz/attemptlib.php: call to quiz_attempt->load_questions() * line 78 of /mod/quiz/cronlib.php: call to quiz_attempt->__construct() * line 61 of /mod/quiz/classes/task/update_overdue_attempts.php: call to mod_quiz_overdue_attempt_updater->update_overdue_attempts() * line 253 of /lib/cronlib.php: call to mod_quiz\task\update_overdue_attempts->execute() * line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()


Any idea?

Thanks in advance,

François

回复François Lizotte

Re: update overdue attempts task fail

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像

OK, let me edit that to make it readable:

Looking for quiz overdue quiz attempts...

Warning: Undefined array key 95610 in /var/www/html/moodle/mod/quiz/attemptlib.php on line 775

Warning: Attempt to read property "section" on null in /var/www/html/moodle/mod/quiz/attemptlib.php on line 775 ...

used 8 dbqueries ... used 0.041204929351807 seconds

Scheduled task failed: Mise à jour des tentatives de test en retard (mod_quiz\task\update_overdue_attempts),

Attempt to assign property "firstinsection" on null Backtrace:

* line 718 of /mod/quiz/attemptlib.php: call to quiz_attempt->determine_layout()
* line 648 of /mod/quiz/attemptlib.php: call to quiz_attempt->load_questions()
* line 78 of /mod/quiz/cronlib.php: call to quiz_attempt->__construct()
* line 61 of /mod/quiz/classes/task/update_overdue_attempts.php: call to mod_quiz_overdue_attempt_updater->update_overdue_attempts()
* line 253 of /lib/cronlib.php: call to mod_quiz\task\update_overdue_attempts->execute()
* line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()

I am sure I have seen this reported somewhere before, but I cannot find a tracker issue, so it must have been somewhere else.

This error is coming from where the code tries to look at the structure of quiz_slot and quiz_sections, and determine the layout. So, have a look at the data in those two tables. It would be nice if the failing task told us which quiz id it was that failed. Anyway, look for quiz_sections where firstslot points to a slot that does not exist. Alternatively, look at quiz_attempt.layout, and check that that is a list of slot ids that exist in that quiz.

By the way, which Moodle version are you using?

回复Tim Hunt

Re: update overdue attempts task fail

François Lizotte -
Particularly helpful Moodlers的头像

It's Moodle 3.11.

Thank you so much. I'll get back to you as soon as possible.

François

回复François Lizotte

Re: update overdue attempts task fail

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
I was wondering if you were seeing the problem that MDL-54907 fixed, but that was fixed in 3.10.1. If you can supply more information, then I will try to comment further.
回复François Lizotte

Re: update overdue attempts task fail

François Lizotte -
Particularly helpful Moodlers的头像

Well, we fixed it, but the solution is not clear to me.

After searching in the database, which is rather big and complex, our tech just turned on extra logging and found a query happening in an old course. Deleting the course fixed the task issue.

This is what was caught:

SELECT
    quba.id AS qubaid,
    quba.contextid,
    quba.component,
    quba.preferredbehaviour,
    qa.id AS questionattemptid,
    qa.questionusageid,
    qa.slot,
    qa.behaviour,
    qa.questionid,
    qa.variant,
    qa.maxmark,
    qa.minfraction,
    qa.maxfraction,
    qa.flagged,
    qa.questionsummary,
    qa.rightanswer,
    qa.responsesummary,
    qa.timemodified,
    qas.id AS attemptstepid,
    qas.sequencenumber,
    qas.state,
    qas.fraction,
    qas.timecreated,
    qas.userid,
    qasd.name,
    qasd.value

 

FROM      mdl_question_usages            quba
LEFT JOIN mdl_question_attempts          qa   ON qa.questionusageid    = quba.id
LEFT JOIN mdl_question_attempt_steps     qas  ON qas.questionattemptid = qa.id
LEFT JOIN mdl_question_attempt_step_data qasd ON qasd.attemptstepid    = qas.id

 

WHERE
    quba.id = '82898'

 

ORDER BY
    qa.slot,
    qas.sequencenumber


*************************** 1. row ***************************
            qubaid: 82898
         contextid: 58172
         component: mod_quiz
preferredbehaviour: adaptive
questionattemptid: NULL
   questionusageid: NULL
              slot: NULL
         behaviour: NULL
        questionid: NULL
           variant: NULL
           maxmark: NULL
       minfraction: NULL
       maxfraction: NULL
           flagged: NULL
   questionsummary: NULL
       rightanswer: NULL
   responsesummary: NULL
      timemodified: NULL
     attemptstepid: NULL
    sequencenumber: NULL
             state: NULL
          fraction: NULL
       timecreated: NULL
            userid: NULL
              name: NULL
             value: NULL




回复François Lizotte

Re: update overdue attempts task fail

François Lizotte -
Particularly helpful Moodlers的头像

We hit this issue again on another Moodle site (3.11.13). Here's more information.

1- It began after we updated PHP from 7.3 to 8.0.

2- Again, it's old stuff, more than 10 years old.

3- Deleting the attempts in the quiz fixes the problem. Some attempts belong to deleted users.


回复Tim Hunt

Re: update overdue attempts task fail

Daniel Ziegenberg -
Core developers的头像 Peer reviewers的头像
Hi Tim,

We hit this same problem with several old attempts. The problem is that the quiz_attempt.layout lists several non-existing slots. In my opinion, the scheduled tasks should be a bit more robust and handle failures a bit more gracefully.

Should I report this as a tracker issue?

greetings, Daniel
回复Daniel Ziegenberg

Re: update overdue attempts task fail

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
This task is gradually getting more and more robuse as people hit problems, report them, and fix them.

There are further improvements in Moodle 4.2.3 and the other recent point releases. So, I would say first upgrade to the latest release on your stable branch. Then, if the problem is still present, please create a tracker issue.