Administrators sometimes encounter a warning message in Moodle that says “Activity deletion in progress.” In some cases, the message disappears quickly after a page refresh. In other situations, however, it can persist for hours or even days, preventing instructors from modifying courses or removing activities.
This issue typically indicates that Moodle attempted to delete an activity but the background cleanup process did not complete successfully. Understanding why this happens and how to resolve it can help administrators maintain stable course environments and avoid long-term database issues.
Working with Mindfield is a life changing experience. From Product knowledge to technical expertise the team has gone above and beyond the call of duty more times then I can count.
Greg Shorland
Funeral Learning Hub
Outline
What the “Activity Deletion in Progress” Message Actually Means

When an activity is removed from a course, Moodle performs more than a simple delete action. The system must carefully remove all associated data to maintain integrity across the platform.
During activity deletion, Moodle typically performs several background operations:
-
Removing the activity from the course_modules table
-
Cleaning up related records stored by the activity module
-
Removing associated gradebook items
-
Deleting completion tracking and user attempt data
-
Removing related files stored in the Moodle file system
-
Updating course caches and internal references
Because some activities may contain large amounts of data, such as quizzes with thousands of attempts or assignments with many file uploads, Moodle processes the deletion in stages.
Instead of blocking the entire system while deletion completes, Moodle marks the activity as pending deletion and schedules background cleanup tasks. These tasks run through the cron system, which allows Moodle to finish removing the remaining data safely without affecting site performance.
If any part of that process fails, the activity remains in a partially deleted state and Moodle continues showing the “Activity deletion in progress” message.
Because activity deletion runs through background tasks, the time required depends heavily on how much related data Moodle must remove. Each user attempt, submission, or completion record generates multiple database rows across different tables.
A useful way to estimate deletion complexity is to consider the number of user records connected to the activity. For example:
-
A quiz with 200 users and 3 attempts each may generate 600 attempt records, plus additional grading and completion rows.
-
A large assignment with 1,000 users submitting files can produce thousands of database records and many stored files that must be removed.
In normal conditions, Moodle should complete most activity deletions within a few minutes, assuming cron runs regularly and the server has sufficient resources. If the warning message persists longer than 10–15 minutes for small activities, or longer than an hour for activities with hundreds of users, administrators should begin investigating whether the background cleanup process is stuck.
Why Activity Deletion Sometimes Gets Stuck in Moodle

When Moodle displays the “Activity deletion in progress” warning for an extended period of time, it usually means the system started removing an activity but could not complete the full cleanup process. Because Moodle activities are tightly connected to several internal systems, deleting them requires more than simply removing a single record.
A single activity can affect multiple parts of Moodle, including:
-
Course module references
-
User activity attempts or submissions
-
Gradebook entries
-
Completion tracking records
-
Context and permissions
-
Plugin-specific data tables
If any step of the cleanup process fails, Moodle will leave the activity marked as pending deletion until the remaining tasks are completed.
Incomplete Background Deletion
Moodle often performs activity deletion in stages, particularly when the activity contains a large amount of historical data. For example, quizzes with many attempts or assignments with extensive file submissions require the system to remove records across numerous tables.
If the deletion process is interrupted due to server timeouts, limited resources, or plugin conflicts, the cleanup may stop halfway. Moodle then keeps the activity flagged as being deleted to avoid breaking database relationships or leaving inconsistent data.
Administrators may notice that the activity still appears in the course but cannot be edited, duplicated, or restored. In reality, the system is waiting for background tasks to finish removing the remaining records.
Cron Dependency Failures
A common reason deletion tasks fail to finish is that Moodle relies on cron jobs to complete many background operations. When an activity is deleted, Moodle schedules cleanup tasks that cron must execute in order to remove remaining data.
If cron is not configured correctly or stops running, these tasks will never complete. As a result, Moodle continues to display the deletion warning.
Typical cron-related issues include:
-
Cron not configured on the server
-
Cron scheduled too infrequently
-
Incorrect PHP path used in the cron command
-
Server resource limits stopping tasks early
-
Permission errors preventing cron from running
Modern Moodle installations recommend running cron every minute so that background tasks—including activity deletion—can complete quickly and reliably.
Administrators can verify cron activity by checking:
Site administration → Server → Scheduled tasks
If scheduled tasks have not run recently, or if cleanup tasks show repeated failures, the deletion process may remain stuck.
Grade Item Orphaning
Another complication that can prevent activity deletion from completing involves gradebook records. Many Moodle activities automatically create grade items so that student scores appear in the course gradebook.
When the activity is removed, Moodle must also remove those grade items and their related grading data. If the deletion process fails midway, the gradebook entry may remain while the activity itself is partially deleted.
This situation creates orphaned grade items, where gradebook records still reference activities that no longer exist.
Orphaned grade items can lead to several issues, such as:
-
Gradebook entries that cannot be edited or removed
-
Completion tracking referencing missing activities
-
Cleanup tasks repeatedly attempting to remove invalid records
Until these orphaned records are resolved, Moodle may continue showing the “Activity deletion in progress” message because the system detects incomplete relationships in the database.
Administrators can often estimate whether a deletion delay is normal by considering the approximate number of database records involved. In general:
-
Activities with fewer than 100 users should usually delete within a few minutes.
-
Activities with 500–1,000 users or large numbers of attempts may take 15–60 minutes depending on server performance.
-
Activities generating tens of thousands of related records, such as quizzes with multiple attempts across large cohorts, may take longer but should still complete once cron processes the queued tasks.
If an activity remains in the “Activity deletion in progress” state for several hours, or if the same message persists after multiple cron cycles, it usually indicates that the cleanup process has failed rather than simply running slowly.
At that point, administrators should review scheduled task logs and verify whether the deletion tasks are completing successfully.
Database Cleanup Strategies

