Moodle 3.1.: Quizzes not submitting automatically

Moodle 3.1.: Quizzes not submitting automatically

by Davian Rodriguez -
Number of replies: 11

I am experiencing an issue with our Moodle where instructors are setting their quizzes to "Open attempts are submitted automatically", yet some submissions that were never submitted but opened are still shown as in progress.

I understand that this was an issue in prior Moodle versions but the work arounds in the past forums do not apply to this version.

cron.php is running every 5 minutes. We have even tried running it manually. We also ran mod/quiz/cronlib.php manually as well with no luck.

We have made no changes to either php files.


We are using Moodle 3.1 Build 20160523

Average of ratings: -
In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

When you run cron, does it complete successfully? Are any errors output?

In reply to Tim Hunt

Re: Moodle 3.1.: Quizzes not submitting automatically

by Davian Rodriguez -

There are no errors.


Cron script completed correctly
Cron completed at 08:10:23. Memory used 18.7MB.
Execution took 0.027019 seconds


In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Running mod/quiz/cronlib.php  won't do anything. That file simply defines a class. To do anything, you need to call the methods defined, which is what cron does.

Actually, what cron runs is this function: https://github.com/moodle/moodle/blob/MOODLE_31_STABLE/mod/quiz/lib.php#L522

As you can see, when it runs is prints

Looking for quiz overdue quiz attempts...

when it starts, and

Considered X attempts in Y quizzes.

when it finishes. Do you see that in the cron output?

In reply to Tim Hunt

Re: Moodle 3.1.: Quizzes not submitting automatically

by Davian Rodriguez -

We were not seeing that in the output. We actually weren't seeing anything except that it was completed. We increased our max_input_vars from 1000 to 2000 and we received more outputs when running cron.php, but when I run lib.php I do not get any output. Within the cron.php output we do not see "looking for quiz overdue quiz attempts" or anything in regards to quizzes.

In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Normally there is lots of cron output, showing all the tasks being run. If that is not the case, then something is fundamentally broken with your cron setup, and this is not a quiz-specific problem.

Have a look on Site administration ▶︎ Server ▶︎ Scheduled tasks. That is one place where things could be set up wrongly.

In reply to Tim Hunt

Re: Moodle 3.1.: Quizzes not submitting automatically

by Davian Rodriguez -

Okay Tim,


We looked into Scheduled tasks and found Legacy cron processing for plugins has not been running. It is on a reoccurring schedule. Using this resource https://moodle.org/mod/forum/discuss.php?d=272994 I was able to run the task manually but with a failure. Here is the command we used as well as the output:

php /var/www/moodle/admin/tool/task/cli/schedule_task.php --execute=\\core\\task\\legacy_plugin_cron_task
Execute scheduled task: Legacy cron processing for plugins (core\task\legacy_plugin_cron_task)
Running auth crons if required...
Running enrol crons if required...
Starting activity modules
Processing module function assign_cron ...
... used 10 dbqueries
... used 0.13500881195068 seconds
Scheduled task failed: Legacy cron processing for plugins (core\task\legacy_plugin_cron_task),Can not find data record in database table context.

I have not been able to find any information about this error in regards to the Legacy cron task. Based on the output the user in the above link was given, I am to believe this is what may be causing the issue.
In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes. That looks like the problem, and the issues is either in mod_assign, or whatever comes immediately after it. (Might be worth trying a run with Debugging set to Developer level to see if that gives more information.

You may also be better off posting subsequent information in another forum?

In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Davian Rodriguez -

We looked within our logs for moodle and found multiple errors such as

PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini

Database transaction aborted automatically in moodle/mod/quiz/processattempt.php

We went ahead and doubled our Input variables. When we ran our cron.php we were given more output than usual. We will be testing and seeing if this resolves our issue.

In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Mike Millings -

I am having the exact same issue on my moodle server.  Chron script runs every 5 minutes but does not fix the issue.

In reply to Davian Rodriguez

Re: Moodle 3.1.: Quizzes not submitting automatically

by Mike Millings -

I had the same problem and here is how I fixed it.  I went to server-->scheduled tasks and noticed that all scheduled tasks stopped running at 7:30am in September 23rd including cron scripts.  I went and found the quiz activity that closed at that same time.....i deleted all quiz attempts and deleted the assignment...in the assignment there was a question that was corrupted....i deleted that question from QB....then ran chron script through address bar and chron script finally ran and all subsequent quiz activities that had opened attempts past the due date were graded....all scheduled tasks are now running again too....let me know if this works for you.