jpahullo / moodle-tool_mergeusers

Merge users script for Moodle
https://moodle.org/plugins/view.php?plugin=tool_mergeusers
22 stars 50 forks source link

Scheduler compatibility #230

Open sjaffredo opened 1 year ago

sjaffredo commented 1 year ago

Hi, A fairly indispensable tool, should be integrated into core in my opinion. Thanks for this piece of code. Could it be possible to work for slots created in Scheduler as well? That would be tremendously useful for us.

Best regards,

Sébastien Jaffrédo Institut français du Japon

jpahullo commented 1 year ago

Hi!

Thanks for your words. There is a tracker in Moodle which motivates to include this plugin into core: https://tracker.moodle.org/browse/MDL-61542. You could post there, vote it, to try to push it a bit more. More votes, more possibilities to work on it by Moodle HQ.

However, I think that for including this functionality of merging users (instead of including this plugin as-is), this should be reworded into a new API, so that any part/component/plugin of Moodle defines how to do that. The default behaviour should be the current one: travel database table by table, but enabling that any part of Moodle define how to do that. There are so many issues and special cases related to specific behaviour of all these parts of Moodle (like grades, quiz attempts, and so many others). This approach would enable to adopt it progressively into Moodle core.

Regarding to your question: it would be very useful and convenient to process a single merge users into slots. I agree. The problem arised is how to define these slots: by amount of tables to work on? What should happen if a slot presents an error? Should the rest of slots be processed no matter previous errors if any or should it stop?

There is another issue created to convert any single merging into a single adhoc_task, so that cron.php would process it. However, a single merging could take half an hour easily on our instance, which have aournd 20K users in total. So the idea is go ahead a bit more, and analyse how to create several adhoc_tasks per merging.

Thanks for your words and vote that tracker and ask for voting it ;-)

Jordi

jpahullo commented 9 months ago

By the way, @sjaffredo ,

As Scheduler module is non core, you could provide the mergeusers/config/config.local.php file (create or update) with the necessary settings, as explained in https://github.com/jpahullo/moodle-tool_mergeusers/blob/master/README.md#command-line-script. You should consider cases like:

  1. https://github.com/jpahullo/moodle-tool_mergeusers/blob/master/config/config.php#L56
  2. https://github.com/jpahullo/moodle-tool_mergeusers/blob/master/config/config.php#L147

A similar example is here: https://github.com/jpahullo/moodle-tool_mergeusers/issues/257#issuecomment-1835755986

Let me know if you need more help.

I will leave this open for a while.

Thanks a lot for reporting.

Jordi