The issue appears in the cron output:
Adhoc task failed: core_course\task\course_delete_modules, Coding error detected, it must be fixed by a programmer: The course module SOME_CM_ID could not be deleted.
It would be fine to found an universal solution for this issue.
The issue appears for different activities.
It was noticed for:
It appears when "Enable course recycle bin" is turned on.
In DB it looks the same for at least most of the cases:
- No record in plugin's table like mdl_questionnaire or mdl_bigbluebuttonbn,
- Kept record in mdl_course_modules
Check mdl_course_modules table in a cron is there related records in the plugin's tables and remove orphaned course module records.