If the deletion warning persists after cron runs normally, administrators may need to perform additional investigation and cleanup.
Several strategies can help resolve the issue safely.
Review Scheduled Task Logs
The first step is verifying whether Moodle attempted to run the cleanup tasks and whether any errors occurred during execution. The scheduled task logs can reveal problems such as database query failures, plugin errors, or server timeouts.
Purge Moodle Caches
In some situations, the warning message may persist due to cached course data. Clearing Moodle caches forces the system to reload activity states from the database.
This can be done through:
Site administration → Development → Purge caches
Although cache clearing will not fix database inconsistencies, it can resolve interface issues that make the deletion appear stuck.
Inspect the Course Activity Structure
Administrators should check whether the activity still appears in the course editing interface. If it appears but cannot be opened or modified, the course module reference may still exist in the course_modules table.
Database-Level Inspection
If the problem persists, a deeper review of Moodle database tables may be required. Tables commonly involved in activity deletion include:
-
course_modules
-
modules
-
context
-
grade_items
-
grade_grades
Administrators may need to confirm that the module instance and related records were removed properly.
Because these tables are interconnected, database changes should always be performed cautiously and preferably first tested in a staging environment.
Long-Term Prevention Planning

While resolving a single deletion issue is important, preventing future occurrences is even more valuable for long-term system stability.
Several proactive strategies can help minimize the risk of stuck activity deletions.
Maintain Reliable Cron Execution
Ensuring that cron runs consistently is one of the most important maintenance practices in Moodle administration.
Cron should:
-
Run every minute
-
Use the correct PHP version
-
Be monitored for failed tasks
-
Be reviewed after system upgrades
Reliable cron execution ensures that background processes such as activity cleanup complete quickly.
Monitor Large Activity Deletions
Deleting very large activities can place temporary strain on the system. Administrators may consider performing these actions during low-traffic periods to reduce the likelihood of timeouts.
Keep Plugins Updated
Outdated or poorly maintained plugins can interfere with activity deletion processes. Regularly reviewing and updating plugins helps ensure compatibility with the current Moodle version.
Maintain Database Health
Routine database maintenance, including optimization and monitoring for large unused tables, can reduce the risk of cleanup failures.
Administrators should also periodically review logs for recurring task failures that may indicate deeper system issues.
Large Moodle sites can benefit from monitoring the scale of activity data before performing deletions. For example:
-
A quiz with 5,000 attempts may generate 20,000+ database rows across related tables.
-
A course with 1,500 enrolled users may create large completion and gradebook datasets tied to each activity.
If administrators regularly manage courses with thousands of users or high volume activities, it is helpful to schedule large deletions during low traffic periods and monitor cron execution closely. When an activity deletion remains pending longer than two or three cron cycles, it is usually a signal that deeper investigation is required.
Powering Stable Moodle Maintenance with Expert Support

When Moodle displays warnings such as “Activity deletion in progress,” the issue is often tied to deeper system mechanisms like cron tasks, database relationships, or gradebook dependencies. While the warning itself may appear simple, diagnosing the underlying cause can require detailed knowledge of Moodle’s architecture, including how course modules, scheduled tasks, and database tables interact during activity removal.
Experienced Moodle experts can quickly identify why deletion processes become stuck and safely resolve the issue without risking further data inconsistencies. They can audit cron configurations, repair orphaned grade items, and implement proper database cleanup strategies. Beyond fixing the immediate problem, Moodle specialists can also establish monitoring and maintenance practices that help prevent similar issues from occurring in the future, ensuring a more stable and reliable learning platform for administrators and instructors.

