moodle-tool_mergeusers
moodle-tool_mergeusers copied to clipboard
Deleted mdl_course_completion_crit_compl records causes issues
I have Moodle 3.9 and have deployed tool_mergeusers. I found that for migrated users, the records in mdl_course_completion_crit_compl were being deleted by the tool. I don't know if it deletes all the records, but it certainly deleted some. For my environment, it would have worked better to have the userid updated in this table just as in the other tables rather than having the rows deleted. I'm not sure of the history of why this table is handled differently. I corrected the issue by running a script to put these records back in, recreating them from data in mdl_course_modules_completion.
The issue presents itself when a user completes an activity prior to a name change then has their name changed, which is when we have tool_mergeusers automatically run, then the user subsequently completes more activities and finishes the course. The course completion feature doesn't have the older record in mdl_course_completion_crit_compl, because mergeusers removed it. So, when the user has finally completed all activities, the completion feature can't figure out that the all activities are complete.
We have many courses where we use the automatic course completion feature. We have many activities that have automatic completion and are required for course to be automatically complete.
Hi @R-oberto ,
Thanks for contacting.
This plugin processes record by record of every table in Moodle, and processes them in two ways:
- Updating the id from the old one to the new one, or
- In case of presence of compounded table keys (either defined by the table or by the PHP data model), deleting records from the old user and keeping just the ones from the new one.
- Then, other tasks are performed, like ensure completion and regrading things like quizzes, when multiple attemps exist.
The table you refer to mdl_course_completion_crit_compl should be a case of compouned key. This is way the plugin deletes records.
So, tell us how do you performed the operation of restoring and keeping data from both users. Maybe this table needs an exception to be processed in a different way.
Thanks for your time.
Tagging it right now as a possible bug. Let's see how it evolves.