Old quiz and question attempts deletion

Maintained by Vadim Dvorovenko
Deletes old quiz and question attempts by scheduler task or by CLI command.
Price option: Free

Supports Moodle 2.7-5.0 See all versions
Latest release: 1 year ago
Installations: 283
Downloads (last 90 days): 76

Frankenstyle name: local_deleteoldquizattempts
Local plugins

Comments

Comments are no longer open for new posts. Existing comments remain available to read.

Karsinora Fenriz
1. If you want to specify dates instead of days, you can set Do not delete old-attempts in interface and use command line interface to specify date.
2. This plugin deletes attempts based on time when atempt was started, so abandoned attempts will not hang longer then completed attempt. This plugin is only for deletion. If you wand abandoned quiz to complete, use core quiz settings and setup timing https://docs.moodle.org/500/en/Quiz_settings#Timing
Good day! Your plugin is a real find. It helped to solve many problems that were provoked by abandoned and old attempts. I wonder, why Moodle developers don't provide something like that in standart Moodle. Such a function is especially important for long functioning systems and with a large number of users.
Taking into account my experience, I would like to suggest some additions:
1. Ability to set a date, not a period. Periods don't provide sufficient flexibility in all cases. For example, I could delete attempts in the fall semester (before January 1, 25), but this means that the period of 180 days is too short - deletion will affect attempts for January, February, and 1 year is too much - the process will not even reach attempts of the fall semester.
2. Ability to configure completion of abandoned attempts independently of deletion process, so that attempts older than, for example, 2 months can be automatically completed so that they do not "hang" waiting for the deletion process, which may reach them much later.
I tested it with moodle 4.5.2 and it worked fine. Thank you
Has anybody tested on moodle 4.1?
Hello Vadim. Your plugin is really great and useful. With Moodle 4 it doesn't seem to work anymore. Correct?
Installed! Thanks a lot!
The (15 / 7 / 3 days) options are simply great. Thanks for your great work, Vadim.
Daninet Bilbao, fixed in latest release
Dear Vadim. Your plugin just saved my life. (I mantain a single course with 4.800 users, hundreds of attempts everyday, so before I discovered your plugin I had to clean all this just by hand). Thanks A LOT!
Just a question: is there an way to configure a shorter period than a month? (For example, automatic deletion every 15 days?). Sorry, I'm not an IT expert, I hope it is easy to configure.
Thanks again
Daniel
Dante Pereyra, I was newer tested this plugin with 2.5, but you may try. Change 2014051200 in version.php to 2013051400 and try to install it
Hey Vadim! This is a great idea, exactly what I need to cleanup our moodle database. Now, we have Moodle 2.5+ version and we're not able to upgrade to 2.7
Do you think this plugin can work for this 2.5+ version?
Thanks Vadim.
I have tried different configurations: the courseid, quizid option, different types of quizzes and courses ... and none of them work
I can't use the cPanel terminal because my hosting does not give that option.
sad
i've checked, your command and it goes no errors for me.
first, run from command line to be sure everything works
/usr/bin/php /home/xxxx/mysite.com/moodle/local/deleteoldquizattempts/cli/delete_attempts.php --days=10 --quizid=26 --verbose
check that you specified right quizeid by visiting mysite.com/moodle/mod/quiz/view.php?q=26 - quizid is not the same as coursemodule id. Sometimes it's better to look into DB id mdl_quiz table.
Check your cron syntax, maybe some misprint, command must be the same, that you test in command line. Maybe your cron requires some escaping of params
When oll is ok, you can add " >/dev/null" to the end of the command to supress output and mails from cron.
Many thanks Vadim!
I am using the following code but it doesn't seem to work:
/usr/bin/php /home/xxxx/mysite.com/moodle/local/deleteoldquizattempts/cli/delete_attempts.php --days=10 --quizid=26
However I receive this mail from cron, what can be the error?
X-Powered-By: PHP/7.4.14
Content-type: text/html; charset=UTF-8
Delete old quiz and question attempts
Options:
--days= Delete attempts that are older than specified number of days
--timestamp= Delete attempts that are created before specified UTC timestamp
--date= Delete attempts that are created before specified date.
Use "YYYY-MM-DD HH:MM:SS" format in UTC
--courseid= Delete only attempts for quizzes in course with specified id.
--quizid= Delete only attempts for quiz with specified id.
--timelimit= Stop execution after specified number of seconds
-v, --verbose Show progress
-h, --help Print out this help
Only one of --days, --timestamp and --date options should be specified.
Examples:
php local/deleteoldquizattempts/cli/delete_attempts.php --days=90 --verbose
php local/deleteoldquizattempts/cli/delete_attempts.php --timestamp=1514764800 --timelimit=300
php local/deleteoldquizattempts/cli/delete_attempts.php --date="2018-01-01 00:00:00"
Phineas Gomez. CLI script has option to specify course id and other params. You can specify 1 year in settings, and create additional cron task running CLI script to cleanup for courses with 1 month period.
I think it would be a good update to be able to choose the deletion time for each of the courses, because in my case I have paid courses that I want to be deleted in a period of 1 year, but in the free courses I wanted to reduce it to just 1 month.
Thanks!!