UNIMOODLE / moodle-local_coursetransfer

Lote P3.2 - Restauración de cursos entre plataformas
2 stars 2 forks source link

Functionality 6. Admin plug-in to remove courses from a platform to optimise performance #8

Open mapemo4 opened 7 months ago

mapemo4 commented 7 months ago

-The delete option is missing so that it is not saved in the trash. This functionality was requested so that bulk course deletion doesn't suddenly increase disk space during the deletion period. -If it takes a long time to respond, the WS displays the error message: -120001. At the moment, the timeout is changed to 2000 seconds but indicates error 22011: "You do not have permissions to view the list of courses".

xpazv commented 7 months ago

In review.

xpazv commented 7 months ago

Under development.

We will use the recycle bin task code to bypass admin/tool/recyclebin/classes/task/cleanup_course_bin.php

We will implement a plugin setting to enable or disable the recycle bin feature.

xpazv commented 6 months ago

During the implementation, we have found an important detail to be taken into account, related with the requirement @mapemo4

Moodle uses two scheduled task to delete the category courses and course items to the recycle bin areas.

The course items task uses courseid combined with lifetime setting to gather the course items candidates to be deleted.

The category course task uses just shortname and fullname, combined with lifetime setting to gather the courses to be deleted.

So, if we have to bypass the recycle bin for courses, we cannot use the internal course id to delete the backups as we can only use the shortname, and there is a high chance of having a live course and a course in the recycle bin with the same shortname.

mapemo8 commented 6 months ago

Let's see if this is easier to implement, I'll put it in context @xpazv : The purpose of this is to free space when the administrator performs mass removal. In this case, what happens to moodledata usually increases its size instead of decreasing it, because the files are converted to compressed files like mbz during the garbage storage period (categorybinexpiry) for a week in our case. The draft state remains in the mdl_files table for another 4 days. Then the files are moved to trashdir and the cron system will delete them after 4 days. It may be possible to implement this by doing two cleanups without disabling the trash. First, the administrator deletes the course (optionally, in several installations, the administrator can globally disable the course category (binenablecategory). Second, the administrator performs a selective purge. The administrator does not want to remove all trashdirs without any criteria, as trashdirs can contain activities and resources from teachers.

What we are currently doing is using the CCFg->fileslastcleanup = 0 in config.php after a mass removal. courses, but as I said, we delete the whole trashdir directory. Code related to the above:

www/lib/filestorage/file_storage.php

// Find all outdated project areas (more than 4 days old) and remove them.

I will do an update of the latest code changes and we will have a look at it again.

AngelAyllon commented 6 months ago

When we delete the academic year each year with between 7 and 8000 courses, we manually carry out the following steps, which we assume can be automated in the plugin for deleting courses from a category:

1) Disable the recycling bin for deleted courses 2) Delete the courses 3) Delete the moodledata/trashdir directory 4) Delete the moodledata/temp/backup directory

We assume that the records in mdl_files that remain in draft status are deleted after a few days so, at first, it is not a concern.